Page 1 of 1

Extended Kalman Filter

Posted: Tue Mar 23, 2010 3:29 pm
by ecrgap
Hi all,

I'm trying to code a dsge model with a threshold interest rate rule, so I need to perform the extended Kalman Filter. An example is the attached paper. Is there a similar example available?


Thanks in advance

Re: Extended Kalman Filter

Posted: Thu Mar 25, 2010 12:03 pm
by TomDoan
For each function evaluation, you have to solve the model for each of the two states. To do that, you'll need alternative FRML's where a particular equation depends upon state-dependent parameters (I believe that's just the interest rate equation), and you'll need two GROUP instructions which put together the two collections of equations. Those are set up in advance. Then, for a function evaluation, you do DSGE instructions on the two models to get two state-space representations.

Since kappa-c and N-c are fixed for a given experiment, you can compute the state switching dummy in advance. That's most conveniently handled by defining a SERIES[INTEGER] which is 1 or 2:

Code: Select all

dec series[int] state
gset state = fix(??? which evaluates to 1 or 2)

This will be called to solve the two models at every function evaluation:

Code: Select all

dec vect[rect] a(2) f(2)
function SolveModels
dsge(model=dsge1,a=a(1),f=f(1)) list of variables
dsge(model=dsge2,a=a(2),f=f(2)) list of variables
end SolveModel
and this (with other options), will compute the log likelihood:

Code: Select all

dlm(startup=SolveModels(),a=a(state(t)),f=f(state(t)),...

Re: Extended Kalman Filter

Posted: Mon Mar 29, 2010 7:33 am
by ecrgap
Thanks a lot Tom

So I guess the procedure gets more complicated once kappa-c becomes time varying (as is the case in my work).
Another thing that causes me troubles is that after the fix function I get the following message

## SR13. Need to Include an Entry Range. No Previous Instruction Has Set the Default

I haven't used the fix function before so I must be doing sth wrong.

Thanks in advance

Re: Extended Kalman Filter

Posted: Mon Mar 29, 2010 2:03 pm
by TomDoan
You can't set that up that series until you have data; that's the complaint--that it doesn't know what the range is. You can either do an ALLOCATE to set the range to match your data, or just read the data up near the top.

How is kappa-c supposed to vary in your model? As long as the state can be computed in advance, the general strategy above should work.

Re: Extended Kalman Filter

Posted: Mon Mar 29, 2010 2:13 pm
by ecrgap
So in my case, assuming that kappa is not time varying, I want to define the ''dummy'' to be equal to 1 whenver inflation is equal to 2%.

After that, what I want to try is whether I can collapse the two models into one in order to generate the calibrated impulse responses.

So as you said I should use the allocate instruction instead of fix, no?

And if I understand well, the instruction for the impulse responses should like like the following:

@dlmirf(a=a(t), f=f(t)....)

or do I have to do sth else in order to generate the calibrated impulse responses?

Re: Extended Kalman Filter

Posted: Wed Mar 31, 2010 12:14 pm
by ecrgap
Another example is the paper by Davig and Leeper (2006), attached