Looping over initial values - guide/example code

Dear All,

I need to ask how to run loop over initial values, I am working on (for me) relatively complicated model, and hence, I am unable to solve for steady-state analyticaly, and so, I need to boost power of the numeric steady-state solvers to search in larger space, because I am afraid, that my initial quess will be too far from true steady-state value to converge.
Is there any usefull guide/example code, or at least some function like set_param_value()?

I would be also happy for advice, with solver to use for such a task (personally, i found simple fsolve as most efficient)?

Any advice/insight would be wery welcome!

Best
Jan Žemlička

In case you have such a challenging problem, you should still go for an analytic approach. Simplify the problem until just a few equations remain and then solve those numerically. That is typically easier and faster than going brute force.

Dear professor Pfeifer,

thank you very much for your advice, my supervisor also suggested this approach, but I am not really sure, if this will work, so I plan to build steady state block with as much analytical symplifications as I would be able to derive, but I need to prepare such a “last resort” mechanism to be as sure, as possible, that I will be able to find steady state.

Is there some way, how to program this loop in dynare .mod file, or using looping over dynare file in Matlab? I saw some codes for looping over parameters, so I want to ask, if there is something like set_param_value() function for initial values. I will use this brute force option just once, to find best starting guess for further aplications, so runtime is not so much constraint for me, I just want to be really sure, that solver will converge.

Thank you in advance.

Jan Žemlička

Again, I cannot recommend this approach. It is a lot more promising to simplify the problem first and then loop over initial values for a lower-dimensional problem. If your model is big, you will be trying to fill a large-dimensional hypercube with your randomly drawn initial values. That is very unlikely to work.

If you want to loop over initial values, simply set the content of oo_.steady_state and call

[steady_state,params,info] = evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);

The last output argument will tell you whether the search has been successful.

Dear professor Pfeifer,

I plan to use this option, does syntax of this function change, when I will provide steady_state_model block? Should implementation of this loop looks something like this?

Best Regards
Jan Žemlička

You should use something like

info=1;
iter=1;
while info && iter<100
    oo_.steady_state=oo_.steady_state+randn(size(oo_.steady_state));
    [steady_state,params,info] = evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);
    iter=iter+1;
end

Thank you very much, now I think, that I understand, how to do it!

I just thinking about deterministic grid for this task, instead of random walk approach, create sequence of initial values (capital, hours worked, nominal rate,…) and create nested loops to step-by step search in reasonable area of state space.

Best Regards
Jan Žemlička

That is fine as well. Simply set the entries of oo_.steady_state as you like in that loop. But remember: filling out a hypercube like that will be challenging.

Dear professor Pfeifer,

thank you very much, I really appreciate your guidance!

Best Regards
Jan Žemlička