model with signal extraction

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

model with signal extraction

Postby taleggio » Fri Nov 28, 2014 2:50 pm

I am using the code provided by Blanchard, L'Hullier and Lorenzoni (AER,2013). They use an old dynare version (3.065). Their approach needs to use the Kalman filter to produce the expectations of some states the agents use in their signal extraction problem. In their code (and in the old Dynare version they're using), it is possible to use matlab functions outside dynare, by just adding a # in front of each line. It is then possible to use the outputs of the matlab function within dynare.
I cannot understand if this is possible in the version 4.4.3 I am using. I give you an example: their first line is the following: # A=[1+rho -rho 0 ; 1 0 0 ; 0 0 rho ];
They define the A matrix that is then used in what follows in their code

Is it possible to use matlab function (or user-defined functions) within Dynare now? How to do that?

Thanks for your help
taleggio
 
Posts: 2
Joined: Fri Nov 28, 2014 2:36 pm

Re: model with signal extraction

Postby taleggio » Mon Dec 01, 2014 9:39 am

hello!

I used an absolutely inelegant code that waistes some computer time, but at least works in dynare 4.4.3!

The idea in Blanchard, Lorenzoni and L'Hullier is to use the steady state kalman filter to compute the dynamics of the expectations of states that enter in the solution of the model.

The steady state kalman filter computations give you the gain matrix (K). This is a matrix but dynare 4.4.3 works only with scalars (this is what is written in the help...there is actually footnote 1 in the reference manual that states: "Note that arbitrary MATLAB or Octave expressions can be put in a .mod file, but those expressions have to be on separate lines, generally at the end of the file for post-processing purposes. They are not interpreted by Dynare, and are simply passed on unmodified to MATLAB or Octave. Those constructions are not addresses in this section". Is there anybody that can clarify this?).

My idea is to compute K and save it; then have many different functions that just load the saved K. Each function has one output: one and only one element of K.

This is super-inefficent and not- elegant, but it works...
As K is only 3x5 I can do it, but what if K is 10x5?

In Dynare 3.065 used bu Blanchard et al, it was much easier: matlab functions could be called by just adding # in front:

This is their way to compute the steady state Kalman gain. This part could be put in the .mod file:

# for iter = 1:100000;
# P = A*P*A' - A*P*F'*K'*A' + S_1;
# Ki = P*F'/(F*P*F' + S_2);
# dif = max(max(abs(Ki-K))); K = Ki;
# if dif<1e-15
# break;
# end
# if iter == 99999
# display('conv not achieved !!!!')
# end;
# end;

I am sure that there is another way to do the same in Dynare 4.4.3. Any suggestions?

Thank you!
taleggio
 
Posts: 2
Joined: Fri Nov 28, 2014 2:36 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 11 guests