%% cgg2c.dyn % Claida, Gali, Gertler two country NK open economy model, JME 2002 % Parameter names correpsond to version in Chapter 9 of Monetary Theory % and Policy, 4th edition. % % Modified 7/27/2018 to distinguish between efficient output gap (output minus the efficient level) % and the flex-price output gap (output minus flex price output) that appears in the NKPC. % var xh, // Flex-price output gap, home xf, // Flex-price output gap, foreign xeh, // Output minus efficient output, home xef, // Output minus efficient output, foreign yflexh, // Flex-price output, home yflexf, // Flex-price output, foreign yeffh, // Efficient output, home yefff, // Efficient output, foreign yh, // Actual output, home yf, // Actual output, foreign pih, // Domestic price inflation pif, // Foreign price inflation picpih, // CPI inflation, home picpif, // CPI, foreign s, // Terms of trade sgap, // s - sflex ph, // Domestic price level pf, // Foreign price level (in foreign currency) e, // Nominal exchange rate ih, // Nominal interest rate, home if, // Nominal interest rate, foreign rnh, // Natural interest rate, home rnf, // Natural interest rate, foreign ah, // Domestic productivity shock af, // Foreign productivity shock vh, // Monetary policy shock, home vf, // Monetary policy shock, foreign muwh, // Cost Push Shock, home muwf; // Cost Push Shock, foreign varexo e_ah, // Productivity, home e_af, // Productivity, foreign e_vh, // Policy, home e_vf, // Policy, foreign e_muwh, // Cost shock, home e_muwf; // Cost shock, foreign parameters savefig, // = 1 to save figure lambda, // Weight on output gap in loss function beta, // Subjective discount factor sigma, // Consumption index coef. in utility function eta, // Inverse labor supply elasticitys xi, // Price elasticity, individual goods alphah, // Used to compare home policies, = 0 for opt disc, == 1 for Taylor rule alphach, // Opt commitment if alpha = 0 and alphac = 1 alphaf, // Used to compare foreing policies, = 0 for opt disc, == 1 for Taylor rule alphacf, // Opt commitment if alpha = 0 and alphac = 1 gamma, // Degree of openness omega, // Calvo parameter (Fraction of firms not adjusting prices) kappa, // Inflation elasticity w.r.t output gap // Home Taylor rule parameters phi_pih, // Taylor Rule Coef. on domestic inflation phi_cpih, // Taylor coefficient on cpi inflation phi_xh, // Taylor Rule Coef. on output-gap phi_eh, // Taylor Rule Coef. on exchange rate // Foreign taylor rule parameters phi_pif, // Taylor Rule Coef. on domestic inflation phi_cpif, // Taylor coefficient on cpi inflation phi_xf, // Taylor Rule Coef. on output-gap phi_ef, // Taylor Rule Coef. on exchange rate // Domestic shocks rho_ah // Tech. Shock persistance rho_vh, // Monetary Policy Shock persistance rho_muwh, // Cost push shock persistance sde_ah, // Standard deviation for tech. shock sde_vh, // Standard deviation for mon. policy shock sde_muwh, // Stadard deviation for cost push shock // Foreign shocks rho_af, // Tech. Shock persistance rho_vf, // Monetary Policy Shock persistance rho_muwf, // Cost push shock persistance sde_af, // Standard deviation for tech. shock sde_vf, // Standard deviation for mon. policy shock sde_muwf; // Stadard deviation for cost push shock // parameter values from Gali-Monacelli (REStud 2005) savefig = 0; // set to = 1 to save figure alphah = 0; alphach = 0; alphaf = 0; alphacf = 0; beta = 0.99; sigma = 1; eta = 3; xi = 6; gamma = 0.4; omega = 0.75; kappa = (1-omega)*(1-omega*beta)/omega; lambda = (sigma+eta)*kappa/xi; phi_pih= 1.5; phi_cpih= 0; phi_xh = 0; phi_eh = 0; phi_pif= 1.5; phi_cpif= 0; phi_xf = phi_xh; phi_ef = -phi_eh; rho_ah = 0.66; sde_ah = 0.71; rho_vh = 0.75; sde_vh = 0.25; // Standard deviation for mon. policy shock rho_muwh = 0.7; sde_muwh = 0.25; // Stadard deviation for cost push shock rho_af = rho_ah; rho_vf = rho_vh; rho_muwf = rho_muwh; sde_af = sde_ah; sde_vf = sde_vh; sde_muwf = sde_muwh; model(linear); xh = yh - yflexh; xeh = yh - yeffh; (eta+sigma - gamma*(sigma-1))*yflexh = -gamma*(sigma-1)*yflexf + (1+eta)*ah - muwh; (eta+sigma - gamma*(sigma-1))*yeffh = -gamma*(sigma-1)*yefff + (1+eta)*ah; xh = xh(+1) - (1/sigma)*(ih - picpih(+1) - rnh) - gamma*(s(+1) - s); rnh = sigma*(yflexh(+1) - yflexh); pih = beta*pih(+1) + kappa*(eta+sigma-gamma*(sigma-1))*xh; // Taylor rule //ih - phi_pih*pih + phi_cpih*picpih + phi_xh*xh + phi_eh*e + vh; 0 = alphah*(ih - phi_pih*pih - phi_cpih*picpih - phi_xh*xh - phi_eh*e - vh) + (1-alphah)*(kappa*(eta+gamma+sigma*(1-gamma))*pih + lambda*(xeh - alphach*xeh(-1))); // Optimal discretion //kappa*(eta+gamma+sigma*(1-gamma))*pih + lambda*xeh = 0; ph = ph(-1) + pih; picpih = pih + gamma*(s - s(-1)); // Foreign economy xf = yf - yflexf; xef = yf - yefff; (eta+sigma-(1-gamma)*(sigma-1))*yflexf = -(1-gamma)*(sigma-1)*yflexh + (1+eta)*af - muwf; (eta+sigma-(1-gamma)*(sigma-1))*yefff = -(1-gamma)*(sigma-1)*yeffh + (1+eta)*af; xf = xf(+1) - (1/sigma)*(if - picpif(+1) - rnf) + (1 - gamma)*(s(+1) - s); rnf = sigma*(yflexf(+1) - yflexf); pif = beta*pif(+1) + kappa*(eta+sigma - (1-gamma)*(sigma-1))*xf; //if = phi_pif*pif + phi_cpif*picpi + phi_xf*xf + phi_ef*e + vf; 0 = alphaf*(if - phi_pif*pif - phi_cpif*picpif - phi_xf*xf - phi_ef*e - vf) + (1-alphaf)*(kappa*(eta+gamma+sigma*(1-gamma))*pif + lambda*(xef - alphacf*xef(-1))); pf = pf(-1) + pif; picpif = pif - (1-gamma)*(s - s(-1)); s = yh - yf; sgap = xh - xf; e = s + ph - pf; ah = rho_ah*ah(-1) + e_ah; vh = rho_vh*vh(-1) + e_vh; muwh = rho_muwh*muwh(-1) + e_muwh; af = rho_af*af(-1) + e_af; vf = rho_vf*vf(-1) + e_vf; muwf = rho_muwf*muwf(-1) + e_muwf; end; steady; check; shocks; //var e_ah = (sde_ah)^2; //var e_vh = (sde_vh)^2; var e_muwh = (sde_muwh)^2; var e_af = (sde_af)^2; var e_vf = (sde_vf)^2; var e_muwf = (sde_muwf)^2; end; ///////////////////////////////////////// /* planner_objective pih^2 + lambda*xeh^2; ramsey_policy(planner_discount=0.99, order = 1,irf=15) ; //discretionary_policy(irf=40,planner_discount=0.99,order=1,instruments=(i),nograph,solve_maxit=10000); OOPT.MODELS.oo2CNK_ramsey = oo_; save OOPT_2CNK_ramsey; */ ///////////////////////////////////////// ///////////////////////////////////////// // Computing Theoretical Moments and IRF's //////////////////////////////////////// // Taylor rules alphah = 1; alphach = 0; alphaf = 1; alphacf = 0; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK_TR = oo_; save OOPT_2CNK_TR; // Optimal discretion alphah = 0; alphach = 0; alphaf = 0; alphacf = 0; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK = oo_; save OOPT_2CNK; // Optimal commitment alphah = 0; alphach = 1; alphaf = 0; alphacf = 1; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK_1 = oo_; save OOPT_2CNK_1; // Fixed exchange rate alphah = 1; phi_cpi = 0; phi_pih = 1.5; phi_eh = 10; alphaf = 0; check; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK_2 = oo_; save OOPT_2CNK_2; // CPI inflation rule alphah = 1; phi_cpi = 1.5; phi_pih = 0; phi_eh = 0; alphaf = 0; check; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK_3 = oo_; save OOPT_2CNK_3; /* // Nash, optimal discretion in both alphah = 0; alphach = 0; alphaf = 0; alphach = 0; check; stoch_simul(order=1,ar=1,irf=20,nograph,noprint); OOPT.MODELS.oo2CNK_4 = oo_; save OOPT_2CNK_4; */ //////////////////////////////////////////////// // Plotting Impulse-Response functions // This part uses the plot_comp function in order to do multiple IRFS graphs. //////////////////////////////////////// // Figure 1 of chapter 9 OOPT.NN=12; OOPT.plot_color={':dr' '-ok' ':*b'} OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={ 'oo2CNK' 'oo2CNK_1' 'oo2CNK_2'}; OOPT.legend_models={ 'Optimal discretion' 'Optimal commitment' 'Fixed exchange rate'} OOPT.list_endo={'xeh' 'pih' 'picpih' 's' 'ph' 'e' }; OOPT.label_variables={'Efficent output gap' 'Domestic price inflation' 'CPI Inflation' 'Terms of trade' 'Domestic price level' 'Nominal exchange rate' }; plot_comp(OOPT); //print -depsc2 'C:\Users\CEW\Dropbox\4thedition\Chpt9\graphics_ch9\ch9_figure_1'; /* OOPT.NN=12; OOPT.plot_color={'-*b' ':xr' 'o-k'} OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={'oo2CNK_TR' 'oo2CNK' 'oo2CNK_1'}; OOPT.legend_models={'Taylor rules' 'Optimal discretion' 'Optimal commitment'} OOPT.list_endo={'xh' 'pih' 'pif' 'ih' 'if' 'picpih' 'ph' 's' 'e' }; OOPT.label_variables={'Dom. Output gap' 'Dom. Inflation' 'For. Inflation' 'Domestic nominal rate' 'Foreign nominal rate' 'Dom. CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); OOPT.NN=12; OOPT.plot_color={':dr' '-ok'} OOPT.shocks_names={'e_vh'}; OOPT.tit_shocks={'Monetary Policy Shock'}; OOPT.type_models={ 'oo2CNK_TR' 'oo2CNK_3'}; OOPT.legend_models={ 'Dom. inflation rule' 'CPI inflation rule'} OOPT.list_endo={'xh' 'pih' 'picpih' 's' 'ph' 'e' }; OOPT.label_variables={'Output gap' 'Domestic price inflation' 'CPI Inflation' 'Terms of trade' 'Domestic price level' 'Nominal exchange rate' }; plot_comp(OOPT); print -depsc2 'cgg2c_policyshock'; */ /* OOPT.NN=12; OOPT.plot_color={'-b' ':r' '-.k' } OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={'oo2CNK' 'oo2CNK_1' 'oo2CNK_2'}; OOPT.legend_models={ 'Taylor Rule' 'Optimal discretion' 'Optimal commitment' } OOPT.list_endo={'xh' 'pih' 'pif' 'ih' 'if' 'picpi' 'ph' 's' 'e' }; OOPT.label_variables={'Domestic Output gap' 'Domestic Inflation' 'Foreign Inflation' 'Domestic Nominal Rate' 'Foreign Nominal Rate' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); OOPT.NN=12; OOPT.plot_color={'-b' ':r' '-.k' 'og'} OOPT.shocks_names={'e_muwf'}; OOPT.tit_shocks={'Foreign Cost Shock'}; OOPT.type_models={'oo2CNK' 'oo2CNK_1' 'oo2CNK_2' 'oo2CNK_3'}; OOPT.legend_models={ 'Taylor Rule' 'Optimal discretion' 'Optimal commitment' 'Fixed Exchange Rate'} OOPT.list_endo={'xh' 'pih' 'picpi' 's' 'p' 'e' }; //OOPT.list_endo={'xh' 'pih' 'pif' 'ih' 'if' 'picpi' 'ph' 's' 'e' }; OOPT.label_variables={'Domestic Output gap' 'Domestic Inflation' 'CPI Inflation' 'Terms of Trade' 'Domestic price level' 'Nominal exchange rate' }; //OOPT.label_variables={'Domestic Output gap' 'Domestic Inflation' 'Foreign Inflation' 'Domestic Nominal Rate' 'Foreign Nominal Rate' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); //print -depsc2 'cgg2c_muwf_polices'; OOPT.NN=12; OOPT.plot_color={'-b' ':r' } OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={ 'oo2CNK_1' 'oo2CNK_4'}; OOPT.legend_models={ 'H opt disc, F TR' 'Both Optimal discretion' } OOPT.list_endo={'xh' 'pih' 'pif' 'ih' 'if' 'picpi' 'ph' 's' 'e' }; OOPT.label_variables={'Domestic Output gap' 'Domestic Inflation' 'Foreign Inflation' 'Domestic Nominal Rate' 'Foreign Nominal Rate' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); OOPTT.NN=12; OOPT.plot_color={'-b' ':r'} OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={'oo2CNK_1'}; OOPT.legend_models={'Taylor Rule'} OOPT.list_endo={'xh' 'pih' 'pif' 'ih' 'if' 'picpi' 'ph' 's' 'e' }; OOPT.label_variables={'H Output gap' 'H Inflation' 'F Inflation' 'Domestic i' 'Foreign i' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); OOPT.NN=12; OOPT.plot_color={'-b' ':r'} OOPT.shocks_names={'e_muwf'}; OOPT.tit_shocks={'Foreign Cost Shock'}; OOPT.type_models={'oo2CNK'}; OOPT.legend_models={'Optimal discretion'} OOPT.list_endo={'xh' 'xf' 'ih' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'H Output gap' 'F Output Gap' 'Domestic i' 'Foreign i' 'Dom. Inflation' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' }; plot_comp(OOPT); OOPT.NN=12; OOPT.plot_color={'-b' ':r'} OOPT.shocks_names={'e_muwh'}; OOPT.tit_shocks={'Domestic Cost Shock'}; OOPT.type_models={'oo2CNK' 'oo2CNK_1'}; OOPT.legend_models={'Dom. Infl. Target' 'CPI Infl Target'} OOPT.list_endo={'xf' 'xh' 'ih' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'Output' 'Output Gap' 'Nominal interest rate' 'Dom. Inflation' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' 'Real exchange rate'}; plot_comp(OOPT); */ /* OOPT.NN=12; OOPT.plot_color={'-b' ':r' '-.g'} OOPT.shocks_names={'e_a'}; OOPT.tit_shocks={'Productivity Shock'}; OOPT.type_models={'ooSOE' 'ooSOE_1' 'ooSOE_2'}; OOPT.legend_models={'Dom. Inflation' 'CPI Inflation' 'Nominal Exch. Rate'} OOPT.list_endo={'y' 'x' 'i' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'Output' 'Output Gap' 'Nominal interest rate' 'Dom. Inflation' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' 'Real exchange rate'}; plot_comp(OOPT); if savefig == 1 print -depsc2 'gmsoe_ch9_baseline'; end OOPT.NN=12; OOPT.plot_color={'--k' ':k' '-.k' 'o-k'} OOPT.shocks_names={'e_a'}; OOPT.tit_shocks={'Productivity Shock'}; OOPT.type_models={'ooSOE' 'ooSOE_1' 'ooSOE_2' 'ooSOE_3'}; OOPT.legend_models={'Dom. Inflation' 'CPI Inflation' 'Nominal Exch. Rate' 'Optimal'} OOPT.list_endo={'y' 'x' 'i' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'y' 'x' 'i' 'domestic inflation' 'cpi inflation' 'dom. price level' 's' 'e' 'q'}; plot_comp(OOPT); //if savefig == 1 //print -depsc2 'gmsoe_ch9_e_a'; //end OOPT.NN=12; OOPT.plot_color={'o-b' 'b--' 'r--' 'd-r'}; OOPT.shocks_names={'e_af'}; OOPT.tit_shocks={'Foreign Income Shock'}; OOPT.type_models={'oo2CNK_TR' 'oo2CNK' 'oo2CNK_2' 'oo2CNK_3'}; OOPT.legend_models={'Taylor rule' 'Opt disc' 'CPI Infl Target' 'Fixed exch rate'} OOPT.list_endo={'y' 'x' 'i' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'Output' 'Output Gap' 'Nominal interest rate' 'Domestic Inflation' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' 'Real exchange rate'}; plot_comp(OOPT); OOPT.NN=12; OOPT.plot_color={'d-r'}; OOPT.shocks_names={'e_af'}; OOPT.tit_shocks={'Foreign Income Shock'}; OOPT.type_models={'oo2CNK_3'}; OOPT.legend_models={'Taylor rule' 'Opt disc' 'CPI Infl Target' 'Fixed exch rate'} OOPT.list_endo={'y' 'x' 'i' 'pih' 'picpi' 'ph' 's' 'e' 'q'}; OOPT.label_variables={'Output' 'Output Gap' 'Nominal interest rate' 'Domestic Inflation' 'CPI Inflation' 'Domestic price level' 'Terms of Trade' 'Nominal exchange rate' 'Real exchange rate'}; plot_comp(OOPT); */