Professional Documents
Culture Documents
Decomposition
Decomposition
To estimate the trend component and seasonal component of a seasonal time series that
can be described using an additive model, we can use the decompose() function in R. This
function estimates the trend, seasonal, and irregular components of a time series that can
be described using an additive model.
The function decompose() returns a list object as its result, where the estimates of the
seasonal component, trend component and irregular component are stored in named
elements of that list objects, called seasonal, trend, and random respectively.
By plotting the seasonal component we can observe the patterns being followed over the
course of time for the particular year.
This helps in predicting the future component and is widely used for seasonal planning of
programs for the enterprise.
R- Code
> # decompose time series
> apts <- ts(AirPassengers, frequency=12)
> f <- decompose(apts)
> # seasonal figures
> f$figure
[1] -24.748737 -36.188131 -2.241162 -8.036616 -4.506313 35.402778 63.830808
[8] 62.823232 16.520202 -20.642677 -53.593434 -28.619949
> plot(f$figure, type="b", xaxt="n", xlab="")
> # get names of 12 months in English words
> monthNames <- months(ISOdate(2011,1:12,1))
> # label x-axis with month names
> # las is set to 2 for vertical label orientation
> axis(1, at=1:12, labels=monthNames, las=2)
Time Series Decomposition is to decompose a time series into trend, seasonal, cyclical and
irregular components. The trend component stands for long term trend, the seasonal
component is seasonal variation, the cyclical component is repeated but non-periodic
fluctuations and the residuals are irregular component.
Time series represents data which has been sampled at equi-spaced points in time. A
frequency of 7 indicates that a time series is composed of weekly data, and 12 and 4 are
used respectively for monthly and quarterly series.
T Ct Trend-Cycle
St Seasonal
Rt Random
By identifying the various components, our aim is to separate the Random component from
the other components of the series. This way we hope to be able to eliminate the noise and
isolate the true signal
R-Code
> # decompose time series
> apts <- ts(AirPassengers, frequency=12)
> f <- decompose(apts)
> plot(f)