Error using print_info (line 32)-Error in steady (line 102)-Error in nkbb.driver (line 364)-Error in dynare (line 293)

Dear all,

How could I make Dynare compute the steady state of my model first and, afterwards, run / simulate the model using two values of that steady state?
The idea is to get GDP at constant prices in the simulation and, those constant prices would be the steady state ones.
The code is v7justq_works.rar (12.8 KB)
Note: With matlab (and fsolve) I computed the steady state as an isolated piece of code. If this is a better strategy, how could I make Dynare to use the values found in this piece? This is the code for steady state: steady_try.zip (4.4 KB)
Thank you so much.

I am not sure I understand your question. There are various examples on how to use steady state files. See e.g. the Dynare examples-folder.
What do you mean with different steady state? Does your model contain a unit root so that you need to select a particular steady state?

quality_ctatP.zip (18.6 KB)
Letā€™s see if I explain myself correctly:
No, I donā€™t have multiple equilibriaā€¦
In the model equations (e.g. equation 20 in dyn_main.mod) I use ā€˜psā€™ (and ā€˜qsā€™) which should be the prices in the steady state.
However, the model cannot take the (true) steady state price there, because it has not yet been computed. This is the reason I need to have the steady state in advance (I find it with steadystate_matlab_try.m attached. This file saves the results in stst.mat).
Now, I need dynare model equations to take the correct psH, psF, qsH and qsF values (saved in stst.mat) when running the model and simulating it. But I did not manage so far (now, one must run dyn_calibration.m to use the code).

What I had some weeks ago (and I am convinced it was incorrect) was a value assignment to this ps, ā€¦ Of course, every time I changed the parameterization of the model, these assigned values where no longer correct as steady state values.

I sincerely thank you for answering.

The code I upload here is quite messy because I was trying different things. Sorry.

Best.

Again, I donā€™t understand why you cannot use a steady state file to recompute the steady state?

Iā€™m not sure I understand your question. Sorryā€¦
Could I make equation 20 in the model section (for example) use the steady state price psH? I was ā€œcallingā€ psH in equation 20, before the steady section. But at that point, psH is not computed yet by the steady state file.

To solve the above, I tried computing the steady state first to have this psH (and psF, qsH, qsF) before the model section is run. And wanted to run steady; as always, afterwards, to see if all together works. Is this incorrect? What is your advise?
The other doubt is: how can I make dyn_main.mod use the values saved in stst.mat. I tried with external function pss.m without success.

What you describe is exactly what a steady state file doesā€¦

I do it (or the code is supposed to do it once I manage to take the ā€˜psā€™ for my model equations).
When running dyn_main.mod, the steady part is there and it calls the steady state file. But I (think I) need to pour psH psFā€¦ before. Is this not ok?

Dear Johannes,
Now it seems to work fine. The ā€œpreā€ steady state (_try.m files) and the final one (dyn_main_steadystate.m called with steady;) are identical.
When I modify parameter values, it does not crash.
quality_ctatP_works.zip (18.8 KB)
Shame on meā€¦ the attached is the messiest code ever. I must clean itā€¦
Do you detect any crazy procedure in it?
Thank you so so much for your support and help.

The only thing I immediately notice is that you are not extracting the error code of fsolve. See https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Jermann_Quadrini_2012/Jermann_Quadrini_2012_RBC/Jermann_Quadrini_2012_RBC_steadystate.m

Do you mean output exitflag in fsolve?
I now added

[X,exitflag] = fsolve(@(X) dyn_det(X),X0,options);
if exitflag<1
check=1;
end

And I get an error (see below). But all residuals of equations are zero. Why? Whatā€™s happening?

Error using print_info (line 32)
The steadystate file did not compute the steady state
Error in check (line 48)
print_info(info, 0, options);
Error in dyn_main.driver (line 746)
oo_.dr.eigval = check(M_,options_,oo_);
Error in dynare (line 293)
evalin(ā€˜baseā€™,[fname ā€˜.driverā€™]) ;
Error in dyn_calibration (line 7)
dynare dyn_main.mod noclearall

It needs to be

[X,fval,exitflag] = fsolve(@(X) dyn_det(X),X0,options);
  if exitflag<1
      check=1;
  end

exitflag is the third output, not the second.

Thank you! I corrected this.
The code attached in my previous post worked fine for different parameterizations. Now, I tried setting del=0.025 (K depreciation) and it fails to compute the steady state (with dynare). However, it works fine, at least, for del between (0.027,0.05).
The equations with residuals are different from those that were giving problems in the pastā€¦ Indeed, the equations with residuals different from 0 are different for del=0.025 and for del=0.026. Where should I look to find the cause of this?
Many thanks.
quality20201218_fails.zip (18.6 KB)

You can verify that your call to fsolve does return with exitflag=0, i.e. no solution was found.