Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

State Space Models and the Kalman Filter

Eric Zivot April 9, 2006

State Space Models

A state space model for an N dimensional time series yt consists of a measurement equation relating the observed data to an m dimensional state vector t , and a Markovian transition equation that describes the evolution of the state vector over time. The measurement equation has the form yt = Zt t + dt + t , t = 1, . . . , T where Zt is an N m matrix, dt is an N 1 vector and t is an N 1 error vector such that t iid N (0, Ht ) The transition equation for the state vector t is the rst order Markov process t = Tt t1 + ct + Rt t t = 1, . . . , T where Tt is an m m transition matrix, ct is an m 1 vector, Rt is a m g matrix, and t is a g 1 error vector satisfying t iid N (0, Qt ) For most applications, it is assumed that the measurement equation errors t are independent of the transition equation errors E [t 0s ] = 0 for all s, t = 1, . . . , T However, this assumption is not required. The state space representation is completed by specifying the behavior of the initial state E [t a00 ] 0 N (a0 , P0 ) = 0, E [ t a00 ] = 0 for t = 1, . . . , T

The matrices Zt , dt , Ht , Tt , ct , Rt and Qt are called the system matrices, and contain non-random elements. If these matrices do not depend deterministically on 1

t the state space system is called time invariant. Note: If yt is covariance stationary, then the state space system will be time invariant. If the state space model is covariance stationary, then the state vector t is covariance stationary. The unconditional mean of t , a0 , may be determined using E [t ] = TE [t1 ] + c = TE [t ] + c Solving for E [t ], assuming T is invertible, gives a0 = E [t ] = (Im T)1 c Similarly, var(0 ) may be determined analytically using P0 = var(t ) = Tvar(t )T0 + Rvar( t )R0 = TP0 T0 + RQR0 Then, using vec(ABC) = C0 Avec(B), where vec is the column stacking operator, vec(P0 ) = vec(TP0 T0 ) + vec(RQR0 ) = (T T)vec(P0 ) + vec(RQR0 ) which implies that vec(P0 ) = (Im2 T T)1 vec(RQR0 ) Here vec(P0 ) is an m2 1 column vector. It can be easily reshaped to form the m m matrix P0 . Example 1 AR(2) model Consider the AR(2) model yt = + 1 yt1 + 2 yt2 + t t iid N (0, 2 ) One way to represent the AR(2) in state space form is as follows. Dene t = (yt , yt1 )0 so that the transition equation for t becomes 1 yt1 1 2 yt t + = + 0 0 yt1 1 0 yt2 The transition equation system matrices are 1 2 1 , Q = 2 ,c = T= ,R = 0 0 1 0 2

The measurement equation is yt = (1, 0)t which implies that Zt = (1, 0), dt = 0, t = 0, Ht = 0 The distribution of the initial state vector is 0 N (a0 , P0 ) Since t = (yt , yt1 )0 is stationary a0 = E [t ] = (I2 T)1 c 1 1 1 2 = 0 1 1 /(1 1 2 ) = /(1 1 2 ) The variance of the initial state vector satises vec(P0 ) = (I4 T T)1 vec(RQR0 ) Here, simple algebra gives I4 T T = 2 1 2 1 2 1 2 2 2 1 1 2 0 1 2 1 0 1 0 0 1 2 0 0 0 2 0 0 0

and so

vec(RQR0 ) =

Example 2 AR(2) model again

1 2 1 2 2 1 2 1 2 2 1 1 2 0 vec(P0 ) = 1 2 1 0 1 0 0 1

Another state space representation of the AR(2) is yt = + ct ct = 1 ct1 + 2 ct2 + t 3

The state vector is t = (ct , ct1 )0 , which is unobservable, and the transition equation is ct1 1 2 1 ct t = + 0 ct1 1 0 ct2 This representation has measurement equation matrices Zt = (1, 0), dt = , t = 0, Ht = 0 = /(1 1 2 ) The initial state vector has mean zero, and the initial covariance matrix is the same as that derived above. Example 3 AR(2) model yet again Yet another state space representation of the AR(2) model is yt = ( 1 0 )t yt1 1 1 1 yt = + + t t = 2 0 2 yt1 2 yt2 0 0 Example 4 MA(1) model The MA(1) model yt = + t + t1 can be put in state space form in a number of ways. Dene t = (yt , t ) and write yt = ( 1 0 )t + 0 1 1 t1 + t t = 0 0 The rst element of t is then t1 + t which is indeed yt . Example 5 ARMA(1,1) model The ARMA(1,1) model yt = + (yt1 ) + t + t1 can be put in a state space form similar to the state space form for the MA(1). Dene t = (yt , t ) and write yt = ( 1 0 )t + 1 1 t1 + t t = 0 0 The rst element of t is then (yt1 ) + t1 + t which is indeed yt . 4

Example 6 ARMA(p,q) model The general ARMA(p, q ) model yt = yt1 + p ytp + t + 1 t1 + + q tq may be put in state space form in the following way. Let m = max(p, q + 1) and re-write the ARMA(p,q) model as yt = yt1 + p ytm + t + 1 t1 + + m1 tm+1 where some of the AR or MA coecients will be zero unless p = q + 1. Dene yt yt1 + + ytm+1 + 1 + + m1 p t tm+2 2 t = . . . m yt1 + m t and set yt = ( 1 00m1 )t 1 1 0 0 1 2 . . . . t = . . . . . m1 0 0 m 0 0

1 0 0 1 . ... . . t1 + . . . m2 1 0 m1

1.1

The Kalman Filter

The Kalman lter is a set of recursion equations for determining the optimal estimates of the state vector t given information available at time t, It . The lter consists of two sets of equations: 1. Prediction equations 2. Updating equations To describe the lter, let at = E [t |It ] = optimal estimator of t based on It Pt = E [(t at )(t at )0 |It ] = MSE matrix of at

1.1.1

Prediction Equations

Given at1 and Pt1 at time t 1, the optimal predictor of t and its associated MSE matrix are at|t1 = E [t |It1 ] = Tt at1 + ct Pt|t1 = E [(t at1 )(t at1 )0 |It1 ] = Tt Pt1 T0t1 + Rt Qt R0t The corresponding optimal predictor of yt give information at t 1 is yt|t1 = Zt at|t1 + dt The prediction error and its MSE matrix are vt = yt yt|t1 = yt Zt at|t1 dt = Zt (t at|t1 ) + t 0 E [vt vt ] = Ft = Zt Pt|t1 Z0t + Ht These are the components that are required to form the prediction error decomposition of the log-likelihood function. 1.1.2 Updating Equations

When new observations yt become available, the optimal predictor at|t1 and its MSE matrix are updated using
1 at = at|t1 + Pt|t1 Z0t F t (yt Zt at|t1 dt ) 1 = at|t1 + Pt|t1 Z0t F t vt 1 Pt = Pt|t1 Pt|t1 Zt F t Zt Pt|t1

The value at is referred to as the ltered estimate of t and Pt is the MSE matrix of this estimate. It is the optimal estimate of t given information available at time t.

1.2

Prediction Error Decomposition

Let denote the parameters of the state space model. These parameters are embedded in the system matrices. For the state space model with a xed value of , the Kalman Filter produces the prediction errors, vt (), and the prediction error variances, Ft (), from the prediction equations. The prediction error decomposition of the log-likelihood function follows immediately: NT 1X 0 1X 1 ln L(|y) = ln |Ft ()| vt ( )F ln(2 ) t ( )vt ( ) 2 2 t=1 2 t=1
T T

1.3

Derivation of the Kalman Filter

The derivation of the Kalman lter equations relies on the following result: Result 1: Suppose x xx xy x N , y y yx yy Then, the distribution of x given y is observed is normal with
1 var(x|y) = xx xy yy yx 1 E [x|y] = x|y = x + xy yy (y y )

In the linear Gaussian state-space model, the disturbances t , and t are normally distributed and the initial state vector 0 is also normally distributed. From the transition equation, the state vector at time 1 is 1 = T1 0 + c1 + R1 1 Since 0 N (a0 , P0 ), 1 N (0, Q1 ) and 0 and 1 are independent it follows that E [1 ] = a1|0 = T1 a0 + c1 var(1 ) = E [(1 a1|0 )(1 a1|0 )0 ] = P1|0 = T1 P0 T1 + R1 Q1 R01 1 N (a1|0 , P1|0 ) Notice that the expression for a1|0 is the prediction equation for 1 at t = 0. Next, from the measurement equation y1 = Z1 1 + d1 + 1 Since 1 N (a1|0 , P1|0 ), 1 N (0, H1 ) and 1 and 1 are independent it follows that y1 is normally distributed with E [y1 ] = y1|0 = Z1 a1|0 + d1 var(y1 ) = E [(y1 y1|0 )(y1 y1|0 )0 ] = E [(Z1 (1 a1|0 ) + 1 )(Z1 (1 a1|0 ) + 1 )0 ] = Z1 P1|0 Z01 + H1 Notice that the expression for y1|0 is the prediction equation for y1 at t = 0. For the updating equations , the goal is to nd the distribution of 1 conditional 0 0 ) must be on y1 being observed. To do this, the joint normal distribution of (01 , y1 determined and then Result 1 can be applied. To determine the joint distribution of 0 0 (01 , y1 ) use 1 = a1|0 + (1 a1|0 ) y1 = y1|0 + y1 y1|0 = Z1 a1|0 + d1 + Z1 (1 a1|0 ) + 1 7

and note that cov (1 , y1 ) = E [(1 a1|0 )(y1 y1|0 )0 ] 0 = E [(1 a1|0 ) (Z1 (1 a1|0 ) + 1 ] = E [(1 a1|0 ) (1 a1|0 )Z01 + 01 ] = E [(1 a1|0 )(1 a1|0 )Z01 ] + E [(1 a1|0 )01 ] = P1|0 Z01 Therefore, P1|0 P1|0 Z01 , Z1 P1|0 Z1 P1|0 Z01 + H1

1 y1

a1|0 Z1 a1|0 + d1

Now, use Result 1 to determine the mean and variance of the distribution of 1 conditional on y1 being observed: 1 (y1 Z1 a1|0 d1 ) a1 = E [1 |y1 ] = a1|0 + P1|0 Z01 Z1 P1|0 Z01 + H1 0 1 = a1|0 + P1|0 Z1 F1 v1 1 P1 = var(1 |y1 ) = P1|0 P1|0 Z01 Z1 P1|0 Z01 + H1 Z1 P1|0 0 1 = P1|0 P1|0 Z1 F1 Z1 P1|0 where v1 = y1 y1|0 = (y1 Z1 a1|0 d1 ) 0 ] = Z1 P1|0 Z01 + H1 F1 = E [v1 v1 Notice that the expressions for a1 and P1 are exactly the Kalman lter updating equations for t = 1. Repeating the above prediction and updating steps for t = 2, . . . , T gives the Kalman lter recursion equations. 1 |y1 N (a1 , P1 )

You might also like