State space models

State space models
19 November 2014
Business Cycles Theory, IES FSV UK
The Plan
Introduction
Motivation
Example:
time-varying
parameter
regression
Estimation
Kalman filter
MLE
Examples in R
Local level
model
Local linear
trend model
Business Cycles Theory, IES FSV UK
General state
space models
TVP model
State space models
๏
Unobservable variables in economics
๏
Potential GDP
๏
Expectations
๏
Time-varying parameters
๏
Volatility
Business Cycles Theory, IES FSV UK
State space models: applications
๏
Estimating models
๏
๏
๏
๏
๏
๏
Disaggregating time series
(monthly GDP etc.)
๏
Factor models
ARMA, VAR
DSGE
volatility (GARCH, stochastic
volatility)
Estimating “invisible” variables
๏
coincident indicators
๏
nowcasting
๏
FAVARs
๏
Potential output, output gaps
๏
Missing data
๏
NAIRU
๏
Seasonal adjustment
Time-varying parameter models
(e.g. TVP-VAR)
Business Cycles Theory, IES FSV UK
Example: TVP (time varying parameter) regression
Measurement equation:
yt = x t
t
+ et
vt ⇠ N(0, Q)
Transition equation
t
=µ+F
t 1
+ vt
vt ⇠ N(0, Q)
Dimensions:
yt : 1x1 dependent variable, xt : 1xk exogenous variables,
time-varying parameters, F : kxk, Q : kxk, R : 1x1
If µ = 0, F = Ik : coefficients follow a random walk
Business Cycles Theory, IES FSV UK
t
: kx1
Example: time-varying CAPM betas
2
๏
US banking
sector
๏
Top panel:
betas
๏
Bottom panel:
stochastic
volatility
1.5
1
0.5
0.1
0.08
0.06
0.04
0.02
92
95
Business Cycles Theory, IES FSV UK
97
00
02
05
07
10
General Linear State Space Model
Measurement equation:
yt = H t
t
+ Azt + et
Transition equation:
t
=µ+F
t 1
+ vt
where et ⇠ i.i.d.N(0, R), vt ⇠ i.i.d.N(0, Q), E (et vs0 ) = 08t, s
yt : nx1 vector, observed variables
t : kx1 unobserved state variables
Ht : nxk matrix, links un/observed variables
zt : rx1 vector of exogenous variables
µ: kx1, vt : kx1
Business Cycles Theory, IES FSV UK
Estimation algorithm
1. Model formulation
2. Estimation
๏
Provided we know hyperparameters (variances of
shocks, system matrices), we can run the Kalman
filter to estimate state variables
๏
The Kalman filter’s output, as a byproduct, is the
likelihood
Business Cycles Theory, IES FSV UK
Estimation algorithm
Model formulation
Write the model in state
space form
2 kinds of unknowns:
- parameters
- states
Filtering state variables
Conditional on model
parameters, it is easy to
estimate state variables: Kalman filter
Estimating parameters
Maximum likelihood:
run the Kalman filter,
calculate likelihood
Need to estimate the
parameters
General Linear State Space Model
Measurement equation:
Iterate until likelihood is maximized
yt = H t
t
+ Azt + et
Transition equation:
t
=µ+F
t 1
+ vt
where et ⇠ i.i.d.N(0, R), vt ⇠ i.i.d.N(0, Q), E (et vs0 ) = 08t, s
yt : nx1 vector, observed variables
state variables
t : kx1 unobserved
Business
Cycles
Theory, IES FSV UK
Ht : nxk matrix, links un/observed variables
Set parameters
Kalman filter
Likelihood
The Kalman filter
๏
๏
Intuition:
๏
we specify (assume) a process that unobservable variables
follow
๏
if they are closely linked with observed variables, we can
guess their values
2 parts:
๏
prediction step: forecasting values of t given information at
t-1
๏
updating step: updating forecasts given the prediction error
Business Cycles Theory, IES FSV UK
The Kalman filter
Assume
0
⇠ N(
0|0 , P0|0 )
Prediction of beta
Variance of prediction
Prediction error
Variance of prediction error
Business Cycles Theory, IES FSV UK
Maximum likelihood estimation
๏
Model parameters are estimated using the
maximum likelihood
๏
Maximizes the following expression with respect to
model’s parameters:
Business Cycles Theory, IES FSV UK
Examples
๏
Writing some models in the state space form
๏
local level model
๏
local linear trend model
๏
AR(2) model
๏
TVP regression model
Business Cycles Theory, IES FSV UK
Local level model
Sometimes known as a random walk plus noise model
I
Measurement equation:
yt = µ t + ✏ t ,
I
✏t ⇠ N(0,
2
✏)
Transitionequation:
µt+1 = µt + ⌘t ,
Business Cycles Theory, IES FSV UK
⌘t ⇠ N(0,
2
⌘)
Local linear trend model
Extends the local level model by adding a slope
I
Measurement equation:
⌘t ⇠ N(0,
yt = µ t + ✏ t ,
I
2
✏)
(3)
Transition equation:
µt =
t 1
+ µt
1
+ ⌘t ,
⌘t ⇠ N(0,
2
⌘)
(4)
=
t 1
+ ⇠t
1
+ ⇠t ,
⌘t ⇠ N(0,
2
⇠)
(5)
t
Business Cycles Theory, IES FSV UK
AR(2) model
yt = ↵ +
Business Cycles Theory, IES FSV UK
1 yt 1
+
2 yt 2
+ ⌘t ,
⌘t ⇠ N(0,
2
⌘)
Business Cycles Theory, IES FSV UK
Example: potential GDP, output gap
๏
Source: CNB’s Inflation Report, IV/2014
Business Cycles Theory, IES FSV UK
Stock and Watson’s (1988)
coincident index
Business Cycles Theory, IES FSV UK
๏
Overall state of
the economy
๏
Dynamic factor
model
๏
DOC:
department of
commerce index
Business Cycles Theory, IES FSV UK
Summary
๏
Linear state-space model
๏
Intuition behind the Kalman filter
๏
Applications
๏
DLM package in R
๏
http://www.jstatsoft.org/v36/i12/paper
Business Cycles Theory, IES FSV UK