?Syntax error, unexpected $end dynare?


#1

Dear friends,
i am a beginner to DSGE, and confused by the error notice after running this simple NK.mod. NK.mod (1.3 KB)
Looking forward to your comments.Thanks!

Appendix of code//NK model
//NK model
var Y I C R K W L MC P PI A;
varexo e;
parameters sigma phi alpha beta delta rhoa psi theta;

sigma = 2;
phi = 1.5;alpha = 0.35;beta = 0.985; delta = 0.025; rhoa = 0.95; psi = 8;theta = 0.75;

model(linear);
#Pss = 1;
#Rss = Pss *((1/beta)-(1-delta));
#MCss = ((psi-1)/psi) *(1-beta *theta) *Pss;
#Wss = (1-alpha) *(MCss^(1/(1-alpha))) *((alpha/Rss)^(alpha/(1-alpha)));
#Yss = ((Rss/(Rss-delta *alpha *MCss))^(sigma/(sigma+phi))) *((Wss/Pss) *(Wss/((1-alpha) *MCss))^phi)^(1/(sigma+phi));
#Kss = alpha * MCss * (Yss/Rss);
#Iss = delta * Kss;
#Css = Yss - Iss;
#Lss = (1-alpha) * MCss * (Yss/Wss);

//1-Labor supply
sigma *C + phi *L = W - P;
//2-Euler equation
(sigma/beta) *(C(+1)-C)=(Rss/Pss) *(R(+1)-P(+1));
//3-Law of motion of capital
K = (1-delta) *K(-1) + delta *I;
//4-Production function
Y = A + alpha *K(-1) + (1-alpha) *L;
//5-Demand for capital
K(-1) = Y - R;
//6-Demand for labor
L = Y - W;
//7-Marginal cost
MC = (1-alpha) *W + alpha *R - A;
//8-Phillips equation
PI = beta *PI(+1)+((1-theta) *(1-beta *theta)/theta) *(MC-P);
//9-Gross inflation rate
PI = P - P(-1);
//10-Goods market equilibrium condition
Yss *Y = Css *C + Iss *I;
//11-Productivity shock
A = rhoa *A(-1) + e;
end;

steady;
check(qz_zero_threshold=1e-20);

shocks;
var e;
stderr 0.01;
end;

stoch_simul(nograph,qz_zero_threshold=1e-20) Y I C R K W L PI A;


#2

It seems that the code works well in windows while fails in OS.


#3

I tried it out - It at first reported errors, but if I copy and paste codes in a new file, things are all fine. There must be some kind of weird mysterious bugs. (I use windows)


#4

@HoutanBastani @sebastien I can actually replicate the issue on Windows in both Octave and Matlab. Something in the parsing of the file goes wrong. If I copy its contents to a different file, the issue is gone. But I cannot see any invisible characters in the file that might cause this.


#5

The problem is that the line endings in the file are “Mac” style.

@kzcaitec what editor did you use to make this file and how did you save the it?


#6

I use Matlab and save it as .mod file.


#7

Indeed. After pasting without format, the error is gone.Thanks for your attention.