54
Local Level Model Siem Jan Koopman http://sjkoopman.net [email protected] Department of Econometrics, Vrije Universiteit Amsterdam CREATES, Aarhus University October 2016: CREATES, Aarhus University

Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model

Siem Jan Koopman

http://sjkoopman.net

[email protected]

Department of Econometrics, Vrije Universiteit AmsterdamCREATES, Aarhus University

October 2016: CREATES, Aarhus University

Page 2: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Day 1 : Local Level Model

Program :

• Introduction

• Local level model

• Statistical dynamic properties

• Filtering, smoothing and forecasting.

• Literature : J. Durbin and S.J. Koopman (2012), ”TimeSeries Analysis by State Space Methods”, Second Edition,Oxford: Oxford University Press. Chapter 2.

• Exercises and Assignments.

2 / 53

Page 3: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Time Series

A time series is a set of observations yt , each one recorded at aspecific time t.

The observations are ordered over time.We assume to have n observations, t = 1, . . . , n.

Examples of time series are:

• Number of cars sold each year

• Gross Domestic Product of a country

• Stock prices during one day

• Number of firm defaults

Our purpose is to identify and to model the serial or “dynamic”correlation structure in the time series.

Time series analysis is relevant for a wide variety of tasks includingeconomic policy, financial decision making and forecasting

3 / 53

Page 4: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

The US Economy

1960 1980 2000

-1

0

1

2

Inflation

1960 1980 2000

0

10

GDP growth

1920 1940 1960 1980 2000

-10

0

10 Industrial Prod growth

1970 1980 1990 2000 2010

5

10

15

Interest Rate 10 year TBill

4 / 53

Page 5: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

US Inflation, based on CPI, all products

1960 1980 2000

-1

0

1

2

1990 2000 2010

-1

0

1

0 10 20 30 40

0.25

0.50

0.75

1.00

0 10 20 30 40

-0.5

0.0

0.5

1.0

5 / 53

Page 6: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

US Gross Domestic Product (GDP), percentage growth

1950 1960 1970 1980 1990 2000 2010

0

10

20

0 5 10 15 20 25 30 35 40

0

1

0.0 0.5 1.0

0.2

0.4Spectral density

6 / 53

Page 7: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

US Industrial Production, levels and growth

1920 1930 1940 1950 1960 1970 1980 1990 2000 2010

25

50

75

100

1920 1930 1940 1950 1960 1970 1980 1990 2000 2010

-10

0

10

7 / 53

Page 8: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

US Industrial Production, growth

0 5 10 15 20 25 30 35 40

-0.5

0.0

0.5

1.0

Autocorrelogram for IP growth 1919-2015

0 5 10 15 20 25 30 35 40

-0.5

0.0

0.5

1.0

Autocorrelogram for IP growth 1985-2015

8 / 53

Page 9: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

US Treasury Bill Rate, 10 years

1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015

2

4

6

8

10

12

14

9 / 53

Page 10: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Sources of time series data

Data sources :

• US economics :http://research.stlouisfed.org/fred2/

• DK book data :http://www.ssfpack.com/files/DK-data.zip

• Financial data : Datastream, Wharton, Yahoo Finance

• Time Series Data Library of Rob Hyndman :http://datamarket.com/data/list/?q=provider:tsdl

10 / 53

Page 11: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Example: Nile data, yearly volumes

1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970

500

600

700

800

900

1000

1100

1200

1300

1400

11 / 53

Page 12: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Time SeriesA time series for a single entity is typical denoted by

y1, . . . , yn ⇔ yt , t = 1, . . . , n,

where t is the time index and n is time series length.The current value is yt .The first lagged value, or first lag, is yt−1.The τ th lagged value, or τ -th lag, is yt−τ for τ = 1, 2, 3, . . ..

The change between period t − 1 and period t is yt − yt−1.This is called the first difference denoted by ∆yt = yt − yt−1.

In economic time series, we often take the first difference of thelogarithm, or the log-difference, that is

∆ log yt = log yt − log yt−1 = log(yt/yt−1),

is a proxy of proportional change, see Appendix.Percentage change is then 100∆ log yt .

12 / 53

Page 13: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Time Series Models: many

• Autoregressive models, unit roots

• Autoregressive moving average models

• Long memory models, fractional integration

• ... unobserved components time series models ...

• Dynamic regression models, error correction models

• Vector autoregressive models, cointegration, vector errorcorrection models

• ... state space models ...

• Regime-switching, Markov-switching, treshold autoregression,smooth transitions models

• Generalized autoregressive conditional heteroskedasticity(GARCH) models

• Autoregressive conditional duration models and related models

• ... stochastic volatility models ...

13 / 53

Page 14: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Autoregressive model: AR(1)

The AR(1) model is given by

yt = µ+ φyt−1 + εt , εt ∼ NID(0, σ2ε),

with three parameter coefficients µ, φ and σ2ε with 0 < σε <∞.

Stationary condition: |φ| < 1.

Statistical dynamic properties:

• Mean E(yt) = µ / (1− φ); in case µ = 0, E(yt) = 0;

• Variance Var(yt) = σ2 / (1− φ2);

• Autocovariance lag 1 is Cov(yt , yt−1) = φσ2 / (1− φ2);

• and for lag τ = 2, 3, 4, . . . is Cov(yt , yt−τ ) = φτσ2 / (1− φ2);

• Autocorrelation lag τ = 1, 2, 3, . . . is Corr(yt , yt−τ ) = φτ .

14 / 53

Page 15: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Moving Average model: MA(1)

The MA(1) model is given by

yt = µ+ θεt−1 + εt , εt ∼ NID(0, σ2ε),

with three parameter coefficients µ, θ and σ2ε with 0 < σε <∞.

Invertibility condition: |θ| < 1.

Statistical dynamic properties:

• Mean E(yt) = µ; in case µ = 0, E(yt) = 0;

• Variance Var(yt) = σ2 (1 + θ2);

• Autocovariance lag 1 is Cov(yt , yt−1) = θ σ2;

• ... for lag τ = 2, 3, 4, . . . is Cov(yt , yt−τ ) = 0;

• Autocorrelation lag 1 is Corr(yt , yt−1) = θ / (1 + θ2).

15 / 53

Page 16: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Example: Nile in levels and Nile in differences

1880 1900 1920 1940 1960500

750

1000

1250

0 5 10 15 20

0.25

0.50

0.75

1.00

1880 1900 1920 1940 1960

-250

0

250

0 5 10 15 20

-0.5

0.0

0.5

1.0

16 / 53

Page 17: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Classical Decomposition

A basic model for representing a time series is the additive model

yt = µt + γt + ψt + εt , t = 1, . . . , n,

also known as the Classical Decomposition:

yt = observation,

µt = slowly changing component (trend),

γt = periodic component (seasonal),

ψt = stationary component (cycle, ARMA),

εt = irregular component (disturbance).

It is an Unobserved Components time series model, whenthe components are modelled as dynamic stochastic processes.

17 / 53

Page 18: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model

• Component is stochastic or deterministic function of time:• Deterministic, eg: yt = µ(t) + εt with εt ∼ NID(0, σ2

ε)• Stochastic, eg: Local Level model:

• Local level model :

yt = µt + εt , εt ∼ NID(0, σ2ε)

µt+1 = µt + ηt , ηt ∼ NID(0, σ2η)

• The disturbances εt , ηs are independent for all s, t;• The model is incomplete without initial specification for µ1.• The time series processes for µt and yt are nonstationary.

18 / 53

Page 19: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model

The local level model or random walk plus noise model :

yt = µt + εt , εt ∼ NID(0, σ2ε)

µt+1 = µt + ηt , ηt ∼ NID(0, σ2η)

• The level µt and irregular εt are unobserved;

• Parameters σ2ε and σ2η are unknown;

• We still need to define µ1;

• Trivial special cases:• σ2

η = 0 =⇒ yt ∼ NID(µ1, σ2ε) (IID constant level);

• σ2ε = 0 =⇒ yt+1 = yt + ηt (random walk);

• Local Level model is basic illustration of state space model.

19 / 53

Page 20: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Simulated Local Level data

0 10 20 30 40 50 60 70 80 90 100

-6

-4

-2

0

2

4

6

σε2=0.1 ση

2=1

20 / 53

Page 21: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Simulated Local Level data

0 10 20 30 40 50 60 70 80 90 100

-6

-4

-2

0

2

4

6

σε2=1 ση

2=1

21 / 53

Page 22: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Simulated Local Level data

0 10 20 30 40 50 60 70 80 90 100

-6

-4

-2

0

2

4

6

σε2=1 ση

2=0.1

22 / 53

Page 23: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Simulated Local Level data

0 10 20 30 40 50 60 70 80 90 100

-5

0

5 σε2=0.1 ση

2=1

0 10 20 30 40 50 60 70 80 90 100

-5

0

5 σε2=1 ση

2=1

0 10 20 30 40 50 60 70 80 90 100

-2

0

2 σε2=1 ση

2=0.1

23 / 53

Page 24: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Properties of Local Level model

yt = µt + εt , εt ∼ NID(0, σ2ε),

µt+1 = µt + ηt , ηt ∼ NID(0, σ2η),

• First difference is stationary:

∆yt = ∆µt + ∆εt = ηt−1 + εt − εt−1.

• Dynamic properties of ∆yt :

E(∆yt) = 0,

γ0 = E(∆yt∆yt) = σ2η + 2σ2ε ,

γ1 = E(∆yt∆yt−1) = −σ2ε ,γτ = E(∆yt∆yt−τ ) = 0 for τ ≥ 2.

24 / 53

Page 25: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Properties of Local Level model• Define q as the signal-to-noise ratio : q = σ2η / σ

• The theoretical ACF of ∆yt is

ρ1 =−σ2ε

σ2η + 2σ2ε= − 1

q + 2,

ρτ = 0, τ ≥ 2.

• It implies that−1/2 ≤ ρ1 ≤ 0

• The local level model implies that ∆yt ∼ MA(1).Hence yt ∼ is ARIMA(0, 1, 1). We have∆yt = ξt + θξt−1, ξt ∼ NID(0, σ2).

• This implied MA(1) has ACF ρ1 = θ / (1 + θ2), and hence arestricted parameter space for θ : −1 < θ < 0.

• To express θ as function of q, solve equality for ρ1’s:

θ =1

2

(√q2 + 4q − 2− q

).

25 / 53

Page 26: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level ModelThe Local Level model is given by

yt = µt + εt , µt+1 = µt + ηt , t = 1, . . . , n.

• The parameters σ2ε and σ2η are unknown and need to beestimated, typically via maximum likelihood estimation;

• MLE for this class of models is discussed in next session.• When we treat parameters σ2ε and σ2η as known, how to

”estimate” the unobserved series µ1, . . . , µn ?• This “estimation” is referred to as signal extraction.• We base this “estimation” on conditional expectations.• Signal extraction is the recursive evaluation of conditional

means and variances of the unobserved µt for t = 1, . . . , n.• It is known as the Kalman filter;• Next we provide the derivation only for the Local Level model.• In our next session we discuss the Kalman filter for the

general linear state space model.26 / 53

Page 27: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Signal extraction: conditional expectationConsider two random variable x and y that are normally distributed

x ∼ N (µx , σ2x), y ∼ N (µy , σ

2y ), Cov(x , y) = σxy .

Assume that we do not know anything about x but we havecollected an observation for y .

The conditional expectation and variance are given by

E(x |y) = µx + σxy (y − µy ) / σ2y , Var(x |y) = σ2x − σ2xy / σ2y .

Verify these results and make sure you can derive these resultsfrom basic principles. We have

x |y ∼ f (x |y) ≡ N (µx |y , σ2x |y ),

where µx |y ≡ E(x |y) and σ2x |y ≡ Var(x |y).

Notice that µx |y is a function of y but σ2x |y is not.

Notice that when σxy = 0, E(x |y) = µx and Var(x |y) = σ2x .27 / 53

Page 28: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model: signal extractionLocal Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

Assume we have collected observations for y1, . . . , yt−1 and thatthe conditional density f (µt |y1, . . . , yt−1) is normal with knownmean at and known variance pt , we have

µt |y1, . . . , yt−1 ∼ f (µt |y1, . . . , yt−1) ≡ N (at , pt).

Next we collect an observation for yt , the conditional densities ofinterest are

f (µt |y1, . . . , yt), f (µt+1|y1, . . . , yt).

These conditional densities turn out to be normal as well

f (µt |y1, . . . , yt) ≡ N (at|t , pt|t), f (µt+1|y1, . . . , yt) ≡ N (at+1, pt+1).

Can we express (at|t , pt|t) in terms of (at , pt) ? Also (at+1, pt+1) ?28 / 53

Page 29: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model: signal extractionLocal Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

Notation: Ys = {y1, . . . , ys}, for s = t − 1, s = t and s = n.

Define prediction error vt = yt − at with at = E(µt |Yt−1), withproperties such as

E(vt |Yt−1) = E(µt + εt − at |Yt−1) = at − at = 0,

Var(vt |Yt−1) = Var(µt − at + εt |Yt−1) = pt + σ2ε ,

E(vt |µt ,Yt−1) = µt − at ,

Var(vt |µt ,Yt−1) = σ2ε ,

We have E(εt) = 0 but verify that E(εt |Yt−1) = 0.When yt is observed, it becomes fixed, just as y1, . . . , yt−1.But also vt is then fixed, it is non-stochastic !!

29 / 53

Page 30: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model: signal extractionNext, we aim to obtain an expression for f (µt |y1, . . . , yt), with aneye on updating. Local Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

Consider filtered estimate f (µt |y1, . . . , yt) ≡ f (µt |vt ,Yt−1) sincevt = yt − at , where at = E(µt |Yt−1), are all fixed. We have

f (µt |vt ,Yt−1) = f (µt , vt |Yt−1)/f (vt |Yt−1)

= f (µt |Yt−1)f (vt |µt ,Yt−1)/f (vt |Yt−1),

where f ()’s are normals and f (µt |Yt) = const.× exp(− 1

2Qt

)with

Qt = (µt − at)2/pt + (vt − µt + at)

2/σ2ε − v2t /(pt + σ2ε).

After some algebra, we have

Qt =pt + σ2εpt σ2ε

(µt − at −

pt vtpt + σ2ε

)2.

30 / 53

Page 31: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model: signal extractionNext we consolidate these results for the Local Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

We are interested in the filtered signal density

f (µt |Yt) = const.× exp(− 1

2Qt

),

with

Qt =pt + σ2εpt σ2ε

(µt − at −

pt vtpt + σ2ε

)2.

It implies thatf (µt |Yt) ≡ N (at|t , pt|t),

with

at|t = at + kt vt , pt|t = kt σ2ε , kt =

ptpt + σ2ε

.

31 / 53

Page 32: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Level Model: signal extractionLocal Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

In addition, we are typically interested in the predicted signaldensity

f (µt+1|Yt) ≡ N (at+1, pt+1),

where

at+1 = E(µt+1|Yt) = E(µt + ηt |Yt) = at|t ,

pt+1 = Var(µt + ηt |Yt) = pt|t + σ2η.

We have obtained the updating equations

at+1 = at + kt vt , pt+1 = kt σ2ε + σ2η, kt =

ptpt + σ2ε

.

This is the celebrated Kalman filter for the Local Level model.32 / 53

Page 33: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Kalman filter for the Local Level Model

Local Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

The Kalman filter equations are given by

vt = yt − at , Var(vt) = pt + σ2ε ,

kt = pt / (pt + σ2ε),

at|t = at + ktvt ,

pt|t = kt σ2ε ,

at+1 = at|t ,

pt+1 = pt|t + σ2η,

for t = 1, . . . ,T with initialisation ...

a1 = 0 and p1 = σ2ε × 107.The equations are recursions, we update when new yt is observed.

33 / 53

Page 34: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Kalman filter for the Local Level Model

Local Level model :

yt = µt + εt , εt ∼ N (0, σ2ε), µt+1 = µt +ηt , ηt ∼ N (0, σ2η).

The Kalman filter equations are given by

vt = yt − at , Var(vt) = pt + σ2ε ,

kt = pt / (pt + σ2ε),

at|t = at + ktvt ,

pt|t = kt σ2ε ,

at+1 = at|t ,

pt+1 = pt|t + σ2η,

for t = 1, . . . ,T with initialisation ... a1 = 0 and p1 = σ2ε × 107.The equations are recursions, we update when new yt is observed.

33 / 53

Page 35: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Signal Extraction for Nile Data: filtered estimate of level

1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970

500

600

700

800

900

1000

1100

1200

1300

1400

34 / 53

Page 36: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Observation weights

We show next that at|t is a weighted sum of past observations :

at|t = at + ktvt = at + kt(yt − at)

= ktyt + (1− kt)at

= ktyt + (1− kt)at−1 + (1− kt)kt−1(yt−1 − at−1)

= ktyt + kt−1(1− kt)yt−1 + (1− kt)(1− kt−1)at−1...

= ktyt +t−1∑j=1

wt,jyt−j , wt,j = kt−j

j−1∏m=0

(1− kt−m).

Since 0 < kt < 1, the weights are decaying in j .A larger j implies that yt−j is more remote from t.

35 / 53

Page 37: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Signal Extraction for Nile Data: observation weights

-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 00.00

0.05

0.10

0.15

0.20

0.25

0.30

Local Level : filtered weights

-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 00.00

0.01

0.02

0.03

0.04

0.05

Global Level

36 / 53

Page 38: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Linear Trend Model

The LLT model extends the LL model with a slope:

yt = µt + εt , εt ∼ NID(0, σ2ε),

µt+1 = βt + µt + ηt , ηt ∼ NID(0, σ2η),

βt+1 = βt + ξt , ξt ∼ NID(0, σ2ξ ).

• All disturbances are independent at all lags and leads;

• Initial distributions β1, µ1 need to specified;

• If σ2ξ = 0 the trend is a random walk with constant drift β1;(For β1 = 0 the model reduces to a LL model.)

• If additionally σ2η = 0 the trend is a straight line with slope β1and intercept µ1;

• If σ2ξ > 0 but σ2η = 0, the trend is a smooth curve, or anIntegrated Random Walk;

37 / 53

Page 39: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Trend and Slope in LLT Model

µ

0 10 20 30 40 50 60 70 80 90 100

-2.5

0.0

2.5

5.0µ

β

0 10 20 30 40 50 60 70 80 90 100

-0.25

0.00

0.25

0.50

0.75 β

38 / 53

Page 40: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Trend and Slope in Integrated Random Walk Model

µ

0 10 20 30 40 50 60 70 80 90 100

0

5

10 µ

β

0 10 20 30 40 50 60 70 80 90 100

-0.25

0.00

0.25

0.50

0.75 β

39 / 53

Page 41: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Local Linear Trend Model

• The LLT model can be represented as the ARIMA(0,2,2)model, please verify this;

• The estimation methodology is the same as for the LL model;

• It requires the general state space methods;

• LLT provides a model for Holt-Winters forecasting;

• The smooth trend model is with σ2ζ = 0;

• Smoother trend models can be obtained by higher-orderRandom Walk processes:

∆dµt = ηt

and with yt = µt + εt .

40 / 53

Page 42: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Seasonal Effects

We have seen specifications for µt in the basic model

yt = µt + γt + εt .

Now we will consider the seasonal term γt . Let s denote thenumber of ‘seasons’ in the data:

• s = 12 for monthly data,

• s = 4 for quarterly data,

• s = 7 for daily data when modelling a weekly pattern.

41 / 53

Page 43: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Dummy Seasonal

The simplest way to model seasonal effects is by using dummyvariables. The effect summed over the seasons should equal zero:

γt+1 = −s−1∑j=1

γt+1−j .

To allow the pattern to change over time, we introduce a newdisturbance term:

γt+1 = −s−1∑j=1

γt+1−j + ωt , ωt ∼ NID(0, σ2ω).

The expectation of the sum of the seasonal effects is zero.

42 / 53

Page 44: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Trigonometric Seasonal

Defining γjt as the effect of season j at time t, an alternativespecification for the seasonal pattern is

γt =

[s/2]∑j=1

γjt ,

γj ,t+1 = γjt cosλj + γ∗jt sinλj + ωjt ,

γ∗j ,t+1 = −γjt sinλj + γ∗jt cosλj + ω∗jt ,

ωjt , ω∗jt ∼ NID(0, σ2ω), λj = 2πj/s.

• Without the disturbance, the trigonometric specification isidentical to the deterministic dummy specification.

• The autocorrelation in the trigonometric specification laststhrough more lags: changes occur in a smoother way;

43 / 53

Page 45: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Seatbelt Law

70 75 80 85

7.0

7.1

7.2

7.3

7.4

7.5

7.6

7.7

7.8

7.9

44 / 53

Page 46: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Seatbelt Law: decomposition

drivers Level+Reg

70 75 80 85

7.25

7.75

drivers Level+Reg

Seasonal

70 75 80 85

0.0

0.2

Seasonal

Irregular

70 75 80 85

-0.1

0.0

0.1Irregular

45 / 53

Page 47: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Seatbelt Law: forecasting

70 75 80 85

7.0

7.1

7.2

7.3

7.4

7.5

7.6

7.7

7.8

7.9

46 / 53

Page 48: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Textbooks

• A.C.Harvey (1989). Forecasting, Structural Time SeriesModels and the Kalman Filter. Cambridge University Press

• G.Kitagawa & W.Gersch (1996). Smoothness Priors Analysisof Time Series. Springer-Verlag

• J.Harrison & M.West (1997). Bayesian Forecasting andDynamic Models. Springer-Verlag

• J.Durbin & S.J.Koopman (2012). Time Series Analysis byState Space Methods, Second Edition. Oxford UniversityPress

• J.J.F.Commandeur & S.J.Koopman (2007). An Introductionto State Space Time Series Analysis. Oxford University Press

47 / 53

Page 49: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Exercises

1 Consider the Local Level model (see slides, see DK chapter 2).

• Reduced form is ARIMA(0,1,1) process. Derive therelationship between signal-to-noise ratio q of LL model andthe θ coefficient of the ARIMA model;

• Derive the reduced form in the case ηt =√qεt and notice the

difference in the general case.• Give the elements of the mean vector and variance matrix of

y = (y1, . . . , yn)′ when yt is generated by a LL model fort = 1, . . . , n.

48 / 53

Page 50: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Exercises

2 Consider the stationary time series model

yt = µt + εt , εt ∼ N (0, σ2ε),

µt+1 = φµt + ηt , ηt ∼ N (0, σ2η),

with autoregressive coefficient |φ| < 1 and variances σ2ε > 0and σ2η > 0. The disturbances εt and ηs are independent ofeach other for all t, s = 1, . . . , n.

• Explore the dynamic properties of yt (mean, variance,autocovariances, autocorrelations).

• Assume that parameters φ, σ2ε and σ2

η are given. Develop theKalman filter recursions for this model.

• Propose initial values for mean and variance of theautoregressive component µt , that is, µ1 ∼ N (a1, p1) andpropose values for a1 and p1.

49 / 53

Page 51: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Assignment

3 Consider the Local Level model (see slides, see DK chapter 2).

• Implement the Kalman filter for the Local Level model in acomputer program.

• Apply the Kalman filter to the Nile data(Nile data is part of DK book data, see page 11 of these slides)

• Replicate the Figure on page 34 of these slides.

50 / 53

Page 52: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Appendix – Taylor seriesThe Taylor expansion for function f (x) around some value x∗ is

f (x) = f (x = x∗)+f ′(x = x∗)[x−x∗]+1

2f ”(x = x∗)[x−x∗]2+. . . ,

where

f ′(x) =∂f (x)

∂x, f ”(x) =

∂2f (x)

∂x∂x,

and g(x = x∗) means that we evaluate function g(x) at x = x∗.

Example: consider f (x) = log(1 + x) with f ′(x) = (1 + x)−1 andf ”(x) = −(1 + x)−2; the expansion of f (x) around x∗ = 0 is

log(1 + x) = 0 + 1 · (x − 0) +1

2(−1) · (x − 0)2 + . . . = x − 1

2x2 + . . .

Notice that f (x = 0) = 0, f ′(x = 0) = 1 and f ”(x = 0) = −1. Forsmall enough x (when x is close to x∗ = 0), we have

log(1 + x) ≈ x .

Check: log(1.01) = .00995 ≈ 0.01 and log(1.1) = 0.0953 ≈ 0.1.51 / 53

Page 53: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Appendix – Percentage growthObservation at time t is yt and observation at time t − 1 is yt−1.

We define rate rt as the proportional change of yt wrt yt−1, that is

rt =yt − yt−1

yt−1⇒ yt − yt−1 = yt−1 · rt ⇒ yt = yt−1 · (1 + rt).

We notice that rt can be positive and negative !

When we take logs of yt = yt−1 · (1 + rt), we obtain

log yt = log yt−1 + log(1 + rt)⇒ log yt − log yt−1 = log(1 + rt)⇒

∆ log yt = log(1 + rt).

Since log(1 + rt) ≈ rt , see previous slide, when rt is small, we have

rt ≈ ∆ log yt .

The percentage growth is defined as 100× rt ≈ 100 ·∆ log yt .52 / 53

Page 54: Local Level Model - Aarhus Universitet · Day 1 : Local Level Model Program : Introduction Local level model Statistical dynamic properties Filtering, smoothing and forecasting. Literature

Appendix – Lag operators and polynomials

• Lag operator Lyt = yt−1, Lτyt = yt−τ , for τ = 1, 2, 3, . . .

• Difference operator ∆yt = (1− L)yt = yt − yt−1

• Autoregressive polynomial φ(L)yt = (1− φL)yt = yt − φyt−1• Other polynomial θ(L)εt = (1 + θL)εt = εt + θεt−1

• Second difference∆2yt = ∆(∆yt) = ∆(yt − yt−1) = yt − 2yt−1 + yt−2

• Seasonal difference ∆s yt = yt − yt−s for typicals = 2, 4, 7, 12, 52

• Seasonal sum operatorS(L)yt = (1 +L+L2 + . . .+Ls−1)yt = yt +yt−1 + . . .+yt−s+1

• Show that ∆S(L) = ∆s .

53 / 53