Non-linear parameter transformation and estimation

Hello,

I am trying to estimate a linearized DSGE model with imperfect information. I solve for the evolution of the state vector using a function [M,m] = state_eq(parameters) that I wrote by myself. The law of motion for the state vector is X_t = M X_{t-1} + m u_t.

I would like to call the entries of M and m into the model block in my mod file but I cannot declare them as parameters because they need to change with the ‘deep parameters’ at every MCMC iteration. I have tried something like this:

var y x …;
varexo u …;
parameters alph bet …;

[M,m] = state_eq([alph bet …]);

model(linear);
x = M(1,1)*x(-1) + …
end

but Dynare does not recognize this matrix notation. I would like to avoid writing an external function for each entry of M and m because that would require solving for the whole matrices M and m numerous times at each MCMC.

Do you have any suggestions?

Thanks a lot for your help!

Giacomo

Define the required entries as parameters and then use a steady state file to call the function state_eq only once per iteration and then write the results of this into the parameters.

Thank you very much Johannes - the solution you proposed works!

I have one more issue though. I know that in the estimation we do not declare the standard errors of the structural shocks as parameters and in the estimation we write something like:

stderr ez,inv_gamma_pdf, 0.007, 0.02;

However in my case the standard error of the shocks pins down the entries of the matrices M and m (which now I compute inside the steady state file). Is there a way to call the standard error of the shocks of the current MCMC iteration inside the steady state file even if they are not declared as parameters? Alternatively, is there another work-around?

Thank you very much again for your help!

In this case, I would suggest setting the standard deviation of the shock to 1 in the shocks-block and estimating the standard deviation as a parameter premultiplying the shock:

Alternatively, you could try to access the corresponding entry of M_.Sigma_e, but the first approach is fail-safe

Of course, I should have thought about this! Thank you very much for your help, Johannes.