Thanks . I will check on it.
I am trying to run the two-sector model code from Jaimovich and rebelo(2009) that is provided in AER website. I did not change anything from their code but it did not run . It gives the error that
Error using trustnleqn (line 28)
Objective function is returning undefined values at initial point. FSOLVE cannot continue.
Error in fsolve (line 368)
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msgData]=...
Error in Two_Sector_Model (line 568)
Solution=fsolve('ss_JMCB',VECguess,options,pars);
Error in dynare (line 180)
evalin('base',fname) [/quote]
The all initial values are zero. I am wondering why the program does not run.
Jaimovich and Rebelo(2009) code is following:
- Code: Select all
periods=500;
var C, Hc, Hi, Ic, Ii, Kc, Ki,X,PI,DELTA_C_VAR,DELTA_I_VAR,U_C_VAR,U_I_VAR,
Y, H, I, Yc,Yi,
LAMBDAC_var,LAMBDAI_var,MIUC_var,MIUI_var,PHI_var,zc,zi,M,zc2,zc3,
OMEGAc,OMEGAi,zi2; //Endogenous variables; note that z in endogenous
varexo ec,ei,ei2; //Exogenous variables, they must be iid
parameters alpha_c, alpha_i beta, gamma, sigma,SDP,gammai,delta2,HStarget,HStarget_C,HStarget_I,theta,gamman;
parameters Kval1,Kval2,KStarget_I,IStarget_I,IStarget,KStarget_C,CStarget;
parameters XStarget,xsi1,xsi2,xsi3,xsi,MStarget;
parameters Lambda_C, Miu_C, P_I,YStarget,Miu_I,Lambda_I,PHIS1,PHIS2,PHIStarget,LAMBDAS1,LAMBDAS2,LAMBDAStargetC;
parameters GPc,GDPc,G1c,GPUSc,GPi,GDPi,G1i,GPUS;
parameters UStargeti,UStargetc,rho,Utilcoef;
parameters PIs,Suuport,Pergodic,Xstd,datagammaq,gammaq,gtarget,V,theta,delta,gamma,SDP,Utilcoef,alpha;
parameters sigma,p1,betax,beta,gammabeta,a1,a2,HStarget,UStarget,Acoef,Axc,Kval1,Kval2,KStarget;
parameters IStarget,CStarget,XStarget,YStarget,xsi1,xsi2,xsi3,xsi,MStarget,PHIS1,PHIS2,PHIS,LAMBDAS1,LAMBDAS2;
parameters LAMBDAS,MIUS,GPUS,GP,GDP,G1,CS,cs,IS,is,KS,ks,HS,hs,US,us,XS,xs,MS,ms;
parameters ys,ys2,ws,rs2,A1c,A2x,A3u,A5c,A5o,A6c,A6n,A6x,B1miu,B1k,B1lambda,D1delta,D1u,D1n,F1,C4k,E4d,B6phi,E6;
parameters DynN_1,DynN_2,gamman,p1,IStarget_C,IStarget_I;
load my_parameters.mat;
theta=1.4;
gamma=0.001;
p1=1;
alpha=alpha_c;
Kval1=1/beta-(1-delta2);
Kval2=(1-alpha_i);
KStarget_I=HStarget_I/(Kval1/Kval2)^(1/alpha_i);
IStarget_I=KStarget_I*delta2;
IStarget=KStarget_I^(1-alpha_i)*HStarget_I^alpha_i;
IStarget_C=IStarget-IStarget_I;
KStarget_C=1/delta2*IStarget_C;
//
pars(1)=alpha_c;pars(2)=alpha_i;pars(3)=beta;
pars(4)=sigma;pars(5)=theta;pars(6)=delta2;
pars(7)=HStarget_I;pars(8)=KStarget_I;pars(9)=KStarget_C;
pars(10)=IStarget;pars(11)=gamma;
VECguess=[0.8*1/5]';
options=optimset('MaxIter',100000,'MaxFunEvals',1000000,'TolFun',1e-22);
Solution=fsolve('ss_JMCB',VECguess,options,pars);
HStarget_C=Solution(1);
CStarget=KStarget_C^(1-alpha_c)*HStarget_C^alpha_c;
HStarget=HStarget_C+HStarget_I;
XStarget=CStarget;
xsi1=theta*HStarget^(theta-1)/(alpha_c/HStarget_C);
xsi2=HStarget^theta*gamma;
xsi3=(1-beta*(1-gamma));
xsi=1/(xsi1+xsi2/xsi3);
MStarget=CStarget*(1-xsi*HStarget^theta);
Lambda_C=xsi*theta*HStarget^(theta-1)/(1-xsi*HStarget^theta)/alpha_c*(HStarget_C)/CStarget;
Miu_C=(1-alpha_c)*CStarget/KStarget_C*Lambda_C;
Miu_C=Miu_C/(1/beta-(1-delta2));
P_I=Miu_C/Lambda_C;
YStarget=CStarget+P_I*IStarget;
Miu_I=Miu_C;
Lambda_I=Miu_I;
PHIS1=MStarget^(-sigma)*xsi*HStarget^theta;
PHIS2=1-beta*(1-gamma);
PHIStarget=PHIS1/PHIS2;
LAMBDAS1=MStarget^(-sigma)*xsi*theta*HStarget^(theta-1)*XStarget;
LAMBDAS2=alpha_c*CStarget/HStarget_C;
LAMBDAStargetC=LAMBDAS1/LAMBDAS2;
UStargetc=1;
UStargeti=1;
GPUSc = (1-alpha_c)*CStarget/KStarget_C;
GPc = GPUSc/UStargetc;
GDPc=Utilcoef*GPUSc/UStargetc^2;
G1c=GPc*UStargetc/delta2;
GPUSi = (1-alpha_i)*IStarget/KStarget_I;
GPi = GPUSi/UStargeti;
GDPi=Utilcoef*GPUSi/UStargeti^2;
G1i=GPi*UStargeti/delta2;
CS=CStarget;
MS=MStarget;ms=MS;
HS=HStarget;
XS=XStarget;
IS=IStarget;
model(linear);
// Definition M
MStarget*M - CStarget*C + xsi*HStarget^theta*XStarget*(theta*H+X);
//2) FOC N
MStarget^(-sigma)*(-sigma)*M-Lambda_C*LAMBDAC_var - gamma*PHIStarget*(PHI_var+(gamma-1)*C+(1-gamma)*X(-1));
//Sector Specific Hours worked - From IntraEuler equation
-sigma*M+(theta-1)*H+X-(LAMBDAC_var+Yc-Hc);
-sigma*M+(theta-1)*H+X-(LAMBDAI_var+Yi-Hi);
//FOC for investment specific
-LAMBDAI_var+MIUC_var
+beta*SDP*OMEGAc(+1)
-SDP*OMEGAc;
Ic-Ic(-1)-OMEGAc;
-LAMBDAI_var+MIUI_var
+beta*SDP*OMEGAi(+1)
-SDP*OMEGAi;
Ii-Ii(-1)-OMEGAi;
//FOC for sector specific capital
MIUC_var - beta*(1-delta2)*MIUC_var(+1) + beta*delta2*DELTA_C_VAR(+1)
-beta*(1-alpha_c)*CStarget/KStarget_C*(LAMBDAC_var(+1)+C(+1)-Kc);
MIUI_var - beta*(1-delta2)*MIUI_var(+1) + beta*delta2*DELTA_I_VAR(+1)
-beta*(1-alpha_i)*IStarget/KStarget_I*(LAMBDAI_var(+1)+I(+1)-Ki);
// X conditions
X - gamma*C - (1-gamma)*X(-1);
PHIStarget*PHI_var - beta*PHIStarget*(1-gamma)*(PHI_var(+1)+gamma*C(+1)-gamma*X)
-MStarget^(-sigma)*xsi*HStarget^theta*(-sigma*M+theta*H);
//Sector Specific law of motion for capital
Kc - (1-delta2)*Kc(-1) + delta2*DELTA_C_VAR - IStarget_C/KStarget_C*Ic;
Ki - (1-delta2)*Ki(-1) + delta2*DELTA_I_VAR - IStarget_I/KStarget_I*Ii;
//Sector Specific Produciotn Function
(1-alpha)*U_C_VAR+ alpha*Hc-Yc+(1-alpha)*Kc(-1)+zc;
Yc-C;
(1-alpha)*U_I_VAR +alpha*Hi-Yi +(1-alpha)*Ki(-1)+zi;
Yi-I;
LAMBDAC_var+C-(1+Utilcoef)*U_C_VAR-MIUC_var-Kc(-1);
LAMBDAI_var+I-(1+Utilcoef)*U_I_VAR-MIUI_var-Ki(-1);
delta2*DELTA_C_VAR-GPc*U_C_VAR;
delta2*DELTA_I_VAR-GPi*U_I_VAR;
PI-LAMBDAI_var+LAMBDAC_var;
YStarget*Y - CStarget*C - IStarget*(I+PI);
HStarget*H - HStarget_C*Hc - HStarget_I*Hi;
IStarget*I - IStarget_C*Ic - IStarget_I*Ii;
//Exogneous
// zc=rho*zc(-1)+ec;
// zi=rho*zi(-1)+ei;
zi2=rho*zi2(-1)+ei2;
zi=zc2(-1);
zc=0;//zc2(-1);
zc2=zc3(-1);
zc3=0.9999995*zc3(-1)+ec;
end;
initval; // initval defines either the initial conditions or the initial guesses to solve for steady state
C= 0;
Hc=0;
Hi=0;
Ic=0;
Ii=0;
Kc=0;
Ki=0;
zc3=0;
X=0;
Y=0;
H=0;
I=0;
Yc=0;
Yi=0;
LAMBDAC_var=0;
LAMBDAI_var=0;
MIUC_var=0;
MIUI_var=0;
DELTA_C_VAR=0;
DELTA_I_VAR=0;
U_C_VAR=0;
U_I_VAR=0;
zc=0;
zi=0;
zc2=0;
M=0;
OMEGAi=0;
OMEGAc=0;
PI=0;
ec=0;
ei=0;
PHI_var=0;
end;
steady (solve_algo = 2 ) ;
//check;
shocks;
var ec = 0.0001;
end;
stoch_simul (linear, order = 1,irf=20) Y H Hi Hc C I Ii Ic zc zi;
results=[Y_ec C_ec I_ec H_ec Hc_ec Hi_ec Ic_ec Ii_ec zc_ec zc_ec];
results(1:20,:)
//Ydif Cdif Idif Hdif Hcdif Hidif Icdif Iidif