Page 1 of 1

if condition in model block

PostPosted: Tue Aug 18, 2015 1:23 pm
by ycycyc
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!

Re: if condition in model block

PostPosted: Wed Aug 19, 2015 8:49 am
by jpfeifer
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;

Re: if condition in model block

PostPosted: Wed Aug 19, 2015 9:40 am
by ycycyc
Thank you, Johannes!