4
$\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
  • 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
    Commented May 5, 2014 at 0:45
  • $\begingroup$ Here's a code snippet that could help. library(fpp) dec_series <- decompose(a10) dec_series$figure $\endgroup$
    – Arun Jose
    Commented May 5, 2014 at 12:03

1 Answer 1

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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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