Jaimovich and rebelo (2009)

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Jaimovich and rebelo (2009)

Postby Feroza » Thu Jun 02, 2016 5:55 pm

Hi,

I want to replicate Jaimovich and Rebelo (2009) : "News and Business Cyvle" paper. I include both temporary TFP and investment specific shocks . When I run the program it gives me the following error. I am not sure whether there are problems of defining my shocks or initial values.I tried different ways of writing shocks (all included in the codes) and many initial values. But it does not work. Also, how can I check whether my initial values are good or not?

An infinite element was encountered when trying to solve equation(s) 12
with respect to the variable(s): A.
The values of the endogenous variables when the problem was encountered were:
C 0.76
I 0.24
Y 1
K 10
N 0.31
X 0.76
U 0.8
A 1.002
Z 1.002
lam1 0
lam2 0
lam3 0
AUX_EXO_LAG_14_0 0
AUX_EXO_LAG_14_1 0
AUX_EXO_LAG_14_2 0
AUX_EXO_LAG_15_0 0
AUX_EXO_LAG_15_1 0
AUX_EXO_LAG_15_2 0


My code :
Code: Select all
var C I Y K N X U A Z lam1 lam2 lam3;

varexo e ez ei eiz;

parameters beta phi1 phi theta sigma gama alpha psi delta1 delta rhoe rhoz se sez si siz;

beta = 0.985;
psi=5.17;
sigma=1;
gama=0.001;
theta=1.4;
alpha=0.64;
%u=0.15;
phi1=0.5;
phi= 0.3;
delta1=0.15;
delta=0.0125;
rhoe=0.5;
rhoz=0.8;
se=0.66;
sez=0.33;
si=0.66;
siz=0.33;



model;

% wrt C
((C)-psi*((N)^theta)*(X))^(-sigma)+(lam1)*gama*(C)^(gama-1)*(X(-1))^(1-gama)=(lam2);

%wrt X;
(((C)-psi*((N)^theta)*(X))^(-sigma))*psi*(N)^theta +(lam1)= beta* ((lam1(+1))*(1-gama)*((C(+1))^gama)*(X)^(-gama));

%wrtN

(((C)-psi*((N)^theta)*(X))^(-sigma))*theta*psi*((N)^(theta-1))*(X)=(lam2)*alpha*((A)*((U)*(K(-1)))^(1-alpha))*(N)^(alpha-1);

%wrt U

(lam2)*(1-alpha)*(A)*((U)^-alpha)*((K(-1))^(1-alpha))*(N)^alpha= (lam3)*delta1*(K(-1));

%wrt Kt+1;
(lam3)=beta*(((lam2(+1)))*(1-alpha)*(A(+1))*((U(+1))^(1-alpha))*((K)^-alpha)*(N(+1))^alpha )+ (lam3)*(1-delta);

%wrt I
(lam2)*(1/exp(Z))=(lam3)*(1-phi*((I)/exp(I(-1)))-phi1*((I)/(I(-1))))+ beta*(lam3(+1))*phi1*((I(+1))/(I))^2;

%production function
(Y)=(A)*(((U)*(K(-1)))^(1-alpha))*(N)^alpha;

%Resource constraint
(Y)=(C)+(I/Z);

%Capital Accumulation
(K)=(I)*(1-phi*((I)/(I(-1))))+(1-delta)*(K(-1));

%X
(X)=((C)^gama)*(X(-1))^(1-gama);

A=rhoe*A(-1)+e+ei(-3);
%exp(A)=exp(A(-1))^rhoe*e;

Z=rhoz*Z(-1)+ei+eiz(-3);

%exp(Z)=exp(Z(-1))^rhoz*ei*eiz(-3);

end;

initval;
C=0.76;
I=0.24;
Y=1;
K=10;
N=0.31;
X=0.76;
U=0.8;
A=1.0025;
Z=1.0025;
lam1=0;
lam2=0;
lam3=0;

end;

shocks;
var e=se^2;
var ez=sez^2;
var ei=si^2;
var eiz=siz^2;
end;

stoch_simul(order=1,irf=15,nograph,periods=500,simul_replic=100);
Feroza
 
Posts: 7
Joined: Sun May 15, 2016 9:53 pm

Re: Jaimovich and rebelo (2009)

Postby jpfeifer » Fri Jun 03, 2016 7:49 am

You should have
Code: Select all
log(A)=rhoe*log(A(-1))+e+ei(-3);

or
Code: Select all
A=A(-1)^rhoe*exp(e)*exp(ei(-3));
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Jaimovich and rebelo (2009)

Postby Feroza » Fri Jun 03, 2016 1:50 pm

I tried it either way but it gives me the same error.
Feroza
 
Posts: 7
Joined: Sun May 15, 2016 9:53 pm

Re: Jaimovich and rebelo (2009)

Postby jpfeifer » Sun Jun 05, 2016 8:23 pm

The same of course applies to Z. After that, there is a problem in finding the steady state. I would recommend computing it analytically.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Jaimovich and rebelo (2009)

Postby Feroza » Thu Jun 09, 2016 3:40 am

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

Feroza
 
Posts: 7
Joined: Sun May 15, 2016 9:53 pm

Re: Jaimovich and rebelo (2009)

Postby jpfeifer » Sun Jun 12, 2016 6:23 pm

I will have a look at their files.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Jaimovich and rebelo (2009)

Postby Feroza » Mon Jun 13, 2016 8:03 pm

I got it . You have to fixed the parameters . Thanks a lot for your help.
Feroza
 
Posts: 7
Joined: Sun May 15, 2016 9:53 pm


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 8 guests