by 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!