Problems with steady state when looping over different parameters

Hi everyone, I am performing a MC experiment with the NK baseline model. My aim is to simulate the model for 500 different configurations of parameters (CoP) and, for each CoP, I want to simulate 500 MC runs. To do that, I did two loops, an external loop over the CoP and an internal loop over the MC. The code runs without any problem. Unfortunately, for some CoP I get this message: “The steadystate file did not compute the steady state” and the simulation stops.
I am wondering whether there is way to throw away this “problematic” CoP and continue the simulation with the subsequent CoP.
I am aware that similar topics have been treated in the forum, however I did not find a specific solution for my problem. Any suggestion will be really appreciated.

Thanks in advance,
Mario

As a solution, I set steady(homotopy_force_continue=1) to “[k]eep the values of the last homotopy step that was successful and continues. BE CAREFUL : parameters and/or exogenous variables are NOT at the value expected by the user” (see reference manual, Sec. 4.10.1). I am wondering whether this is the optimal solution.

Many thanks,
Mario

No, that is clearly not the optimal solution, but without seeing the codes, it’s impossible to tell what the proper error handling is.

Loop_exp_II.m (2.2 KB)
NK_baseline_II.mod (10.6 KB)

Dear Prof. Pfeifer,

thank you very much for the prompt reply, in attachment you can find the codes. In particular, a Matlab file with the loop over the parameters and the Dynare file. The loop over the MC runs is inside the Dynare file.

Many thanks,
Mario

You should be pretty much able to take

from the shelf.

Thanks Prof. Pfeifer!

Best,
Mario