You are on page 1of 20

Introduction to demand forecasting

Time series components. Time series decomposition: remove


trend and seasonality.

MSc. Marı́a Belen Segovia

Escuela Superior Politécnica del Litoral

2022
A General Approach to Time Series Modelling
Time series components
So far we have defined as Trend of a time series as a “long term
change in the mean level”.

The notation we will use is as follows:

Xt = µt + st + t f or t ∈ Z
where µt is the trend component at time t, st is the seasonal com-
ponent at time t and t is a random error with zero mean.

This is known as the classical decomposition model.

If the series has a linear trend, then ut = a + bt, where a and b are
constants.

Important note: in the textbook (Chopra) a is referred as the level


and b is referred as the “trend” so trend is the change in the mean
level per unit time.
Time series components
Three seasonal models in common use are:

Xt = ut + St + t (additive)
Xt = ut St + t (multiplicative)
Xt = ut St t (multiplicative)

where ut is the deseasonalized mean level at time t; St is the seasonal


effect at time t and t is the random error.
If there is a trend in the series and the size of the seasonal effect
appears to increase with the mean, then it may be advisable to
transform the data so as to make the seasonal effect constant from
year to year. The seasonal effect is then said to be additive.

if the size of the seasonal effect is directly proportional to the mean,


then the seasonal effect is said to be multiplicative.
Time series components

An alternative to using a multiplicative decomposition is to first


transform the data until the variation in the series appears to be
stable over time, then use an additive decomposition. When a log
transformation has been used, this is equivalent to using a multi-
plicative decomposition because

xt = ut St t is equivalent to log(xt ) = log(ut ) + log(Tt ) + log(Rt )


Time series components
Time series decomposition

The idea is that after removing the deterministic (or systematic)


components st and ut , we will hopefully have left a stationary
stochastic process t . Then the stationary models, can be fitted
to t and used to estimate and forecast the process. Then, we add
the trend and seasonality back.
There are two common procedures for trend removal. However, we
will focus only on filtering for detrending a time series.
Time series decomposition
Trend decomposition in absence of Seasonality
Linear filter

A linear filter or adjusted-average graduation converts one time series


{Xt }, into another {Yt } by using the formula:
+s
X
yt = ar xt+r
r=−q

where {ar } is a set of weights.

In orderPto estimate the local mean with a weighted average, we


choose ar = 1 .

I Adjusted average formula are symmetric when s = q and aj =


a−j .
Trend decomposition in absence of Seasonality
Moving average filter

A procedure to estimate trend is to use a finite moving average filter,


which converts one time series {Xt }, into another {Yt } by:
q
1 X
yt = Xt−j
2q + 1
j=−q

where q ≥ 0.

The values yt are the smoothed or graduated observations. These


smoothed observations are used as a estimate of the trend, so ût =
yt .
Trend decomposition in absence of Seasonality

Whenever a symmetric filter is chosen, there is likely to be an end-


effect problem, since yt can only be calculated for t = (q + 1) to
t = n − q.

In forecasting, it is particularly important to get smoothed values


right up to t = N . The analyst can use an asymmetric filter that
only involves present and past values of xt .
Trend decomposition in absence of Seasonality
Exponential smoothing

A common example of a non-central filter is exponential smoothing.



X
yt = α(1 − α)j xt−j
j=0

where α is a constant such that 0 < α < 1. Thus, the weights


αj = α(1 − α)j decrease geometrically with j.
Trend decomposition in absence of Seasonality
Fitting a polynomial

To remove or estimate the trend under the classical decomposition


model, fitting a k order polynomial to the observations x1 , . . . , xn

Then, let the trend ut = a0 + a1 t + . . . + ak tk

To find the estimates of coefficients a0 , . . . , ak least squares estima-


tion can be used.
Trend decomposition in absence of Seasonality
Trend elimination by differencing

A special type of filtering, which is particularly useful for removing


a trend, is simply to difference a given time series until it becomes
stationary.

This method is an integral part of the so-called Box-Jenkins proce-


dure.

For non-seasonal data, first-order differencing is usually sufficient to


attain apparent stationarity.

A new series,(say) {y2 , . . . , yn }, is formed from the original observed


series, say {x1 , .., xn }, by yt = xt − xt−1 = (1 − B)xt for t =
2, 3, . . . n
Decomposition of series that contain trend and seasonality
variation
Method from Brockwell and Davis 2002

Suppose we have observations {x1 , . . . , xn } with seasonal variation


of period d. Using the Classical Decomposition Model:

Xt = ut + St + t , ∀t = 1, . . . , n

I Step 1.The trend is first estimated by applying a moving average


filter specially chosen to eliminate the seasonal component. Use
an adjusted average formula of the form:
(
1 1
( xt−q + xt−q+1 + . . . + 12 xt+q ), for d = 2q,q < t < n − q
yt = d1 2
d (xt−q + xt−q+1 + . . . + xt+q ), d = 2q + 1,q + 1 < t < n − q
to obtain an initial estimate of the trend ût = yt
Decomposition of series that contain trend and seasonality
variation
Method from Brockwell and Davis 2002

I Step 2. Compute the deviations. That is, substract ût from


observations xt .
I Step 3. Estimate the seasonal component: compute the aver-
age sk of the deviations. As these estimates do not necessarily
sum to zero. We estimate the seasonal component ŝk as
d
1X
ŝk = wk − wi , k = 1, . . . , d
d
i=1

I Step 4. The deseasonalized data is then defined to be the


original series with the estimated seasonal component removed

x0t = xt − ŝt , t = 1, . . . , n
Decomposition of series that contain trend and seasonality
variation

I Step 5. We reestimate the trend from the deseasonalized data


x0t using one of the methods already described.
I Step 6. Subtract this estimate of the trend from {x0t }, to obtain
a new series x00t = xt − ŝt − ût .
I Step 7. Model this new series {x00t } with a stationary process.
Decomposition of series that contain trend and seasonality
variation
Elimination of Trend and Seasonal Components by Differencing
The technique of differencing that we applied earlier to nonseasonal
data can be adapted to deal with seasonality of period d by intro-
ducing the lag−d differencing operator Dd defined by:

Dd Xt = Xt − Xt−d = (1 − B d )Xt

After applying the operator Dd to the model:

Xt = ut + st + t
where {st } has period d, we obtain:

Dd Xt = µt − µt−d + t − t−d
The descomposition of the series is: trend component (ut − ut−d )
and a noise term (t − t−d ).
Decomposition of series that contain trend and seasonality
variation

Other methods: X11 ,X12, SEATS, TRAMO.


Decomposition in R

You might also like