Prevent Dynare from calling the steadystate file twice

Greetings. I’m computing the steady state file of my model numerically using in the steadystate helper file, i.e. calling MATLAB nonlinear system solver in the steadystate file outside the .mod file.

When I run Dynare using only the steady command which calls the steadystate file, I notice that the call to the steadystate file is made twice, I’m not sure of the reason of this behavior but as the numeric solver is very time expensive it’d help to save a lot of time if I could make that Dynare calls the steadystate only once when computing the steady state, do you know how to do that?

Thanks!

In Dynare 4.6.4 I cannot replicate that behavior. steady only calls the steady state file once. Why do you even need the steady-command?

1 Like

I see, if I have the steadystate file in the same folder, there’s no need to use the steady command? If so, then having both the command and the steadystate file is what makes it compute the steady state twice. Nonetheless I think the steady command is the one that shows me the residuals of static equations, is that correct? Because I need the residuals having only the steady state file, how can I do that? Since if I use resid I think that computation of ss will be call also twice. Thanks.

What exactly are you trying to do?

1 Like

That when I run my Dynare code, it calls steadystate file showing me the resulting residuals from the steady state values that the file gives, without the need for calling steady or resid command, since their presence together with the presence of a steadystate file is what makes the call of my steadystate file solver to be called more than once.

No, I meant why you are calling the file repeatedly so that performance matters and which output you are trying to retrieve within the loop.

1 Like

I mean for example the codes attached, where if I activate steady command, my numerical solver gets called twice (I truncated the number of max func. evals. so it doesn’t get fully evaluated), then if the solver were to take a long time to compute, then the whole program would take twice that time for this double call. When I deactivate steady command I don’t get any residual computation. Thanks!! Let me know if I can make explicit my point.
example_steadystate.m (3.0 KB)
example.mod (7.7 KB)

You still did not answer my question. Why do you even care about the residuals? They should always be 0. And why is the program called so often that you care about speed? Linearized models take less than a minute to solve.

P.S.: You did not provide the function called by fsolve.

1 Like

I often use residual information to know how my steady state strategy is doing, or even spot typos in the equations. I mean to this point I have not been able to solve for the steady state, and that’s why residuals information is useful. I attached, the function that fsolve() is supposed to solve (which is “reduced” form static model). Thanks!!
num_ss_Al.m (2.9 KB)

If you are only interested in the residuals, call only resid;, not steady. The reason the steady state file is called twice is that steady will call it, which will then call resid. But with a steady state file, there is no point in calling steady if you are only interested in the residuals.

1 Like

Perfect, thanks!!