if condition in model block

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.

if condition in model block

Postby ycycyc » Tue Aug 18, 2015 1:23 pm

Hello,

I wonder if it is possible to define a Macro-variable to equal to a parameter. Something like
parameters sig_c;
sig_c=1;
@#define sig_c_par=sig_c

I am trying to estimate a model using Dynare. My model has a CRRA utility function, so the model equation of the utility function will be
U= c^(1-sig_c) / (1-sig_c) or U= log(c), depending on the intertemporal elasticity of substitution sig_c. I want to bayesian estimate sig_c, and I wonder how to tell dynare to use the equation U=log(c) when sig_c=1. I have tried the following code, but got the error msg ' ERROR in macro-processor ... Unknown variable: sig_c'.

parameters sig_c;
sig_c=1;
@#define sig_c_par=sig_c
...
model;
@#if sig_c_par==1
U=log(c);
@#else
U= c^(1-sig_c) / (1-sig_c);
@#endif
...
end;

Does anyone have a suggestion how to solve the problem? Any help will be much appreciated!
ycycyc
 
Posts: 2
Joined: Tue Aug 18, 2015 12:47 pm

Re: if condition in model block

Postby jpfeifer » Wed Aug 19, 2015 8:49 am

No, that is not possible. You need to do something like

Code: Select all
@#define log_utility = 1

@#if log_utility ~= 1
parameters sig_c_par;
sig_c_par = any_value_you_like;
@#endif

model;
@#if log_utility==1
U=log(c);
@#else
U= c^(1-sig_c_par) / (1-sig_c_par);
@#endif
...
end;
------------
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: if condition in model block

Postby ycycyc » Wed Aug 19, 2015 9:40 am

Thank you, Johannes!
ycycyc
 
Posts: 2
Joined: Tue Aug 18, 2015 12:47 pm


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 7 guests