Unexpected var ----help....please

nk_2.mod (921 Bytes)

Dear all
Hi,i am one of the new DYNARE user and want to use the software to see the relationship for NK model with consumer habit and loss function.

i meet some technical problem in my DYNARE, first of all, i add the loss function which is linear in my model and when i run it, the DYNARE shows that “i have syntax error, unexpected VAR” the VAR in here is the variance of loss function, so i am quite confused why this things happened ?

the other question is that , i read some papers but non of them include the loss function as the exogenous variable, should i need to consider the loss function as an exogenous variable ? if i remove the loss function from my dynare function, all the parameter shows unknown symbol.

i am really want to solve this question, can you help me to solve that ? please.

thanks very much

here is my command and mod;

var x pi r y l;  // x for output gap, pi for inflation, r for nominal interest rate, y for potential output, l for loss function
 
varexo u epsilonr epsilony;  // u for cost push shock, epsilonr for monetary shock and epsilonr y for TFP shock 
 
parameter sigma gamma beta k mu1 mu2;
 
sigma=1.5;
gamma=0;
beta=0.995;
k=0.1;
mu1=1.5;
mu2=0.5/4;

 
model(linear);
 // IS equation//
x=sigma/(gamma*(sigma-1)+sigma)*x(+1)+(gamma*(sigma-1)/(gamma*(sigma-1))+sigma)*x(-1)-1/(gamma*(sigma-1)+sigma)*(r-pi(+1))-(y-sigma/gamma*(sigma-1)+sigma)*y(+1)-(gamma(sigma-1)/gamma(sigma-1)+sigma)*y(-1);

 // AR(1) for potential output//
y=0.5*y(-1)+epsilony;

 // NKPC//
pi=beta*pi(+1)+k*x+u;

 //Taylor rule// 
r=mu1*pi(+2)+mu2*x+epsilonr;

// loss function// 
l=var pi+0.5*var x; 
end;

initval;
y=epsilony;
r=epsilonr;
pi=u;
x=0;
u=0;
epsilonr=0;
epsilony=0;
end;

shocks;
Var u=1; 
Var epsilonr=1;
Var epsilony=1; 
end;

stoch_simul;

solved with thanks

var is a reserved keyword for the variances. Regarding a loss function example, see https://github.com/JohannesPfeifer/DSGE_mod/tree/master/Born_Pfeifer_2018/Welfare for a nonlinear version and https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_2015/Gali_2015_chapter_6_5.mod for a manually coded loss function