You are on page 1of 4

# Seasonal Analysis

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

The Seasonal Trend Decomposition using Loess (STL) is an algorithm that was developed to help to
divide up a time series into three components namely: the trend, seasonality and remainder. The
methodology was presented by Robert Cleveland, William Cleveland, Jean McRae and Irma
Trepanning in the Journal of Official Statistics in 1990. The STL is available within R via
the stl function.
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.

## How Time Series Decomposes the Elements

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.
We propose to decompose each series into several components.
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
The method for evaluating the trend of a time series is to use nonparametric regression techniques
(which in fact can be seen as a special case of linear filters). The function stl( ) performs a seasonal
decomposition of a given time series Xt by determining the trend Tt using loess regression and
then calculating the seasonal component St (and the residuals et) from the differences Xt Tt
performing the seasonal decomposition for the time series.
The data is firstly fed into r and then Transformed. This transformation is required for most of
the timeseries functions, since a time series contains more information than the values itself,
namely information about dates and frequencies at which the time series has been recorded.

R-Code
> # decompose time series
> apts <- ts(AirPassengers, frequency=12)
> f <- decompose(apts)
> plot(f)

Approach
The method decompose uses

## Classical Seasonal Decomposition by Moving Averages

Description
Decompose a time series into seasonal, trend and irregular components using moving averages.Deals with

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

## The additive model used is:

Y[t] = T[t] + S[t] + e[t]
The multiplicative model used is:
Y[t] = T[t] * S[t] * e[t]
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.
This only works well if x covers an integer number of complete periods.