Setting stoch_simul options in Matlab script


probably someone has asked this question before, but I could not find it:

I’m starting dynare from a matlab script, i.e. dynare ‘name of .mod-file’ noclearall. In the Dynare file I’m using the stoch_simul command. I want to compare some moments of different models. Is there an easy way to specify the options (for example order=2) for the stoch_simul command in the Matlab script (without storing them in an extra file and calling the extra file from the .mod-file)?

Thanks in advance.

Best, Johanna

You can pass macro variables via the preprocessor. For example, include in your mode file

Thus, there is a macro-variable called approx_order that specifies the order. Then call the mod-file with

The -D tells the preprocessor you are passing a macro variable. The following approx_order=2 set the value. It’s equivalent to

Is it possible to pass a variable with a certain value, rather than the value itself? Something like writing


in the .mod file, and then in a .m file writing

dynare example1 -Dapprox_order=order

This returns the error

syntax error, unexpected NAME, expecting INT_NUMBER

because “order” is read as a string (I think).

Yes, but you need to use an eval-command: [Loop over certain antizipation horizons)

Perfect - thank you for the reference. This is very useful to know.