How to show the Kalman Gains?

Discussion of State Space and Dynamic Stochastic General Equilibrium Models
May-June
Posts: 10
Joined: Thu Dec 05, 2013 3:53 am

How to show the Kalman Gains?

Unread post by May-June »

Dear Tom,

I'm trying to replicate the KalMan filter of Stock and Watson (1991) and I would like to extract the Kalman Gain.
I have added the option: Gain = Gain into DLM
*
dlm(start=%%DLMSetup(),y=yf,sw=sw,c=c,a=a,f=f,$
presample=ergodic,type=filter,$
pmeth=simplex,piters=10,Gain=Gain,method=bfgs) 1959:2 * xstates
*
And then, I don't know how to show the "GAIN".
I was trying with "display" but It appeared : Expected Type REAL, Got RECTANGULAR[REAL] Instead

Please show me how to do.

Many thanks.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to show the Kalman Gains?

Unread post by TomDoan »

GAIN produces a SERIES[RECT]. Assuming you have a single observable (it's a RECT because you could have multiple observables) you would need something like:

set gain1 = gain(t)(1,1)
set gain2 = gain(t)(2,1)

to extract the gains for the first and second states.
May-June
Posts: 10
Joined: Thu Dec 05, 2013 3:53 am

Re: How to show the Kalman Gains?

Unread post by May-June »

Many thanks for your help.
Post Reply