Setting stoch_simul options in Matlab script

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Setting stoch_simul options in Matlab script

Postby jojokre » Tue Sep 01, 2015 12:38 pm

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
jojokre
 
Posts: 14
Joined: Thu Jan 15, 2015 1:49 pm

Re: Setting stoch_simul options in Matlab script

Postby jpfeifer » Sat Sep 05, 2015 5:08 pm

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
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Setting stoch_simul options in Matlab script

Postby bdombeck » Fri May 13, 2016 5:04 pm

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).
bdombeck
 
Posts: 2
Joined: Fri Dec 19, 2014 12:27 am

Re: Setting stoch_simul options in Matlab script

Postby jpfeifer » Sat May 14, 2016 9:09 am

Yes, but you need to use an eval-command: http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=8083
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Setting stoch_simul options in Matlab script

Postby bdombeck » Sun May 15, 2016 5:20 pm

Perfect - thank you for the reference. This is very useful to know.
bdombeck
 
Posts: 2
Joined: Fri Dec 19, 2014 12:27 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 14 guests