I am currently going through the codes of Benedikt Kolb, where he shows us how to maximise the likelihood of a New Keynesian model with a financial accelerator over one parameter. He uses Uhlig’s toolbox to solve the model but before he does that he matches the observables from the data into the measurement equation:

% H, matching observables from dy into measurement equation
ns = 16; % # states in model
H = zeros(nd,ns); %nd is the number of observables which is equal 6
H(1,5) = 1; % Y = y(t)
H(2,6) = 1; % C = c(t)
H(3,7) = 1; % I = i(t)
H(4,8) = 1; % P = pi(t)
H(5,9) = 1; % R = rn(t)
H(6,10) = 1; % S = cs(t)

H is 6 by 16 matrix, where the rows represent the number of observables and the columns the number of state variables. Does anyone know why output Y takes the position 5 in row 1 and so on? My plan was to understand the codes and link them back to Dynare’s output after the model has been solved. All codes are attached - the lines of code above can be found in example1.m.

this really just depends on the way the vector of endogenous variables is set up, ie in what order he put the variables. The way he did it is that Y is the fifth one, c number 6 etc. When he sets up the model in the large matrices, this is the order in which he types in the equations. I am sure that he explains this order somewhere, otherwise you can extract it by going through the equations and the matrices of the solution method.

This is a quick follow up question with regard to @DoubleBass’ answer. Is there a way to set up the same H matrix with the help of the output of Dynare? In other words, once we have the solution of the model is it possible to link my endogenous variables to the observables using the M matrix approach as shown above? I have been looking into the oo\_ and M\_ structures, but my feeling is that this won’t be possible, correct me if I am wrong. Thanks!

Sorry @jpfeifer, one last question regarding this. In the link you posted, the corresponding matrix to H is C in Dynare, which we get using the kalman transition matrix file given the oo\_dr.ghx. In the ABCD test, you get the position of the observables using

%get observable position in decision rules
obs_var=oo_.dr.inv_order_var(options_.varobs_id);

Therefore, all elements of the C matrix are filled. In contrast, the H matrix above is a matrix with ones on the diagonal that corresponds to the order of the endogenous variables. As I am following Benedikt Kolb’s codes above, Is there a way to map from C over to H? Or can I just use C, sorry can’t get my head around this at the moment…

If I were in your place, I would not aim at replicating the approach one for one, but rather to get a consistent state space representation for each approach and work with those.

Thanks @jpfeifer, annoyingly I thought I almost had it but then the H matrix seems to make things difficult. I will try what you said. I came across this post

Would you say this is a good starting point? Also, I have seen that you replicated Dynare’s Kalman results with the internal MATLAB implementation. Do you remember whether you have used the