Sie sind auf Seite 1von 67

Kalman Filter and Maximum Likelihood

Estimation of Linearized DSGE Models


Dr. Tai-kuang Ho
+
+
Associate Professor. Department of Quantitative Finance, National Tsing Hua University, No.
1 State space form and the Kalman lter
1.1 State space form
a
t
: the state variables
:
t
: the observable variables
Transition equation
101, Section 2, Kuang-Fu Road, Hsinchu, Taiwan 30013, Tel: +886-3-571-5131, ext. 62136, Fax:
+886-3-562-1823, E-mail: tkho@mx.nthu.edu.tw.
a
t+1
= 1a
t
+G.
t+1
.
t+1
A (0, Q)
Measurement equation
:
t
= 1
t
t
a
t
+u
t
u
t
A (0, 1)
We want to write the likelihood function of :
t
.
1.2 Some useful properties of normal distribution
Assume that
Z[& =
_
A[&
Y [&
_
A
__
a
j
_
,
_

aa

aj

ja

jj
__
Then if follows
A[Y, & A
_
a +
aj

1
jj
(Y j) ,
aa

aj

1
jj

ja
_
1.3 Kalman lter
:
t1
= :
1
, :
0
, . . . , :
t1

a
t[t1
: the random variables a
t
conditional on :
t1
, the history of the observ-
able variables
a
t[t1
= 1
_
a
t
[:
t1
_

t[t1
= 1
_
_
a
t
a
t[t1
_ _
a
t
a
t[t1
_
t
[:
t1
_
:
t[t1
= 1
_
:
t
[:
t1
_

t[t1
= 1
_
_
:
t
:
t[t1
_ _
:
t
:
t[t1
_
t
[:
t1
_
:
t[t1
= 1
_
:
t
[:
t1
_
= 1
_
1
t
t
a
t
+u
t
[:
t1
_
= 1
t
t
a
t[t1

t[t1
= 1
_
_
:
t
:
t[t1
_ _
:
t
:
t[t1
_
t
[:
t1
_
= 1
_
_
1
t
t
_
a
t
a
t[t1
_
+u
t
_ _
1
t
t
_
a
t
a
t[t1
_
+u
t
_
t
[:
t1
_
= 1
_
1
t
t
_
a
t
a
t[t1
_ _
a
t
a
t[t1
_
t
1
t
[:
t1
_
+1
_
u
t
u
t
t
[:
t1
_
= 1
t
t

t[t1
1
t
+1
1
_
_
:
t
:
t[t1
_ _
a
t
a
t[t1
_
t
[:
t1
_
= 1
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
0[0
,
0[0
_

_
a
1[0
,
1[0
, :
1[0
,
1[0
_
1.5 Kalman lter: the algorithm
a
t[t1

t[t1
:
t
a
t[t
= a
t[t1
+
t[t1
1
t
_
1
t
t

t[t1
1
t
+1
_
1
_
:
t
1
t
t
a
t[t1
_

t[t
=
t[t1

t[t1
1
t
_
1
t
t

t[t1
1
t
+1
_
1
1
t
t

t[t1
a
t+1[t
= 1a
t[t

t+1[t
= 1
t[t
1
t
+GQG
t
:
t+1[t
= 1
t
t+1
a
t+1[t

t+1[t
= 1
t
t+1

t+1[t
1
t+1
+1
We have moved as follows:
_
a
t[t1
,
t[t1
_
:
t

_
a
t[t
,
t[t
_

_
a
t+1[t
,
t+1[t
, :
t+1[t
,
t+1[t
_
1.6 The likelihood function
Prediction error decomposition of likelihood:
log
_
:
T
[1, G, 1
t
, Q, 1
_
=
T

t=1
log
_
:
t
[:
t1
, 1, G, 1
t
, Q, 1
_
=
T

t=1
_
.
2
log 2 +
1
2
log

t[t1

+
1
2
u
t
t

1
t[t1
u
t
_
:
t
[:
t1
A
_
:
t[t1
,
t[t1
_
. = dim(:
t
)
u
t
= :
t
:
t[t1
= :
t
1
t
t
a
t[t1

t[t1
= 1
t
t

t[t1
1
t
+1
1.7 Initial conditions for the Kalman lter
All of the eigenvalues of 1 are inside the unit circle.
GQG
t
and 1 are p.s.d. symmetric matrices.
1 = lim
to
1
t
We use the unconditional mean of a
t
to initialize the Kalman lter.
In other words, a
1[0
= 0.
We also use the unconditional variance of a
t
to initialize the Kalman lter.
In other words, we are setting cc
_

1[0
_
= (1 1 1)
1
cc
_
GQG
t
_
.
a
t+1
= 1a
t
+G.
t+1
= 11
t
+GQG
t
cc () = cc
_
11
t
_
+cc
_
GQG
t
_
cc () = (1 1) cc () +cc
_
GQG
t
_
cc () = (1 1 1)
1
cc
_
GQG
t
_
An alternative is to choose the stationary value of the variance as the initial value
for the variance.

t[t
=
t[t1

t[t1
1
t
_
1
t
t

t[t1
1
t
+1
_
1
1
t
t

t[t1

t+1[t
= 1
t[t
1
t
+GQG
t

t+1[t
= 1
_

t[t1

t[t1
1
t
_
1
t
t

t[t1
1
t
+1
_
1
1
t
t

t[t1
_
1
t
+GQG
t

t+1[t

= 1
_
1
_
1
t
1 +1
_
1
1
t

_
1
t
+GQG
t
is the solution to the above algebraic Ricatti equation.
2 DSGE estimation
2.1 Express solution of DSGE models in state-space form
We use the modied Paul Kleins code (solabHO.m) to solve the linearized sys-
tem.
Kleins code treats exogenous shocks as part of the state variables, and solves

0

_
I
t+1
&
t+1
_
= 1
0

_
I
t
&
t
_
I
t
: state variables plus exogenous shocks
&
t
: control variables
Kleins code gives the results
I
t+1
= j I
t
(1)
&
t
= ) I
t
(2)
Assume that exogenous shocks follow:
Z
t+1
= Z
t
+ ~ j.
t+1
.
t+1
A (0, \
1
)
You can follow Schmitt-Groh and Uribe (2004, henceforth SGU) and assume
that exogenous shocks follow:
Z
t+1
= Z
t
+ ~ jo.
t+1
.
t+1
A (0, 1)
We follow Ireland (2004) to transform the solution of DSGE models into a state-
space form.
First, the complete form of equation (1) is expressed as: (SGU, 2004, page 759):
I
t+1
= j I
t
+
_
0
~ j
_
.
t+1
= j
1 =
_
0
~ j
_
I
t+1
= I
t
+1 .
t+1
(3)
We use empirical and observable variables o
t
to estimate the DSGE models.
Second, equation (2) is related to observable variables o
t
by:
o
t
= C I
t
If the observables o
t
are contained in I
t
, namely, they belong to the state vari-
ables of the models, then C is simple a selection matrix, such as:
C =
_
1 0 0 0
0 0 0 1
_
In this example, C matrix selects the rst and last variables of vector I
t
.
In contrast, if the observables o
t
are not contained in I
t
, namely, they belong
to the control variables of the models, then C is ) pre-multiplied by a selection
matrix (or is formed by simple taking out the corresponding rows of )), for
example
C =
_
0 1 0 0 0
0 0 1 0 0
_
)
C =
_
)
2,:
)
3,:
_
In this example, C matrix takes out the second and third rows of matrix ).
In other words, the observables for estimation are the second and third control
variables.
2.2 Stochastic singularity
The number of exogenous shocks must be as least as many as the number of
observable variables.
Otherwise, there is the problem of stochastic singularity and estimation is im-
possible.
Ingram, Kocherlakota, and Savin (1994) rst notice the issue of stochastic sin-
gularity in the estimation of the real business cycle model with single technology
shock.
Ruge-Murcia (2007) provides a very good explanation to the issue of stochastic
singularity.
Here I draw on Ruge-Murcia (2007).
Why stochastic singularity makes maximum likelihood estimation impossible?
Stochastic singularity arises because DSGE models use a small number of struc-
tural shocks to generate predictions about a large number of observable variables.
Therefore, the models predict that certain linear combinations of the observable
variables should hold without noises, namely, be deterministic.
Take Hansens real business cycle with indivisible labor as an example.
The model has only one technology shock.
Observable variables: (j
t
, a
t
, c
t
)
State variables: (I
t
)
Exogenous structural shocks: (:
t
)
The solution of the endogenous observable variables is expressed as:
_

_
j
t
a
t
c
t
_

_
..
c
t
=
_

jI

j:

aI

a:

cI

c:
_

_
..
1
_
I
t
:
t
_
..
a
t
Multiply out the decision rule:
__
j
t
=
jI
I
t
+
j:
:
t
a
t
=
aI
I
t
+
a:
:
t
_
(A)
c
t
=
cI
I
t
+
c:
:
t
(B)
Use (A) to solve for (I
t
, :
t
), and then substitute into (B) to obtain:
_

jI

c:

j:

cI
_
a
t
+ (
a:

cI

aI

c:
) j
t

_

a:

jI

j:

aI
_
c
t
= 0
There exists a linear combination of observable variables that hold without noise.
Under the models, the variance-covariance matrix of (j
t
, a
t
, c
t
) is singular for
any sample size and parameter values.
a
t
= (I
t
, :
t
)
c
t
= (j
t
, a
t
, c
t
)
c
t1
= c
1
, c
0
, . . . , c
t1


t[t1
= 1
_
_
a
t
a
t[t1
_ _
a
t
a
t[t1
_
t
[c
t1
_

t[t1
= 1
_
_
c
t
c
t[t1
_ _
c
t
c
t[t1
_
t
[c
t1
_
c
t
= 1a
t
c
t
c
t[t1
= 1
_
a
t
a
t[t1
_

t[t1
= 1
t[t1
1
t
We can follow the same procedure to show that elements of
_
c
t
c
t[t1
_
are
not linear independent, since they are all proportional to the only technology
shock.
Therefore, the matrix
t[t1
= 1
_
_
c
t
c
t[t1
_ _
c
t
c
t[t1
_
t
[c
t1
_
is sin-
gular.
The inverse of
t[t1
is not well dened and therefore likelihood cannot be
evaluated.
2.3 Adding measurement errors
To avoid the problem of stochastic singularity, we add measurement errors in the
above equation:
o
t
= C I
t
+u
t
(4)
u
t+1
= 1 u
t
+
t+1
(5)

t+1
A (0, \
2
)
1
_
.
t+1

t
t+1
_
= 0
To address the issue of stochastic singularity, one can also estimate the model
using at most as many observable variables as structural shocks, or to extend
the model to permit additional structural shocks.
While adding measurement errors preserves the original economic model, adding
structural errors does not.
Please refer to Ruge-Murcia (2007) and Tovar (2008) for further discussion.
There are 3 ways to specify the measurement errors 1 and \
2
.
McGrattan et al. (1997), "An equilibrium model of the business cycle with
household production and scal policy," International Economic Review: Add as
many measurement errors as the number of observable variables.
The matrices 1 and \
2
are restricted to be diagonal.
For example,
1 =
_

_
j
1
0 0
0 j
2
0
0 0 j
3
_

_
\
2
=
_

_
o
1
0 0
0 o
2
0
0 0 o
3
_

_
Canova (2007): Add measurement errors until the number of measurement errors
plus the exogenous shocks are just equal to the number of observable variables.
Matrix 1 is assumed to be a zero matrix.
For example,
1 =
_

_
0 0 0
0 0 0
0 0 0
_

_
\
2
=
_

_
o
1
0 0
0 o
2
0
0 0 0
_

_
Ireland (2004): like McGrattan et al. (1997), but relax the restriction that
matrices 1 and \
2
are diagonal.
The eigenvalues of the matrix 1 are constrained to lie inside the unit circle, and
the covariance matrix \
2
is constrained to the positive denite.
For example,
1 =
_

_
j
1
j
12
j
13
j
21
j
2
j
23
j
31
j
32
j
3
_

_
\
2
=
_

_
o
1
o
12
o
13
o
12
o
2
o
23
o
13
o
23
o
3
_

_
Here we follow McGrattan et al. (1997).
Once this is done, we can proceed with the transformation, and employ the
Kalman lter, and use the prediction error decomposition of likelihood to com-
pute the likelihood value.
2.4 Use Kalman lter to compute likelihood function
We dene an augmented state vector:
a
t
=
_
I
t
u
t
_
j
t+1
=
_
1 .
t+1

t+1
_
Equations (3), (4), and (5) can be rearranged as:
a
t+1
= 1a
t
+j
t+1
(6)
o
t
= Ga
t
(7)
1 =
_
0
aIao
0
aoaI
1
_
G =
_
C 1
aoao
_
j
t+1
A (0, Q)
Q = 1
_
j
t+1
j
t
t+1
_
=
_
1\
1
1
t
0
aIao
0
aoaI
\
2
_
aI is the dimension of I
t
, namely, the number of state variables plus exogenous
shocks in the DSGE models.
ao is the dimension of o
t
, namely, the number of observable variables used in
the estimation.
Equations (6) and (7) constitute the state space form we employ in computing
the likelihood function.
The sequence of computation is as follows (we use the unconditional mean and
variance of a
t
to initialize the Kalman lter):
a
1[0
= 0
(aI+ao)1
cc
_

1[0
_
=
_
1
(aI+ao)
2
(aI+ao)
2
(1 1)
_
1
cc (Q)
_
a
t[t1
,
t[t1
_
o
t[t1
= 1
_
o
t
[o
t1
_
= G a
t[t1
, o
t1
= o
1
, o
0
, . . . , o
t1

&
t
= o
t
o
t[t1
= o
t
G a
t[t1

t[t1
=
_
1
_
o
t
o
t[t1
_ _
o
t
o
t[t1
_
t
[o
t1
_
= G
t[t1
G
t
1
t[t1
= 1
t[t1
G
t

1
t[t1
a
t+1[t
= 1 a
t[t1
+1
t[t1
&
t

t+1[t
= Q+1
t[t1
1
t
1
t[t1
G
t[t1
1
t
_
a
t+1[t
,
t+1[t
_

log =
T

t=1
_
ao
2
log 2 +
1
2
log

t[t1

+
1
2
&
t
t

1
t[t1
&
t
_
Peter Ireland provides a very useful technical note to his 2004 paper (Ireland,
2003).
I strongly recommend you to read it.
The technical note of Ireland (2003) also explains how to compute impulse re-
sponses, variance decomposition, forecasting and to recover exogenous shocks.
I use the transformation and formulation described here in the estimation of
Monacelli (2005)s small open economy model.
2.5 Extension
Now instead of adding as many measurement errors as the number of observ-
able variables, I will only add the number of measurement errors until the sum
of number of exogenous shocks and measurement errors just are equal to the
number of observables.
The reason for doing so is that for a large-scale DSGE model, it is necessary to
be sparse on parameters, otherwise convergence of the parameters estimation is
a problem.
I follow the notation of Ireland (2003).
c
t+1
= c
t
+1.
t+1
o
t
= Cc
t
+1 u
t
1
ao(aoa:)
1 is a selection matrix.
We assign measurement errors to the variables that are most likely to suer from
this measurement problem.
u
t+1
= 1u
t
+
t+1
1
_
.
t+1
.
t
t+1
_
= \
1
1
_

t+1

t
t+1
_
= \
2
1
_
.
t+1

t
t+1
_
= 0
a
t
=
_
c
t
u
t
_
j
t+1
=
_
1.
t+1

t+1
_
a
t+1
= 1a
t
+j
t+1
o
t
= Ga
t
1 =
_
0
aI(aoa:)
0
(aoa:)aI
1
_
G =
_
C 1
_
j
t+1
A (0, Q)
Q = 1
_
j
t+1
j
t
t+1
_
=
_
1\
1
1
t
0
aI(aoa:)
0
(aoa:)aI
\
2
_
2.6 Andersons transformation
Hansen, Lars Peter, Ellen R. McGrattan, and Thomas J. Sargent, "Mechanics
of forming and estimating dynamic linear economies," Federal Reserve Bank of
Minneapolis, Research Department Sta Report 182, September 1994.
Anderson, Evan W., Ellen R. McGrattan, Lars Peter Hansen, and Thomas J. Sar-
gent (1996), "Mechanics of forming and estimating dynamic linear economies,"
in H.M. Amman, D.A. Kendrick, and J. Rust (eds.), Handbook of Computational
Economics, Chapter 4, pp. 171-252, 1996.
This is correct only when the vector white noise that drive the system is of the
same dimension as that of vector of observable.
A system (a
t
, :
t
) of the form:
a
t+1
=
c
a
t
+C.
t+1
(8)
:
t
= Ga
t
+u
t
(9)
u
t
= 1u
t1
+j
t
1
_
.
t
.
t
t
_
= 1
1
_
j
t
j
t
t
_
= 1
1
_
.
t+1
j
t
c
_
= 0, Vc, t
Equation (8) is the transition equation.
Equation (9) is the measurement equation.
j
t
: a martingale dierence sequence
.
t+1
is a martingale dierence sequence with 1
_
.
t
.
t
t
_
= 1.
1 : a matrix whose eigenvalues are bounded in modulus by unity
u
t
: a serially correlated measurement error process
redene
:
t
= :
t+1
1:
t

G = G
c
1G
state space system (a
t
, :
t
)
a
t+1
=
c
a
t
+C.
t+1
:
t
=

Ga
t
+GC.
t+1
+j
t+1
The state noise remains C.
t+1
The new measurement noise is GC.
t+1
+j
t+1
1
t
= 1
t[t1
: the Kalman gain

t
=
t[t1
: the state covariance matrix
It follows that
1
t
=
_
CC
t
G
t
+
c

t

G
t
_

1
t

t
=

G
t

G
t
+1 +GCC
t
G
t

t+1
=
0

t
0
+CC
t

_
CC
t
G
t
+
c

t

G
t
_

1
t
_

G
t

t
c
+GCC
t
_
=
0

t
0
+CC
t
1
t
_

G
t

t
c
+GCC
t
_
The state space system can be expressed in an innovation representation:
&
t
= :
t


Ga
t[t1
a
t+1[t
=
c
a
t[t1
+1
t
&
t
I use this transformation and formulation in the estimation of Chari, Kehoe and
McGrattan (2007)s prototype model for business cycle accounting.
Christensen, Hurn, and Lindsay (2008) provide useful tips for numerical opti-
mization.
References
[1] Canova, Fabio (2007), Methods for Applied Macroeconomic Research, Chapter
6: Likelihood Methods.
[2] Chari, V. V., Patrick J. Kehoe, and Ellen R. McGrattan (2007), "Business cycle
accounting," Econometrica, 75 (3), pp. 781-836.
[3] Christensen, T. M., A. S. Hurn, and K. A. Lindsay (2008), "The Devil is in the
Detail: Hints for Practical Optimization"
[4] Ingram, Beth Fisher, Narayana R. Kocherlakota, and N. E. Savin (1994), "Ex-
plaining business cycles: a multiple-shock approach," Journal of Monetary Eco-
nomics, 34, pp. 415-428.
[5] Ireland, Peter N. (2004), "A method for taking models to the data," Journal of
Economic Dynamics and Control, 28, pp. 1205-1226.
[6] Ireland, Peter N. (2003), Technical Note on "A method for taking models to the
data," available from Peter Irelands website.
[7] McGrattan, Ellen, Richard Rogerson, and Randall Wright (1995), "An equilib-
rium model of the business cycle with household production and scal policy,"
Federal Reserve Bank of Minneapolis Research Department Sta Report 191.
[8] McGrattan, Ellen, Richard Rogerson, and Randall Wright (1997), "An equilib-
rium model of the business cycle with household production and scal policy,"
International Economic Review, 38 (2), pp. 267-90.
[9] Ruge-Murcia, Francisco J. (2007), "Methods to estimate dynamic stochastic
general equilibrium models," Journal of Economic Dynamics and Control, 31,
pp. 2599-2636.
[10] Tovar, Camilo E. (2008), "DSGE models and central banks," BIS Working Pa-
pers No. 258.

Das könnte Ihnen auch gefallen