Page 1 of 1

Setting stoch_simul options in Matlab script

PostPosted: Tue Sep 01, 2015 12:38 pm
by jojokre
Hi,

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

Re: Setting stoch_simul options in Matlab script

PostPosted: Sat Sep 05, 2015 5:08 pm
by jpfeifer
You can pass macro variables via the preprocessor. For example, include in your mode file
Code: Select all
stoch_simul(order=@{approx_order});

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

Code: Select all
dynare example1 -Dapprox_order=2

The -D tells the preprocessor you are passing a macro variable. The following approx_order=2 set the value. It's equivalent to
Code: Select all
@#define approx_order=2

Re: Setting stoch_simul options in Matlab script

PostPosted: Fri May 13, 2016 5:04 pm
by bdombeck
Is it possible to pass a variable with a certain value, rather than the value itself? Something like writing

Code: Select all

stoch_simul(order=@{approx_order})



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

Code: Select all
order=2
dynare example1 -Dapprox_order=order


This returns the error
Code: Select all
syntax error, unexpected NAME, expecting INT_NUMBER


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

Re: Setting stoch_simul options in Matlab script

PostPosted: Sat May 14, 2016 9:09 am
by jpfeifer
Yes, but you need to use an eval-command: http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=8083

Re: Setting stoch_simul options in Matlab script

PostPosted: Sun May 15, 2016 5:20 pm
by bdombeck
Perfect - thank you for the reference. This is very useful to know.