Hello, I am a bit confused about the timing and expectation operator in dynare and how it is related to model local variables,. Suppose I have the following utility function u\left(c_{t}\right)=\frac{\left(c_{t}-hc_{t-1}\right)^{1-\gamma}}{1-\gamma} and an asset (not risk free) with R_{t}^{p} gross return for time t for asset purchased at time t-1. Then Euler eqn \left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\left(c_{t+1}-hc_{t}\right)^{-\gamma}=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left(\left(c_{t+1}-hc_{t}\right)^{-\gamma}-\beta h\left(c_{t+2}-hc_{t+1}\right)^{-\gamma}\right)^{-\gamma}\right]
Which of the following is correct in dynare if I am doing 2nd - 3rd order simlations as in Basu-Bundick
Case-1 (with model-local variables)
model_local_variable
uc $mu_{t}$ (long_name='marginal utility at time t')
end;
model
#uc=((c-h*c(-1) -betta*h*(c(+1)-h*c))^(-gamma);
uc=betta*uc(+1)*Rp(+1);
end;
Case-2 (with model-local variables)
model
#util=c(+1)-h*c;
#uc=(util(-1) -betta*h*util)^(-gamma);
#uctp1=((util-betta*h*util(+1))^(-gamma))^(-gamma);
uc=betta*uc(+1)*Rp(+1);
end;
Case-3 (without model-local variables)
model
uc=(c-h*c(-1))^(-gamma)-betta*h*(c(+1)-h*c)^(-gamma);
uc=betta*uc(+1)*Rp(+1);
end;
Thank you
Thank you for the answer. But I am extremely confused and having doubts if dynare can actually deal with habits, adjustment costs etc in 2nd and 3rd order. Or maybe I am confusing the basics. Below I try to explain my confusion, especially this expectation operator in dynare and whether model-local variables can include leads
Suppose I have the following u\left(c_{t}\right)=\frac{\left(c_{t}-hc_{t-1}\right)^{1-\gamma}}{1-\gamma} and an asset (not risk free) with R_{t}^{p} gross return for time t for asset purchased at time t-1. Then Euler eqn
\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\mathbb{E}_{t}\left[\beta h\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left(\left(c_{t+1}-hc_{t}\right)^{-\gamma}-\beta h\left(c_{t+2}-hc_{t+1}\right)^{-\gamma}\right)^{-\gamma}\right]
CASE-1 Model-Local variables
model
#uc=( (c-h*c(-1)^(-gamma) -betta*h*(c(+1)-h*c) )^(-gamma);
\underbrace{\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\mathbb{E}_{t}\left[\beta h\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]}_{\text{uc}}
uc=betta*uc(+1)*Rp(+1); \underbrace{\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]}_{\text{uc}}=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left[\underbrace{\left(c_{t+1}-hc_{t}\right)-\mathbb{E}_{t}\left[\beta h\left(c_{t+2}-hc_{t+1}\right)^{-\gamma}\right]}_{\text{uc(+1)}}\right]\right]
end;
CASE-2 Model-Local variables
model
#util=(c(+1)-h*c);
util=\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]
#uc=( util(-1)^(-gamma) -betta*h*util^(-gamma) );
uc=\left(\underbrace{c_{t}-hc_{t-1}}_{\text{util(-1)}}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(\underbrace{\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]}_{\text{util(+1)}}\right)^{-\gamma}\right]
#uctp1=(( util^(-gamma)-betta*h*(util(+1))^(-gamma) );
uctp1=\underbrace{\left(\overbrace{\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]}^{\text{util}}\right)^{-\gamma}}_{\text{util to (-gamma)}}-\beta h\mathbb{E}_{t}\left[\underbrace{\left(\overbrace{\mathbb{E}_{t}\left[c_{t+2}-hc_{t+1}\right]}^{\text{util(+1)}}\right)^{-\gamma}}_{\text{util(+1) to (-gamma)}}\right]
\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]\right)^{-\gamma}\right]=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left[\left(\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]\right)^{-\gamma}-\mathbb{E}_{t}\left[\beta h\left(\mathbb{E}_{t}\left[c_{t+2}-hc_{t+1}\right]\right)^{-\gamma}\right]\right]\right]
uc=betta*uc(+1)*Rp(+1);
\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]\right)^{-\gamma}\right]=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left[\left(\mathbb{E}_{t}\left[c_{t+1}-hc_{t}\right]\right)^{-\gamma}-\mathbb{E}_{t}\left[\beta h\left(\mathbb{E}_{t}\left[c_{t+2}-hc_{t+1}\right]\right)^{-\gamma}\right]\right]\right]
end;
CASE-3 Without Model-Local variables, only Var block
model
uc=(c-hc(-1))^(-gamma)-bettah*(c(+1)-h*c)^(-gamma);
uc=\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]
uc=betta*uc(+1)*Rp(+1);
\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]=\beta\mathbb{E}_{t}\left[\left(c_{t+1}-hc_{t}\right)^{-\gamma}-\beta h\mathbb{E}_{t}\left[\left(c_{t+2}-hc_{t+1}\right)^{-\gamma}\right]\right]
end;
You are confusing what a model-local variable does. It will simply plug in the text expression at the place it is encountered. It will not define a new variable in the information set at time t, which would contain an expectation.
Thus,
#uc=( (c-h*c(-1)^(-gamma) -betta*h*(c(+1)-h*c) )^(-gamma);
means plugging in
\underbrace{\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\left[\beta h\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]}_{\text{uc}}
such that
uc=betta*uc(+1)*Rp(+1);
corresponds to
\mathbb{E}_{t} \left[\underbrace{\left(c_{t}-hc_{t-1}\right)^{-\gamma}-\beta h\left[\left(c_{t+1}-hc_{t}\right)^{-\gamma}\right]}_{\text{uc}}\right]=\beta\mathbb{E}_{t}\left[R_{t+1}^{p}\left[\underbrace{\left(c_{t+1}-hc_{t}\right)-\left[\beta h\left(c_{t+2}-hc_{t+1}\right)^{-\gamma}\right]}_{\text{uc(+1)}}\right]\right]
You can easily check the output by investigating the \LaTeX output from write_latex_dynamic_model.