Setting macroprocessor options externally

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 macroprocessor options externally

Postby Danman » Thu Jul 07, 2016 4:27 am

I have a core model with a number of alternative versions. I use the macro-processing language to tell Dynare which version to use.

To be concrete, if I want to run a version of the model with anticipated monetary policy shocks in the preamble i will set:

// Tun on anticipated shocks (1 = yes, 0 = no)
@# define anticipated_shocks = 1

and so on. This works fine, but it is inconvenient (and prone to mistake) to have to go into the mod file and change the settings individually each time I run a simulation.

Is there any way that I can set all of these switches in first in matlab and then impose them when I call the Dynare file? My thought was to create a structure in matlab that contained all the settings (e.g. SET.anticipated_shocks = 1) and then use if / else statements in Dynare, like:

if SET.anticipated_shocks == 0
@# define anticipated_shocks = 0
else
@# define anticipated_shocks = 1
end

But that doesn't work because the macro-processing language reads both @# define lines so it always sets anticipated shocks equal to 1.

Any thoughts would be really useful. (Even if the answer is no because then I can stop wasting my time trying to work this out).
Danman
 
Posts: 3
Joined: Thu Apr 14, 2016 11:15 am

Re: Setting macroprocessor options externally

Postby jpfeifer » Thu Jul 07, 2016 8:34 am

You can use the -D command line switch to directly pass preprocessor variables. See
http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=8083 for an example
------------
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 macroprocessor options externally

Postby Danman » Fri Jul 08, 2016 7:31 am

Works perfectly. Many thanks!
Danman
 
Posts: 3
Joined: Thu Apr 14, 2016 11:15 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 8 guests