Page 1 of 1

Dynare calls external steady state file twice

PostPosted: Wed Nov 25, 2015 7:34 pm
by twin
Hi,

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?

Thanks!

Tom

Re: Dynare calls external steady state file twice

PostPosted: Thu Nov 26, 2015 8:50 am
by jpfeifer
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.

Re: Dynare calls external steady state file twice

PostPosted: Thu Nov 26, 2015 3:43 pm
by twin
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:

Code: Select all
@#include "parameters.mod"

@#include "variables.mod"

model;
@#include "equations.mod"
end;

shocks;
    var aggregateTFPShock = 1;
end;

steady(nocheck);

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:

Using 64-bit preprocessor
...(preprocessing stuff)...
Preprocessing completed.



Computing steady state...... Done! Elapsed time: 37.50 seconds

STEADY-STATE RESULTS:
...(values for endogenous variables in steady state)...

Computing steady state...... Done! Elapsed time: 37.21 seconds


MODEL SUMMARY
...(output of stoch_simul)...


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.

Re: Dynare calls external steady state file twice

PostPosted: Thu Nov 26, 2015 5:33 pm
by jpfeifer
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.

Re: Dynare calls external steady state file twice

PostPosted: Thu Nov 26, 2015 5:41 pm
by twin
Oh I see, that's indeed a basic mistake on my part. Thanks!

Re: Dynare calls external steady state file twice

PostPosted: Wed Jul 27, 2016 7:59 pm
by twin
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!

Re: Dynare calls external steady state file twice

PostPosted: Thu Jul 28, 2016 6:53 am
by jpfeifer
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
also forces it to evaluate the external steady state file a second time
? 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
Code: Select all
steady(nocheck)
just to set
Code: Select all
options_.steadystate.nocheck

You can simply write
Code: Select all
options_.steadystate.nocheck=1

into your mod-file to set this option. An easier way might be to set
Code: Select all
options_.dynatol.f

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

Re: Dynare calls external steady state file twice

PostPosted: Thu Jul 28, 2016 6:03 pm
by twin
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.