You are on page 1of 34

Business Forecasting

ECON2209
Slides 04

Lecturer: Minxian Yang

BF-04

my, School of Economics, UNSW

Ch.5, 6, 13.4 Trend & Seasonality

Lecture Plan
Simple models and estimation of trend
time trend models and OLS
smoothers
de-trending

Simple models and estimation of seasonality

models with seasonal dummies and OLS


separate seasonality and trend in linear regression
seasonal smoothers
seasonal adjustment

Big picture:
BF-04

yt = mt + st + xt ,

st + p = st ,

my, School of Economics, UNSW

s
k =1

t +k

= 0,

E( xt ) = 0
2

Ch.5 Trend

Trend: modelling and forecasting (Ch.5, 13.4)


Time trend models (deterministic)
The trend, mt, is treated as a function of time:
yt = mt + st + xt , mt = m(t , ), t = 1,2,3,...

where stands for parameters.


Linear and quadratic trends

Textbook notation :
Tt = mt , and TIME t = t.
Logistic Functions

mt = 0 + 1t ;
mt = 0 + 1t + 2t 2 .

Logistic function
mt =
BF-04

1 + 1exp( 2t )

, 2 > 0.

0
my, School of Economics, UNSW

- enter market,
- sales grow,
- market satiates.
t
3

Ch.5 Trend

Estimation of time trend


Least squares: choose parameter estimates to
minimise SSR,
yt = mt + t , mt = m(t , ), t = 1,2,3,...

minimises

)]2 ,

y
t

[
m(
,
t
t =1

where t stands for st + xt in the big picture.


OLS is applicable to polynomial trends.
eg. Quadratic trend: yt = 0 + 1t + 2t 2 + t .

Non-linear LS is applicable to logistic trends.


BF-04

my, School of Economics, UNSW

Ch.5 Trend

Estimation of time trend


eg. China 19622003: Income per capita: logGNI = 0 + 1t + t
China 1962-2003: Income per Capita

China 1962-2003: log Income per Capita

1200

7.5

1000

7.0
6.5

800

6.0
600
5.5
400
5.0
200

4.5

4.0
1965 1970 1975 1980 1985 1990 1995 2000

1965 1970 1975 1980 1985 1990 1995 2000


7
6
.3

.2
4

.1
.0
-.1
-.2
-.3
1965 1970 1975 1980 1985 1990 1995 2000
Residual

BF-04

my, School of Economics, UNSW

Actual

Fitted

Ch.5 Trend

Estimation of time trend


Selecting time polynomial
Is time trend linear, quadratic, or cubic?
Select the polynomial order by minimising AIC/SIC:
K

mt = 0 + i t i ,
i =1

AIC(K) = ln(

SSR
SSR
K +1
K +1
)+2
, SIC(K) = ln(
) + ln(T )
.
T
T
T
T

eg. China: Income per capita

BF-04

K=1

K =2

K=3

K=4

AIC

-1.326056

-1.580543

-1.958790

-1.911177

SIC

-1.243309

-1.456423

-1.793297

-1.704312

my, School of Economics, UNSW

In general, AIC tends


to select a larger K
than SIC.

Ch.5 Trend

Estimation of time trend


eg. China 19622003:
Income per capita
logGNI = 0 + 1t + 1t2 + 1t3 + t

8
7
6
.2

.1

.0
-.1
-.2
-.3
1965 1970 1975 1980 1985 1990 1995 2000
Residual

Actual

Fitted

The in-sample fit is good.


But it does not guarantee
good out-of-sample
predictions!
BF-04

my, School of Economics, UNSW

Ch.5 Trend

Estimation of time trend


EViews
'Read data in Eviews by clicking
File, Open, Foreign Data as Workfile, chinaGNI.xls (in File name), Open, Finish
'Plot data by typing in top panel
genr y=log(gni)
y.line
'Generate time trend
genr tt=@trend(1962)
'Find SIC/AIC for K=1,2,3,4 by inspecting regression results
ls y c tt
ls y c tt tt^2
ls y c tt tt^2 tt^3
ls y c tt tt^2 tt^3 tt^4

BF-04

my, School of Economics, UNSW

Ch.5 Trend

Time trend forecast


Forecasts are based on estimated parameters.
Point forecast: sample end T, horizon h
K

T + h = 0 + i (T + h) i
m
i =1

T+h

Interval forecast:
T + h 2 sT + h , m
T + h + 2 sT + h ],
95% CI [m
sT + h = estimated std deviation of forecast error
= s[1 + xT + h ( X ' X ) 1 xT + h ]1/ 2 ,
s = = standard error of regression.
BF-04

my, School of Economics, UNSW

Ch.5 Trend

Time trend forecast


eg. China 1962 2003: log Income per Capita
estimation period: 1962 1995,
SIC(K=1), AIC(K=4)
forecasting period: 1996 2003

Linear Trend Forecasts

7.5
7.0
6.5
6.0

5.5
5.0
4.5

K=1 model did not do well,


under predicting systematically.
A pattern change in early 90s?
K=4 model did OK but over
forecasts from 1999 onward.

4.0
1965 1970 1975 1980 1985 1990 1995 2000

Quadruple Trend Forecasts


9

4
1965 1970 1975 1980 1985 1990 1995 2000

BF-04

my, School of Economics, UNSW

10

Ch.5 Trend

Time trend forecast


Eviews
eqn4.forecast yhat se
produces extrapolation
forecasts (in yhat) and
standard errors (in se).
eqn4.makeresids res
stores residuals in res.

'Supsample for estimation


smpl 1962 1995
equation eqn1.ls y c tt
equation eqn4.ls y c tt tt^2 tt^3 tt^4
'Supsample for forecasts
smpl 1996 2003
eqn4.forecast yhat se
genr yf=yhat
genr yf_up=yhat+2*se
genr yf_lo=yhat-2*se
'Generate fitted values
smpl 1962 1995
eqn4.makeresids res
genr fitted=y-res
'Supsample for plotting
smpl 1962 2003
plot y yf yf_up yf_lo fitted

BF-04

my, School of Economics, UNSW

11

Ch.5, 13.4 Trend

Trend and smoothers


A local average (smoother) can reveal the trend in
data and is useful for de-trending data.
eg. Average monthly data over a year to find trend.

Two-sided moving average (MA) smoothers:


averaging yt and k observations before & after.
yt (2k + 1) =

w y

i = k

t i

i = k

= 1.

eg. MA(3) with wi = 1/3:


yt (3) = ( yt 1 + yt + yt +1 ) / 3.

BF-04

my, School of Economics, UNSW

For unobservable z(t), here are


some well-known terms.
Forecasting
use info(t-1) to estimate z(t).
Filtering
use info(t) to estimate z(t).
Smoothing
use info(T) to estimate z(t).

12

Ch.5, 13.4 Trend

Trend and smoothers


e.g. Department stores turnover: 1982.04 1999.10
yt (7) = ( yt 3 + yt 2 + yt 1 + yt + yt +1 + yt + 2 + yt +3 ) / 7,
yt (12) = ( yt 6 + + yt 1 + yt + yt +1 + + yt +5 ) / 12.
log Retail Turnover & MA12b

log Retail Turnover & MA7


8.0

8.0

7.6

7.6

7.2

7.2

6.8

6.8

6.4

6.4

6.0

6.0

5.6

5.6
82

BF-04

84

86

88

90

92

94

96

98

82

84

my, School of Economics, UNSW

86

88

90

92

94

96

98

13

Ch.5, 13.4 Trend

Trend and smoothers


Properties of 2-sided MA smoothers
(a) Longer the MA, smoother the trend.
(b) Proper length/weights eliminate seasonality.
e.g. MA(3) with equal weights wipes out
seasonality of 3 periods.
yt = mt + st + t ,

s
i =1

t i

= 0,

E( t ) = 0 ,

1
1
1
yt = ( mt 1 + mt + mt +1 ) + ( st 1 + st + st +1 ) + ( t 1 + t + t +1 ) mt
3
3
3

(c) Past and future observations are required.


(2-sided MA not directly helpful for forecasting)
BF-04

my, School of Economics, UNSW

14

Ch.5, 13.4 Trend

Trend and smoothers


Convolution of MA smoothers
How to MA over an even number of data points?
Hope to eliminate seasonality of period 2k.
e.g. Two ways to do MA(4). Neither is centred.
yt =

yt 2 + yt 1 + yt + yt +1
,
4

yt+ =

yt 1 + yt + yt +1 + yt + 2
.
4

Both able to wipe out seasonality of period 4.


The convolution of the two, MA(2*4),
yt + yt+ yt 2 + 2 yt 1 + 2 yt + 2 yt +1 + yt + 2
=
yt =
2
8

is centred and free of quarterly seasonality.


BF-04

my, School of Economics, UNSW

15

Ch.5, 13.4 Trend

Trend and smoothers


e.g. Department stores turnover: 1982.04 1999.10
yt (12) = ( yt 6 + + yt 1 + yt + yt +1 + + yt +5 ) / 12,

yt+ (12) = ( yt 5 + + yt 1 + yt + yt +1 + + yt + 6 ) / 12,


yt (2 *12) = [ yt (12) + yt+ (12)] / 2.
log Retail Turnover & MA2x12

MA12b - MA(2*12)

8.0

.006
.004

7.6

.002

7.2

.000

6.8

-.002
-.004

6.4

-.006

6.0

-.008

5.6

-.010

82

BF-04

84

86

88

90

92

94

96

98

82

84

my, School of Economics, UNSW

86

88

90

92

94

96

98

16

Ch.5, 13.4 Trend

Trend and smoothers


One-sided MA smoother
It averages the past and the present.
k

yt (k + 1) = wi yt i ,

w = 1.

i =0

i =0

eg. Department stores turnover: 1982.04 1999.10, wi = 1/12


yt (12) = ( yt 11 + yt 10 + + yt 1 + yt ) / 12.
log Retail Turnover, MA2x12 & OMA12

MA2x12 - OMA12

8.0

.07
.06

7.6

.05
7.2

.04

6.8

.03
.02

6.4

.01
6.0

.00

5.6

-.01
82

BF-04

84

86

88

90

92

94

96

98

82

84

my, School of Economics, UNSW

86

88

90

92

94

96

98

17

Ch.5, 13.4 Trend

Trend and smoothers


Exponential MA smoother
It may be beneficial if
more weight is placed on recent observations;
weight diminishes with lags.

With exponentially decreasing weights, we have


exponentially-weighted MA (EWMA):

yt = (1 )i yt i ,

0 < <1

i =0

or
yt +1 = yt +1 + (1 ) yt ,

BF-04

y1 = y1 ,

t = 2,3,...

my, School of Economics, UNSW

It is possible to choose
to minimise the sum
of squared in-sample
forecast errors.

18

Ch.5, 13.4 Trend

Trend and smoothers


e.g. Department stores turnover: Exponential MA smoother
Seasonality is
still visible.

log Retail Turnover & Exponential MA Smoother


8.0
7.6
7.2
6.8

EViews smooth
uses an average as
starting value.

6.4
6.0
5.6
82

84

86

88
EMAV

BF-04

my, School of Economics, UNSW

90

92
Y

94

96

98

EMA

19

Ch.5, 13.4 Trend

Trend and smoothers

genr ema(1)=.1*y(1)+.9*ema
is equivalent to

EViews
'Read departstoresTurnover05.xls in Eviews from 1982:04 to 2005:04,
'For clicks, see p25, BF-03

ema(t+1)=.1*y(t+1)+.9*ema(t)
for t = 2,3, ...

'Use a subsample for now


smpl 1982:04 1999:10
genr y=log(sales)
'Estimate trend with 2-sided MA smoothers
genr ma7=(y(-3)+y(-2)+y(-1)+y+y(1)+y(2)+y(3))/7
genr ma12b=(y(-6)+y(-5)+y(-4)+y(-3)+y(-2)+y(-1)+y+y(1)+y(2)+y(3)+y(4)+y(5))/12
genr ma12f=(y(-5)+y(-4)+y(-3)+y(-2)+y(-1)+y+y(1)+y(2)+y(3)+y(4)+y(5)+y(6))/12
genr ma2x12=0.5*(ma12b+ma12f)
genr ma12b_ma2x12=ma12b - ma2x12
plot ma2x12 y
plot ma12b_ma2x12
'Estimate trend with 1-sided MA smoothers
genr oma12=(y(-11)+y(-10)+y(-9)+y(-8)+y(-7)+y(-6)+y(-5)+y(-4)+y(-3)+y(-2)+y(-1)+y)/12
genr ma2x12_oma12=ma2x12 - oma12
'Exponential MA smoother
y.smooth(s, .1) emav
genr ema=y
genr ema(1)=.1*y(1)+.9*ema
plot emav y ema
BF-04

= 0. 1

my, School of Economics, UNSW

20

Ch.5, 13.4 Trend

Trend and smoothers


Exponential MA smoother and error correction
Forecast yt :

yt|t 1 = yt 1 ;

Forecast error :

et = yt yt 1 ;

Update MA :

yt = yt 1 + et ;

e.g. China 1962 2003:


Income per Capita,
EWMA(=0.8) and error
EWMA(t-1) appears 1 step behind
with systematic forecast errors.

(use info at t 1)

(error correction)
Income per Capita & Exp MA forecast: alpha=0.8
1200
1000
800
600
400
200
0
1965 1970 1975 1980 1985 1990 1995 2000

BF-04

my, School of Economics, UNSW

21

Ch.5, 13.4 Trend

Trend and smoothers


Exponential MA smoother can be used as an easy
1-step ahead forecast.
eg. y1 = y1 , yt +1|t = yt , yt +1 = yt +1 + (1 ) yt , t = 1,2,3,...

Choice of : least squares, experience


eg. RiskMetrics used = 1 0.94 to forecast volatilities of
asset returns.

Exponential MA smoother does not eliminate


seasonality.
BF-04

my, School of Economics, UNSW

22

Ch.6 Seasonality

Seasonality: modelling and forecasting


yt = mt + st + xt ,

st + p = st ,

s
k =1

t +k

= 0,

E( xt ) = 0

Seasonal dummy variables


Seasonality is the re-occurring effects caused by
institutional or customary arrangement.
eg.

BF-04

holiday: Christmas spending


day-of-week: Monday trading differs from Friday?
month-of-year: End of financial-year sales
...

my, School of Economics, UNSW

23

Ch.6 Seasonality

Seasonal dummy variables


Seasonal dummies are indicators of seasons.
eg. Quarterly data: quarter-of-year effects
t

quarter

D1t

D2t

D3t

D4t

96q1

96q2

96q3

96q4

97q1

97q2

97q3

97q4

98q1

D
j =1

jt

= 1,

D
k =1

j ,t + k

= 1,

st = j D jt ?
j =1

How to normalise : st + k = 0 ?
BF-04

my, School of Economics, UNSW

k =1

24

Ch.6 Seasonality

Modelling seasonality and time trend


Seasonality with linear trend
yt = mt + st + xt ,

mt = 0 + 1t ,

yt = 1t + i Dit + xt ,

OLS : yt on t , D1t , D2t ,..., D pt .

i =1

Why is the intercept 0 gone?

because

D
j =1

jt

= 1.

Time trend & seasonality in yt = 1t + i Dit + xt


mt = + 1t ,
Check :
BF-04

st = i Dit ,

st + p = st ,

i =1
p

s
k =1

t +k

i =1
p

1
i.

p i =1

= 0.

my, School of Economics, UNSW

25

Ch.6 Seasonality

Modelling seasonality and time trend


eg. Department stores turnover: 1982.04 1999.10
mt = + 1t + 2t 2 + 3t 3 ,

st = i Dit ,
i =1

yt = 1t + 2t + 3t + i Dit + xt , OLS : yt on t , t 2 , t 3 , D1t , D2t ,..., D pt .


2

i =1

8.0

7.5

.8
Seasonality

.12

7.0

6.5

.6
.4
.2

6.0

.08

5.5

.04

.0

-.2

.00
-.04

1997M07

1998M01

1998M07

-.08
-.12

-1
82

84

86

88

Residual

BF-04

-.4
1997M01

90

92
Actual

94

96

98

82

Fitted

my, School of Economics, UNSW

84

86

88

90

Seasonality

92

94

96

98

Trend

26

Ch.6 Seasonality

Modelling seasonality and time trend


EViews

'Read departstoresTurnover05.xls in Eviews


'from 1982:04 to 2005:04. For clicks, see p25, BF-03

genr D1=@seas(1)
gets January dummy.
scalar gbar=...
handles scalars.
_ means the line
is to be continued.
smpl ... specifies
subsamples to use.

'Generate log sales, time trend & monthly dummies


genr y=log(sales)
genr tt=@trend(1982:04)
genr D1=@seas(1)
genr D2=@seas(2)
:
genr D11=@seas(11)
genr D12=@seas(12)
'Subsample for estimation
smpl 1982:04 1999:10
equation eq1.ls y D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 _
tt tt^2 tt^3
scalar gbar=(c(1)+c(2)+c(3)+c(4)+c(5)+c(6)+c(7)+c(8)+c(9) _
+c(10)+c(11)+c(12))/12
eq1.makeresids res
genr fitted=y-res
genr trnd=gbar + c(13)*tt+c(14)*tt^2+c(15)*tt^3
genr seas=fitted-trnd
plot seas trnd
smpl 1997:01 1998:12
plot seas
'Subsample for estimation
smpl 1999:11 2005:04
eq1.forecast yhat se
genr yf=yhat
genr yf_up=yhat+2*se
genr yf_lo=yhat-2*se
'Subsample for plots
smpl 1999:04 2005:04
graph fig3.plot y yf yf_up yf_lo fitted

BF-04

my, School of Economics, UNSW

27

Ch.6 Seasonality

Forecast seasonality and time trend


Forecasts are based on estimated parameters.
mt = + 1t ,

st = i Dit ,
i =1

1 p
= i.
p i =1

Point forecast: sample end T, horizon h


p

yT + h = 1 (T + h) + i Di ,T + h
i =1

Interval forecast:
95% CI [ yT + h 2 sT + h , yT + h + 2 sT + h ],
sT + h = estimated std deviation of forecast error

T+h

Note yt = mt + st + xt .
Assumption here is
xt being white noise,
which may not be true.

BF-04

my, School of Economics, UNSW

28

Ch.6 Seasonality

Forecast seasonality and time trend


eg. Department stores turnover: 1999.11 2005.4
Forecasts (lines) & Acturals (points)
8.4

8.0

7.6

7.2

6.8

6.4
1999

BF-04

2000

2001

2002

my, School of Economics, UNSW

2003

2004

29

Ch.6 Seasonality

Seasonality and smoothers


Trend can be estimated by a smoother.
yt = MA smoothed

De-trended series can then be used to estimate


seasonality, via a seasonal smoother.
y t = yt yt st + xt ,

BF-04

E ( xt ) = 0

my, School of Economics, UNSW

30

Ch.6 Seasonality

Seasonality and smoothers


Seasonal smoothers average over the same
seasonal points.

eg. monthly data, seasonal MA(3): dt = y t 12 + y t + y t +12


3

Seasonal convolution SMA(5*3):


dt 24 + dt 12 + dt + dt +12 + dt + 24
,
st =
5

y t 36 + 2 y t 24 + 3 y t 12 + 3 y t + 3 y t +12 + 2 y t + 24 + y t +36
.
st =
15

yt = yt st
Seasonal adjustment ~
BF-04

my, School of Economics, UNSW

31

Ch.6 Seasonality

Seasonality and smoothers


Census X-11 seasonal adjustment (approximately)
Apply the MA(2*12) to data estimate trend;
De-trend the data;
Apply the SMA(5*3) to the de-trended data
to estimate seasonality;
Deduct the seasonality from the original data to
obtain the seasonally-adjusted data.

Here, 42 obs at each end of the sample lost. X11


(or X12) handles sample-end issues.
BF-04

my, School of Economics, UNSW

32

Ch.6 Seasonality

Seasonality and smoothers


eg. Department stores turnover: 1982.04 2005.04
Decomposed
into
trend,
seasonality,
cycle
by smoothers.
log Retail Turnover

8.0

7.2

7.6

7.0

7.2

6.8

6.8

6.6

6.4

6.4

6.0

6.2

5.6

Trend: MA2*12

6.0

82

84

86

88

90

92

94

96

98

00

02

04

82

84

86

88

90

92

94

96

98

00

02

04

00

02

04

Seasonally-adjusted Data

Seasonal MA5*3 and Cycle

7.2

.8
CYCLE

SEAS

7.1
.6

7.0
6.9

.4

6.8
.2

6.7
6.6

.0

6.5
-.2

6.4
6.3

-.4
82

BF-04

84

86

88

90

92

94

96

98

00

02

my, School of Economics, UNSW

04

82

84

86

88

90

92

94

96

98

33

Ch.5, 6, 13.4 Trend & Seasonality

Summary
How do we choose the order of a polynomial time trend?
What is a 2-sided smoother? One-sided? EWMA?
Under what conditions a smoother removes seasonality?
What are seasonal dummies? And their characteristics?
How do we separate trend and seasonality in a regression
with time trend and seasonal dummies?
What are seasonal smoothers?
What is a seasonally-adjusted series?

BF-04

my, School of Economics, UNSW

34

You might also like