tholden / dynareOBC

A toolkit for implementing occasionally binding constraints in Dynare.
GNU General Public License v3.0
48 stars 35 forks source link

Stochastic simulation Problem #6

Closed yaoyao2116 closed 6 years ago

yaoyao2116 commented 6 years ago

Dear Dr. Holden,

Thanks for your dynareOBC package.

I try to simulate a small open NK model with ZLB, with options: dynareOBC MC20180615.mod nocubature skipfirstsolutions=1 sparse

I always get a problem that each variable's IRF results are the same for every shocks. And I don't know how to fix this problem.

I attach my .mod. That will be really nice if you could help me.

Thank you very much!

yaoyao2116 commented 6 years ago

Sorry that I find I did not attach my code successfully, so I copy it directly here:

var Uc C G tauC tauW w pi Rbf Phi s q tauK Rk I PsiD PsiM piD piDstar x1D x2D mc yD piX piXstar x1X x2X yX PsiX piM piMstar x1M x2M PsiStar yM y A K L Z RER pistar Bf B tauP T R_tr qb qk R U welfare;

varexo sigma_A sigma_pistar sigma_Rbf sigma_Phi sigma_G sigma_qb sigma_qk;

parameters gamma psi beta delta phi alfam theta lamda v alpha eta rho_A rho_pistar rho_Rbf rho_Phi rho_G rho_qb rho_qk tauC_bar tauW_bar tauP_bar tauK_bar B_bar G_bar A_bar R_tr_bar piD_bar gamma_CB gamma_CG gamma_CA gamma_PB gamma_PG gamma_PA gamma_KB gamma_KG gamma_KA gamma_WB gamma_WG gamma_WA gamma_pi;

gamma=0.39; psi=1; beta=0.99; delta=0.025; phi=3; alfam=0.3; theta=0.6; lamda=0.75; v=6; alpha=0.24; eta=0.6; rho_A=0.75; rho_pistar=0.8; rho_Rbf=0.75; rho_Phi=0.5; rho_G=0.95; rho_qb=0.2194; rho_qk=0.9; tauC_bar=0.05; tauW_bar=0.25; tauP_bar=0.25; tauK_bar=0.25; B_bar=0.5; G_bar=0.2; A_bar=1; R_tr_bar=1/beta; piD_bar=1; gamma_CB=1.5; gamma_CG=-0.25; gamma_CA=-0.1; gamma_PB=9.09; gamma_PG=-0.88; gamma_PA=-0.08; gamma_KB=1.25; gamma_KG=0.64; gamma_KA=-0.1; gamma_WB=1.75; gamma_WG=-0.5; gamma_WA=-0.45; gamma_pi=-9.53;

// Steady state expressed in terms of parameters

q_ss=1; qk_ss=1; %tauK=0.25; %Kollmann 2008 tauK_ss=tauK_bar; Rk_ss=((q_ss/beta-q_ss(1-delta))qk_ss^(-1)-delta*tauK_ss)/(1-tauK_ss);

pi_ss=1; qb_ss=1; R_ss=pi_ssbeta^(-1)qb_ss^(-1);

Phi_ss=1; Rbf_ss=qb_ss*R_ss;

PsiD_ss=1; piD_ss=pi_ss; piDstar_ss=((piD_ss^(1-v)-lamda)/(1-lamda))^(1/(1-v)); mc_ss=((v-1)piDstar_ssPsiD_ss(1-lamdabeta(piD_ss)^v))/(vpiD_ss(1-lamdabeta*piD_ss^(v-1)));

PsiX_ss=1; piX_ss=pi_ss; s_ss=1; piXstar_ss=((piX_ss^(1-v)-lamda)/(1-lamda))^(1/(1-v)); mc_ss=((v-1)piXstar_ssPsiX_sss_ss(1-lamdabeta(piX_ss)^v))/(vpiX_ss(1-lamdabetapiX_ss^(v-1)));

PsiM_ss=1; piM_ss=pi_ss; piMstar_ss=((piM_ss^(1-v)-lamda)/(1-lamda))^(1/(1-v)); PsiStar_ss=((v-1)piMstar_ssPsiM_ss(1-lamdabetapiM_ss^v))/(vpiM_sss_ss(1-lamdabetapiM_ss^(v-1))); pistar_ss=pi_ss;

A_ss=A_bar; w_ss=(A_ssmc_ss(Rk_ss/alpha)^(-alpha))^(1/(1-alpha))*(1-alpha);

%tauW=0.25; %Kollmann 2008 tauW_ss=tauW_bar; Uc_ss=psi/((1-tauW_ss)*w_ss);

%tauC=0.05; %Uhlig 2010 tauC_ss=tauC_bar; %G=0.2; %Kollmann 2008 G_ss=G_bar; C_ss=(Uc_ss(1+tauC_ss))^(-1)-gammaG_ss;

KL_ss=(w_ss/Rk_ss)*(alpha/(1-alpha));

K_ss=((1-alfam)(C_ss+G_ss)+(PsiStar_ss/PsiX_ss)^(eta))/(A_ss(KL_ss)^(alpha-1)-delta*(1-alfam)); L_ss=K_ss/KL_ss;

y_ss=A_ssK_ssKL_ss^(alpha-1); I_ss=deltaK_ss; Z_ss=C_ss+I_ss+G_ss; yD_ss=(1-alfam)Z_ss; yX_ss=(PsiX_ss/PsiStar_ss)^(-eta); yM_ss=alfam*Z_ss;

RER_ss=s_ss*PsiStar_ss;

Bf_ss=pistar_ss(PsiX_ssyX_ss-PsiStar_ssyM_ss)(pistar_ss-Phi_ss*Rbf_ss)^(-1);

%B=0.5; %Kollmann 2008 B_ss=B_bar; %tauP=0.25; %Kollmann 2008 tauP_ss=tauP_bar; T_ss=G_ss+qb_ssR_ssB_ss-B_sspi_ss-tauC_ssC_ss-tauP_ssy_ss-tauK_ss(Rk_ss-delta)K_ss-tauW_ssw_ss*L_ss;

x1D_ss=(Uc_ssmc_ssyD_ss)/(1-lamdabetapiD_ss^v); x2D_ss=(Uc_ssPsiD_ssyD_ss)/(1-lamdabetapiD_ss^(v-1));

x1X_ss=(Uc_ssmc_ssyX_ss)/(1-lamdabetapiX_ss^v); x2X_ss=(Uc_ssPsiX_sss_ssyX_ss)/(1-lamdabeta*piX_ss^(v-1));

x1M_ss=(Uc_sss_ssPsiStar_ssyM_ss)/(1-lamdabetapiM_ss^v); x2M_ss=(Uc_ssyM_ssPsiM_ss)/(1-lamdabeta*piM_ss^(v-1));

R_tr_ss=R_tr_bar+gamma_pi*(piD_ss-piD_bar)/piD_bar;

U_ss=log(C_ss+gammaG_ss)-psiL_ss; welfare_ss=(1/(1-beta))*U_ss;

model;

%marginal utility Uc=(1/(C+gammaG))(1/(1+tauC));

%F.O.C. on labour Uc=psi/((1-tauW)*w);

%F.O.C. on domestic bonds(Euler equation) Uc=betaUc(+1)R*qb/pi(+1);

%F.O.C. on foreign bonds Uc=betaUc(+1)RbfPhis(+1)/(s*pi(+1));

%F.O.C. on capital q=betaUc(+1)/Uc(((1-tauK(+1))Rk(+1)+deltatauK(+1))qk+q(+1)(1-delta));

%F.O.C. on investment 1=q-qphi0.5(I/I(-1)-1)^2-qphi(I/I(-1)-1)I/I(-1)+betaUc(+1)/Ucq(+1)phi(I(+1)/I-1)*(I(+1)/I)^2;

%domestic price index(CPI) 1=(1-alfam)PsiD^(1-theta)+alfamPsiM^(1-theta);

%domestic intermediate firms %%price evolution piD=((1-lamda)piDstar^(1-v)+lamda)^(1/(1-v)); %%reset price piDstar=v/(v-1)piDx1D/x2D; x1D=UcmcyD+lamdabeta(piD(+1)^v)x1D(+1); x2D=UcPsiDyD+lamdabeta(piD(+1)^(v-1))*x2D(+1);

%exported intermediate firms %%price evolution: piX=((1-lamda)piXstar^(1-v)+lamda)^(1/(1-v)); %%reset price piXstar=v/(v-1)piXx1X/x2X; x1X=UcmcyX+lamdabeta(piX(+1)^v)x1X(+1); x2X=UcyXsPsiX+lamdabeta(piX(+1)^(v-1))x2X(+1);

%imported intermediate firms %%price evolution piM=((1-lamda)piMstar^(1-v)+lamda)^(1/(1-v)); %%reset price piMstar=v/(v-1)piMx1M/x2M; x1M=UcsPsiStaryM+lamdabeta(piM(+1)^v)x1M(+1); x2M=UcyMPsiM+lamdabeta(piM(+1)^(v-1))x2M(+1);

%production function y=AK(-1)^(alpha)L^(1-alpha);

%outputs y=yD+yX; yD=(1-alfam)PsiD^(-theta)Z; yM=alfamPsiM^(-theta)Z; yX=(PsiX/PsiStar)^(-eta);

%relative prices PsiStar=pistar/piPsiStar(-1); PsiD=piD/piPsiD(-1); PsiX=piX/piPsiX(-1); PsiM=piM/piPsiM(-1);

%factor prices w=(1-alpha)mcy/L; w=(1-alpha)/alphaK/LRk;

%marginal cost mc=(1/A)(Rk/alpha)^(alpha)(w/(1-alpha))^(1-alpha);

%aggregate resource Z=C+I+G;

%capital accumulation K=(1-delta)K(-1)+(1-phi0.5(I/I(-1)-1)^2)I;

%net foreign assst position PsiXyX-PsiStaryM=Bf-Phi(-1)Rbf(-1)Bf(-1)/pistar;

%real exchange rate RER=s*PsiStar;

%government budget constraint G+R(-1)qb(-1)B=B(+1)pi(+1)+tauCC+tauPy+tauK(Rk-delta)K+tauWw*L+T;

%distortionary taxes tauC-tauC_bar=gamma_CB(B-B_bar)+gamma_CG(G-G_bar)+gamma_CA(A-A_bar); tauP-tauP_bar=gamma_PB(B-B_bar)+gamma_PG(G-G_bar)+gamma_PA(A-A_bar); tauK-tauK_bar=gamma_KB(B-B_bar)+gamma_KG(G-G_bar)+gamma_KA(A-A_bar); tauW-tauW_bar=gamma_WB(B-B_bar)+gamma_WG(G-G_bar)+gamma_WA(A-A_bar);

%Taylor Rule R_tr-R_tr_bar=gamma_pi*(piD-piD_bar)/piD_bar;

%financial friction %Rb=(1+wb)R; %Rb=qbR;

%Zero Lower Bound R=max(1,R_tr);

%exogenous processes A=(1-rho_A)A+rho_AA(-1)+sigma_A; pistar=(1-rho_pistar)pistar+rho_pistarpistar(-1)+sigma_pistar; Rbf=(1-rho_Rbf)Rbf+rho_RbfRbf(-1)+sigma_Rbf; Phi=(1-rho_Phi)Phi+rho_PhiPhi(-1)+sigma_Phi; G=(1-rho_G)G+rho_GG(-1)+sigma_G; %qb=1+wb; qb=(1-rho_qb)qb+rho_qbqb(-1)+sigma_qb; %qk=1-wk; qk=(1-rho_qk)qk+rho_qkqk(-1)+sigma_qk;

%welfare U=log(C+gammaG)-psiL; welfare=U+beta*welfare(+1); end;

initval; Uc=Uc_ss; C=C_ss; G=G_ss; tauC=tauC_ss; tauW=tauW_ss; w=w_ss; pi=pi_ss; Rbf=Rbf_ss; Phi=Phi_ss; s=s_ss; q=q_ss; tauK=tauK_ss; Rk=Rk_ss; I=I_ss; PsiD=PsiD_ss; PsiM=PsiM_ss; piD=piD_ss; piDstar=piDstar_ss; x1D=x1D_ss; x2D=x2D_ss; mc=mc_ss; yD=yD_ss; piX=piX_ss; piXstar=piXstar_ss; x1X=x1X_ss; x2X=x2X_ss; yX=yX_ss; PsiX=PsiX_ss; piM=piM_ss; piMstar=piMstar_ss; x1M=x1M_ss; x2M=x2M_ss; PsiStar=PsiStar_ss; yM=yM_ss; y=y_ss; A=A_ss; K=K_ss; L=L_ss; Z=Z_ss; RER=RER_ss; pistar=pistar_ss; Bf=Bf_ss; B=B_ss; tauP=tauP_ss; T=T_ss; qb=qb_ss; qk=qk_ss; R_tr=R_tr_ss; R=R_ss; U=U_ss; welfare=welfare_ss;

end;

steady; check;

shocks; var sigma_A; stderr 0.01; var sigma_pistar; stderr 0.005; var sigma_Rbf; stderr 0.004; var sigma_Phi; stderr 0.033; var sigma_G; stderr 0.01; var sigma_qb; stderr 1.0292; var sigma_qk; stderr 0.0775; end;

stoch_simul(order=2,periods=0,irf=40,pruning);

tholden commented 6 years ago

Sorry for the delayed response. I haven't run your code yet, but with skipfirstsolutions=1 your impulse responses are going to be driven by the multiplicity effect, which will probably make them all look pretty similar (the size of movement needed to get a self fulfilling jump to the bound will far outweigh the shocks you're using here). Try running without the skipfirstsolutions option and tell me if you still get this issue.

yaoyao2116 commented 6 years ago

Thanks for your reply! I have tried to run without skipfirstsolutions option, but they are still look the same and there are no dot lines (ZLB has not been hit in any of the IRFs) shown in IRFs at the same time.

I have tried to put these shocks in shocks block one by one to see if there is any different. With some of the shocks I can get the IRFs, but others will receive message:“Impossible problem encountered. Try increasing TimeToEscapeBounds, or reducing the magnitude of shocks.” even though I increase TimeToEscapeBounds, I still cannot get the results. For those shocks which I can get IRFs, the IRFs still look similar for every variables, but different shocks I put in shocks block run with different IRFs.

Could you please give me some advice to fix these problems? Thank you very much and looking forward to your reply!

tholden commented 6 years ago

There are a number of problems with this MOD file.

  1. Your response to inflation is negative. This is very odd, and will massively increase the chances of non-existence of a solution.
  2. Your Taylor rule is almost certainly wrong. Subtracting steady states from interest rates and inflation is appropriate when they are in logs. When they are in levels, you need to divide by the steady-state.
  3. As stated in the help file, performance is usually better if the ZLB on nominal interest rates is imposed on the log of interest rates, not on the level.
  4. The model has multiple exact unit roots. These mean that no perturbation solution can be valid, and they absolutely prevent the calculation of the pruned perturbation solutions used by DynareOBC. You need to diagnose the sources of these unit roots and either change the model, or transform the endogenous variables until they are no longer present.

Until these fundamental issues with the model are fixed, I don't think there's going to be much further help I can give you. (Indeed, given you've made mistakes like the above, there are probably others as well. You perhaps ought to go back to a very basic model and work up slowly.)

It does not seem that there's a DynareOBC bug here. Consequently, I'm closing this issue.