DsgeSmoother - State Space of Durbin and Koopman

Hello dear all,
I am seeing that DsgeSmoother.m follows notation of Durbin/Koopman (2003):

y_t = Zalpha_t + eps_t, … eps_ t ~ N(0,H)
apha_t+1 = T
alpha_t + R*eta_t, … eta_t ~ N(0,Q)

I see in this function is computed Z, T, R, H, Q and alphahat and it returns as output alphahat, T and R among other elements.

I would like to modify DsgeSmoother.m in order to be able to get Z, T, R, H, Q and alphahat and I would like to include this in one structure, in M_. Could you please give me some advices to do this, maybe, what codes should I include?

By another side, I would like to know the order of variables included in apha_t, for example if I declare endogenous variables:

var x z x_obs z_obs

and after I declare observed variables:
varobs x_obs z_obs

Does It implies alpha will have this order = [x z x_obs z_obs ]?
And Does it implies y_t will have this order = x_obs z_obs ]?

Thanks a lot for your help


That depends on the function your are calling first. In the unstable version, Dynare returns M_ as a function output. If your are using

any additional field passed to M_
should be returned.

Regarding the ordering, it should be in decision rule order. The code in

may be useful for sorting things out.

Dear jpfeifer thank you very much for your help,
I am new in Dynare, so I apologize if my questions seems redundants.

  1. I don’t understand with

Could you please give me more details?
If it is more complicated get Z, T, R, H, Q and alphahat as output saved in M_, I would like to retrieve these matrices after estimation with a simple .m.

  1. By another side.

Where could I see decision rule orden? I appreciate very much your details, please. Is not urgent, but I would be wonderfull with details.

  1. In Dynare 4.3.0. there was a

Where can I find this in Dynare 4.4.3?



  1. The problem is that you have to make sure that the function that calls the smoother also returns the structure M_ where you want to store the additional objects from the smoother. The best way is to use the unstable version and call

in a

2. The decision rule ordering is documented in the manual in section

  1. It should be in