Xristos Solwmou
Xristos Solwmou

Reputation: 119

Making sense of the decomposition plot in R

I'm trying to understand what does the decomposition function and plot actually indicate. I'm using the following as an example:

library(TTR)
t <- ts(co2, frequency=12, start=1, deltat=1/12)
td <- decompose(t)
plot(td)

I'm not quite sure what the seasonal component and random component actually tells us.

Specifically, why does the seasonal graph fluctuates between -3 and + 2, for all time. Shouldn't it have similar fluctuations as the observed series? And what does actually the range between -3 and +2 mean?

Furthermore, what does the random component actually say? Are those the residual errors, and seasonal + random = observed???

Any help will be greatly appreciated since i am quite confused at this point. Decomposed graph looks like: enter image description here

Upvotes: 0

Views: 1442

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 173858

You can answer this yourself really, by accessing the components using $

library(TTR)
t <- ts(co2, frequency=12, start=1, deltat=1/12)
td <- decompose(t)

Here's the seasonal component on its own:

plot(td$seasonal)

Now add the trend:

plot(td$seasonal + td$trend)

and finally the random component:

plot(td$seasonal + td$trend + td$random)

and compare this to the original data:

plot(td$x)

So the time series is decomposed into a seasonal component, which by definition repeats without variation, a trend line around which the seasonal component varies, and a "random" component which is akin to residuals.

Created on 2020-03-03 by the reprex package (v0.3.0)

Upvotes: 2

Related Questions