# The same residual in two equations

Hi, I’ve been modifying Mr. Pfeifer’s code for the first model ( SGU_2003.mod) of Schmitt-Grohe & Uribe “Closing small open economy models” . I want to derive the model in levels from exponential model. But it gives me the same residual in 2 equations, How can I fix this issue?
Thank you so much.
Here is my code: sgu_level.mod (3.3 KB)

``````var  c h y i k a lambda  util d tb_y, ca_y, r beta_fun, eta;
varexo e;

parameters  gamma
omega
rho
delta
psi_1
alpha
phi
r_bar
d_bar ;

gamma  = 2;
omega  = 1.455;
psi_1  = 0.11;
alpha  = 0.32;
phi    = 0.028;
r_bar    = 0.04;
delta  = 0.1;
rho    = 0.42;
d_bar  = 0.7442;

model;

//1. eq4
d = (1+(r(-1)))*d(-1)- (y)+(c)+(i)+(phi/2)*((k)-(k(-1)))^2;

//2. eq5
(y) = (a)*((k(-1))^alpha)*((h)^(1-alpha));

//3. eq6
(k) = (i)+(1-delta)*(k(-1));

//4. eq8
(lambda)= beta_fun*(1+(r))*(lambda(+1));

//5. eq9
(lambda)=((c)-(((h)^omega)/omega))^(-gamma)-eta*(-psi_1*(1+(c)-omega^(-1)*(h)^omega)^(-psi_1-1));

//6. eq10
eta=-util(+1)+eta(+1)*beta_fun(+1);

//7. eq11
(((c)-((h)^omega)/omega)^(-gamma))*((h)^(omega-1)) +
eta*(-psi_1*(1+(c)-omega^(-1)*(h)^omega)^(-psi_1-1)*(-(h)^(omega-1))) = (lambda)*(1-alpha)*(y)/(h);

//8. eq12
(lambda)*(1+phi*((k)-(k(-1)))) = beta_fun*(lambda(+1))*(alpha*(y(+1))/(k)+1-delta+phi*((k(+1))-(k))) ;

//9. eq14
log(a) = rho*log(a(-1))+e;

//10. endogenous discount factor
beta_fun =(1+(c)-omega^(-1)*(h)^omega)^(-psi_1);

//11. utility function
util=((((c)-omega^(-1)*(h)^omega)^(1-gamma))-1)/(1-gamma);

//12. eq13
(r) = r_bar;

//13. trade balance to ouput ratio
tb_y = 1-(((c)+(i)+(phi/2)*((k)-(k(-1)))^2)/(y));

//14. current account to output ratio
ca_y = (1/(y))*(d(-1)-d);
end;

r     = r_bar;
d     = d_bar;
h     = (((1-alpha)*(alpha/(r_bar+delta))^(alpha/(1-alpha)))^(1/(omega-1)));
k     = h/(((r_bar+delta)/alpha)^(1/(1-alpha)));
y     = (((k)^alpha)*((h)^(1-alpha)));
i     = delta*(k);
c     = y-i-r_bar*d;
tb_y    = 1-(((c)+(i))/(y));
util=((((c)-omega^(-1)*(h)^omega)^(1-gamma))-1)/(1-gamma);
psi_1=-(1/(1+r_bar))/(((1+(c)-omega^(-1)*(h)^omega)));
beta_fun =(1+c-omega^(-1)*(h)^omega)^(-psi_1);
eta=-util/(1-beta_fun);
lambda=(((c)-(((h)^omega)/omega))^(-gamma)-eta*(-psi_1*(1+(c)-omega^(-1)*(h)^omega)^(-psi_1-1)));
a     = 1;
ca_y    = 0;
end;

resid(1);
check;