Dear all,

I have a question on the usage of globals when trying to calibrate a model in Dynare. In my objective function I try to find the parameter combination that minimizes squared distances between data targets and model outcomes. In my execution file, I run my mod-file first and solve the problem (the objective function attached) using Multistart and the fmincon solver.

When the model is approximated at first order, the simulations run at a reasonable time range. However, when using order=3, the code runs for a very long time. Since MultiStart can be applied with parpool in Matlab, I tried to exploit this option. However, since in the objective function the output oo_ from Dynare is declared as a global, parallelization does not work. If I do not declare it as a global, stoch_simul does not simulate for the new parameter values specified with set_param_value.

Is there an option to get around the global variable in the objective function or to increase speed in another way when using a third order approximation?

Thank you a lot for your help! C11.m (4.7 KB)