Dynare calls external steady state file twice


I’m currently solving a model where I use an external _steadystate.m file, and I find that Dynare calls this function twice per run. This seems unnecessary, and actually costs me a fair bit of time because the steady state is complicated to compute. Is there a way to get it to only call the external function once? Why does Dynare call the external function twice?



Please provide more context on what you are trying to achieve and which Dynare routines you call. The steady state file should only be called once per computation of the decision rules.

Sure, I should have been more specific. I’m just trying to call stoch_simul to get the basic output from that. In particular, my code looks like:

@#include "parameters.mod"

@#include "variables.mod"

@#include "equations.mod"

    var aggregateTFPShock = 1;


stoch_simul(order=1,irf=100,hp_filter=1600,relative_irf) aggregateTFP aggregateOutput aggregateInvestment aggregateConsumption aggregateHours wage realInterestRate;

My external steady state file prints “Computing steady state…” whenever its called. The output is:

So, the steady state file is called directly before and directly after the STEADY STATE RESULTS output. I’m away for a holiday today, but could also post code for a minimal working example when I get back. Hopefully I’m just missing something basic and you can set me straight. Thanks for your time.

The steady-command is only for displaying the steady state. In your case, just leave it out. The call to stoch_simul will compute the steady state required for the decision rules.

Oh I see, that’s indeed a basic mistake on my part. Thanks!

It has been a while but I have a follow up question to this thread. I am trying to solve a model where I have an approximate steady state computed using an external _steadystate.m file. The maximum residual associated with this approximated steady state is on the order of 1e-4, which I am fine with but Dynare is not: it throws up the error “The steadystate file did not compute the steady state” and does not continue with stoch_simul. The only way I know to force Dynare to continue is to call steady(nocheck), which instructs Dynare not to check the steady state residuals, but also forces it to evaluate the external steady state file a second time. The steady state is costly to compute so I would like to avoid this. Is there a way to tell Dynare to ignore the steady state residuals without calling the external steady state file a second time? Thanks!

I am not following. How can you have a rather big residual with an analytically computed steady state? Overriding Dynare’s check for correctness simply because there is a problem with the file is not advocated.
And what do you mean with

? Which commands are you calling? And why is a second call costly? You should not be looping over full Dynare in any case and the typical Dynare commands you can loop over only call the steady state file once.

There is no reason to call steady(nocheck) just to set

You can simply write

into your mod-file to set this option. An easier way might be to set

that is the tolerance for the correctness check. You should use the unstable for this, because there was a problem with the nocheck option.

Thanks Johannes, this is exactly what I am looking for – I didn’t know how to manually control these options, so I was calling steady(nocheck) as a workaround. Thanks for your help.

To clarify: I’m not analytically solving the steady state. I’m approximating it numerically using an external _steadystate.m file. Calling this function is costly because it involves a complicated nonlinear equation, and I would like to be able to control the tolerance with which I solve that equation. I understand that a residual of 1e-4 will introduce numerical error into the solution.