Define macro-variable depending on parameter value
Posted: Wed Feb 26, 2014 4:54 pm
I am running second order approximation and letting dynare to calculate unconditional utility. I'm using CRRA utility, specifying utility function depends on whether risk aversion parameter equals 1 or not. I'm trying to write the following code:
...
parameters rho
rho=1;
@#define logutility=rho
...
model;
@#if logutility
U=log(exp(c)-exp((1+epsilon)*h)/(1+epsilon))+beta*U(+1);
@#else
U=(exp(c)-exp((1+epsilon)*h)/(1+epsilon))^(1-rho)/(1-rho)+beta*U(+1);
@#endif
end;
...
However, Dynare returns msg "unknown variable rho". To my understanding, I cannot specify "@#define logutility=rho" because rho is a parameter, not a macro-variable, so it cannot show up within "@#define".
I wonder if there is a way to circumvent this problem?
...
parameters rho
rho=1;
@#define logutility=rho
...
model;
@#if logutility
U=log(exp(c)-exp((1+epsilon)*h)/(1+epsilon))+beta*U(+1);
@#else
U=(exp(c)-exp((1+epsilon)*h)/(1+epsilon))^(1-rho)/(1-rho)+beta*U(+1);
@#endif
end;
...
However, Dynare returns msg "unknown variable rho". To my understanding, I cannot specify "@#define logutility=rho" because rho is a parameter, not a macro-variable, so it cannot show up within "@#define".
I wonder if there is a way to circumvent this problem?