Escolar Documentos
Profissional Documentos
Cultura Documentos
A seasonal time series consists of a trend component, a seasonal component and an irregular
component. Decomposing the time series means separating the time series into these three
components: that is, estimating these three components.
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)
R-Code
> # decompose time series
> apts <- ts(AirPassengers, frequency=12)
> f <- decompose(apts)
> plot(f)
Approach
The method decompose uses
Usage
decompose(x, type = c("additive", "multiplicative"), filter = NULL)
Arguments
x
A time series.
type The type of seasonal component. Can be abbreviated.
filter A vector of filter coefficients in reverse time order (as for AR or MA coefficients), used
for filtering out the seasonal component. If NULL, a moving average with symmetric
window is performed.
Details