3
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ tslm function in forecast package does this automatically. It is wrapper of lm function for time series problems that creates trend and seasonal index automatically. You could try tslm function $\endgroup$ – forecaster May 5 '14 at 0:45
4
$\begingroup$

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

$\endgroup$
0
$\begingroup$

Here's a code snippet that could help.

library(fpp) dec_series <- decompose(a10) dec_series$figure

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.