# Residuals of the static equations: NaN

Dear all,
I am getting two NaN when I run my .mod.

Equation number 1 : NaN
Equation number 2 : NaN
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0

Thanks

Aldo

You have

so that in

``` WELFARESS = (XSS^(1-sig_c)/(1-sig_c) - LC_BAR*LCSS^(1+sig_l_C)/(1+sig_l_C)- LD_BAR*(1-LCSS)^(1+sig_l_D)/(1+sig_l_D))/(1-betta); ```
you are dividing by 0. Put differently, the log utility case is not really nested in your code.

Thanks a lot dear jpfeifer.

Greetings

Aldo

Hello I have a similar problem, with the following code and i cant figure out what is wrong.

//Parameterisation
var s c y k h R w A klr;
varexo e_a e_s;
parameters beta sigma chi alpha delta rho_s sigma_s rho_a sigma_a gamma;

beta=0.99;
sigma=2;
chi=1.5;
alpha=(1/3);
delta=0.05;
rho_s=0.5;
sigma_s=0.005;
rho_a=0.85;
sigma_a=0.001;
gamma=0;

//Model
model;
c+k=wh+(R-delta)k(-1); //Resource constraint
log(A)=rho_a
log(A(-1))+e_a; //Laws of motion
log(s)=rho_s
log(s(-1))+e_s; //Laws of motion
y = Ak(-1)^alphah^(1-alpha); //Output
klr=k/h; //Capital-labour ratio
w=chi/((s/c(-1)^gamma)(c/c(-1)^gamma)^(-sigma)); //Wages
beta
((s(+1)/c^gamma)(c(+1)/c^gamma))/((s/c(-1)^gamma)(c/c(-1)^gamma))(R(+1)-delta)=1; //Euler
alpha
A*k(-1)^(alpha-1)h^(1-alpha)=R-1; //Profit Maximization Capital
A
(1-alpha)*h^(-alpha)*k(-1)^(alpha)=w; //Profit Maximization Labour
end;

initval;

A=1;
s=1;
R=(1/beta)+delta;
klr=((beta^(-1)+delta)^(1/alpha-1))(alpha)^(1/1-alpha);
c=((1-alpha)chi^(1-alpha)(klr)^(alpha))^(1/-gamma-sigma+gamma
sigma);
k=((1-alpha)chi^(-1)(beta^(-1)+delta)^(alpha/1-alpha)(alpha)^(alpha/1-alpha))^(1/-gamma-sigma+sigmagamma)/((beta^(-1)+delta)alpha^(-1)-delta);
y=((beta^(-1)+delta)/alpha)^(alpha/1-alpha)
(((1-alpha)chi^(-1)(beta^(-1)+delta)^(alpha/1-alpha)alpha^(alpha/1-alpha))^(1/-gamma-sigma+sigmagamma)/((beta^(-1)+delta)alpha^(-1)-delta))((beta^(-1)+delta)/alpha)^(1/1-alpha);
h=(((1-alpha)chi^(-1)(beta^(-1)+delta)^(alpha/1-alpha)alpha^(alpha/1-alpha))^(1/-gamma-sigma+sigmagamma)/((beta^(-1)+delta)alpha^(-1)-delta))((beta^(-1)+delta)/alpha)^(1/1-alpha);
w=(1-alpha)*((beta^(-1)+delta)/alpha)^(alpha/alpha-1);
end;

resid;

//Shocks
shocks;
var e_a=sigma_a^2;
var e_s=sigma_s^2;
end;

//Computation
stoch_simul(order=1, irf =20, periods =250) s c y k h R w;Q2.mod (1.8 KB)

You have lines like

``````c=((1-alpha)*chi^(-1)*(klr)^(alpha))^(1/-gamma-sigma+gamma*sigma);
``````

The exponent contains

``````1/-gamma
``````

With `gamma=0` the becomes `-Inf`. My guess is that you are missing brackets.

Thank you very much, that was the problem. I fixed the problem and it runs however, it says that there is an infinite element in equation 7 when deriving for A, however there is no A in equation 7, therefore it should be 0.

I would need to see the new file.

No need, Figured it out, thanks a lot for your help Professor.