Solved – How to calculate time series seasonality index in R

seasonalitytime series

In R, I use the decompose method on my time series object and it gives me seasonal + trend + random component. For seasonal component, it gives me absolute value which is good but I would also like to know the monthly seasonality index as well (like Jan .084, Feb 0.90, Mar 1.12, etc., for example). Is there a quick way to get this seasonality index in R? Also, how is it normally calculated?

Best Answer

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).

Related Question