I want to know which is the procedure to remove the seasonality (anual cycle, monthly cycle, daily cycle) of a time serie. I plotted the Autocorrelogram of my time series and I extracted from there the seasonality (in my case, anual cycle), but I don't know how to remove it.
Solved – How to remove the seasonality of a time series
seasonalitytime series
Related Solutions
Modeling daily electricity demand is a data intensive effort. To simplify this, it's easier to start "zoomed out", estimating monthly loads. Here's an article (with a Youtube video) that describes a monthly model that is simple and easy to understand. The article includes R code:
http://revgr.com/2012/11/06/all-forecasts-are-wrong-but-some-generate-fewer-complaints/
As you "zoom in" to shorter time frames the problem gets more and more complicated. For example, the monthly model includes an integer 12 months/year and starts at the beginning of month 1, while a weekly model includes a non-integer 52.18 weeks/year and might begin at the start of a week, middle of the week, end of the week, etc (i.e. you can't directly compare "week 1" of one year to "week 1" of the next year, they start on different days). It gets more complicated when you drop down to daily or hourly time frames.
The hierarchy in time frames, starting with the longest time frame, is typically:
1) Population growth and economic activity.
2) Long term seasonal temperature terms (summer, winter, etc).
3) Day of the week (Tuesday, Wednesday and Thursday are typically similar workdays; the remaining days have their own individual "day-of-the-week" values).
4) Holidays, the day before and the day after a holiday (many holidays have a similar value as a typical Sunday "day-of-the-week" value).
5) Temperature due to time of day, cooler nights, warmer days, is the sun shining, is it raining, etc. (this is a refinement of item 2 above).
6) Work load during the day. People are typically at home during the night and at work during the day, so lot of electricity consuming workplaces shut down at night.
7) Other terms such as humidity, daylight savings time, etc.
The bottom line is, at the daily and hourly time frames, a lot of data (and complexity) is required.
You can Google "daily electrical load models" (or hourly models) and various papers will show up. Some are based on neural nets, support vector machines, etc. Here's a link to a paper by Rob Hyndman that explains another technique.
http://www.tandfonline.com/doi/abs/10.1198/jasa.2011.tm09771#.UrNTUtJDuyw
The methods used in that paper are in the "forecast" package:
Just extract the "figure" component from your "decomposed.ts" object. The seasonal component is just the recycled figure over the time range of the time series.
As for the calculation, I find the explanation in the details section of the manual page helpful: The function first determines the trend component using a moving average (if filter is NULL, a symmetric window with equal weights is used), and removes it from the time series. Then, the seasonal figure is computed by averaging, for each time unit, over all periods. The seasonal figure is then centered. Finally, the error component is determined by removing trend and seasonal figure (recycled as needed) from the original time series.
Of course, there are other methods for constructing such a seasonal index/figure, including the mentioned tslm (or dynlm from the package of the same name) or stl (in stats).
Best Answer
Usually time series is thought to be represented by following construction:
series = seasonal component + trend component + irregular component
One way to deseasonalize series is to extract trend and add irregular component back to the trend.
For example R has a function stl which can be used to form a three component matrix for time series. You can take trend and irregular component and form an deseasonalized series:
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/stl.html
Actually since we observer only one time series and not these unobservable components, we need many assumptions when modeling these series.