| 1 |
/* |
| 2 |
* This file implements the New Keynesian model with price and wage rigidities under optimal policy |
| 3 |
* with commitment (Ramsey) of Jordi Galí (2015): Monetary Policy, Inflation, and the Business Cycle, Princeton |
| 4 |
* University Press, Second Edition, Chapter 6.4 |
| 5 |
* |
| 6 |
* THIS MOD-FILE REQUIRES DYNARE 4.6 OR HIGHER |
| 7 |
* |
| 8 |
* Notes: |
| 9 |
* - all model variables are expressed in deviations from steady state, i.e. in contrast to |
| 10 |
* to the chapter, the nominal interest rate, natural output, and the natural real wage are not in log-levels, but rather mean 0 |
| 11 |
* - in the LOM for the discount rate shock z the shock enters with a minus sign in this mod-file to generate the |
| 12 |
* IRF to a -0.5% shock |
| 13 |
* |
| 14 |
* This implementation was written by Johannes Pfeifer. In case you spot mistakes, |
| 15 |
* email me at [email protected] |
| 16 |
* |
| 17 |
* Please note that the following copyright notice only applies to this Dynare |
| 18 |
* implementation of the model. |
| 19 |
*/ |
| 20 |
|
| 21 |
/* |
| 22 |
* Copyright © 2020 Dynare Team |
| 23 |
* |
| 24 |
* This is free software: you can redistribute it and/or modify |
| 25 |
* it under the terms of the GNU General Public License as published by |
| 26 |
* the Free Software Foundation, either version 3 of the License, or |
| 27 |
* (at your option) any later version. |
| 28 |
* |
| 29 |
* It is distributed in the hope that it will be useful, |
| 30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 |
* GNU General Public License for more details. |
| 33 |
* |
| 34 |
* For a copy of the GNU General Public License, |
| 35 |
* see <https://www.gnu.org/licenses/>. |
| 36 |
*/ |
| 37 |
|
| 38 |
%define whether to use interest rate or money growth rate rule |
| 39 |
@#define money_growth_rule=1 |
| 40 |
|
| 41 |
var pi_p ${\pi^p}$ (long_name='price inflation') |
| 42 |
y_gap ${\tilde y}$ (long_name='output gap') |
| 43 |
y_nat ${y^{nat}}$ (long_name='natural output') //(in contrast to the textbook defined in deviation from steady state) |
| 44 |
y ${y}$ (long_name='output') |
| 45 |
yhat ${\hat y}$ (long_name='output deviation from steady state') |
| 46 |
r_nat ${r^{nat}}$ (long_name='natural interest rate') |
| 47 |
r_real ${r^r}$ (long_name='real interest rate') |
| 48 |
i ${i}$ (long_name='nominal interrst rate') |
| 49 |
n ${n}$ (long_name='hours worked') |
| 50 |
m_real ${(m-p)}$ (long_name='real money stock') |
| 51 |
m_growth_ann ${\Delta m}$ (long_name='money growth annualized') |
| 52 |
m_nominal ${m}$ (long_name='nominal money stock') |
| 53 |
nu ${\nu}$ (long_name='AR(1) monetary policy shock process') |
| 54 |
a ${a}$ (long_name='AR(1) technology shock process') |
| 55 |
r_real_ann ${r^{r,ann}}$ (long_name='annualized real interest rate') |
| 56 |
i_ann ${i^{ann}}$ (long_name='annualized nominal interest rate') |
| 57 |
r_nat_ann ${r^{nat,ann}}$ (long_name='annualized natural interest rate') |
| 58 |
pi_p_ann ${\pi^{p,ann}}$ (long_name='annualized inflation rate') |
| 59 |
z ${z}$ (long_name='AR(1) preference shock process') |
| 60 |
p ${p}$ (long_name='price level') |
| 61 |
w ${w}$ (long_name='nominal wage') |
| 62 |
c ${c}$ (long_name='consumption') |
| 63 |
w_real $\omega$ (long_name='real wage') |
| 64 |
w_gap ${\tilde \omega}$ (long_name='real wage gap') |
| 65 |
pi_w ${\pi^w}$ (long_name='wage inflation') |
| 66 |
w_nat ${w^{nat}}$ (long_name='natural real wage') |
| 67 |
mu_p ${\mu^p}$ (long_name='markup') |
| 68 |
pi_w_ann ${\pi^{w,ann}}$ (long_name='annualized wage inflation rate') |
| 69 |
; |
| 70 |
|
| 71 |
varexo eps_a ${\varepsilon_a}$ (long_name='technology shock') |
| 72 |
eps_nu ${\varepsilon_\nu}$ (long_name='monetary policy shock') |
| 73 |
eps_z ${\varepsilon_z}$ (long_name='preference shock innovation') |
| 74 |
; |
| 75 |
|
| 76 |
parameters alppha ${\alpha}$ (long_name='capital share') |
| 77 |
betta ${\beta}$ (long_name='discount factor') |
| 78 |
rho_a ${\rho_a}$ (long_name='autocorrelation technology shock') |
| 79 |
rho_nu ${\rho_{\nu}}$ (long_name='autocorrelation monetary policy shock') |
| 80 |
rho_z ${\rho_{z}}$ (long_name='autocorrelation monetary demand shock') |
| 81 |
siggma ${\sigma}$ (long_name='inverse EIS') |
| 82 |
varphi ${\varphi}$ (long_name='inverse Frisch elasticity') |
| 83 |
phi_pi ${\phi_{\pi}}$ (long_name='inflation feedback Taylor Rule') |
| 84 |
phi_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule') |
| 85 |
eta ${\eta}$ (long_name='semi-elasticity of money demand') |
| 86 |
epsilon_p ${\epsilon_p}$ (long_name='demand elasticity goods') |
| 87 |
theta_p ${\theta_p}$ (long_name='Calvo parameter prices') |
| 88 |
epsilon_w ${\epsilon_w}$ (long_name='demand elasticity labor services') |
| 89 |
theta_w ${\theta_w}$ (long_name='Calvo parameter wages') |
| 90 |
lambda_p ${\lambda_p}$ (long_name='composite parameter Phillips Curve') |
| 91 |
lambda_w ${\lambda_w}$ (long_name='composite parameter wage Phillips Curve') |
| 92 |
; |
| 93 |
%---------------------------------------------------------------- |
| 94 |
% Parametrization, p. 67 and p. 113-115 |
| 95 |
%---------------------------------------------------------------- |
| 96 |
siggma = 1; |
| 97 |
varphi=5; |
| 98 |
phi_pi = 1.5; |
| 99 |
phi_y = 0.125; |
| 100 |
theta_p=3/4; |
| 101 |
rho_nu =0.5; |
| 102 |
rho_z = 0.5; |
| 103 |
rho_a = 0.9; |
| 104 |
betta = 0.99; |
| 105 |
eta =3.77; %footnote 11, p. 115 |
| 106 |
alppha=1/4; |
| 107 |
epsilon_p=9; |
| 108 |
|
| 109 |
epsilon_w=4.5; |
| 110 |
theta_w=3/4; |
| 111 |
%---------------------------------------------------------------- |
| 112 |
% First Order Conditions |
| 113 |
%---------------------------------------------------------------- |
| 114 |
|
| 115 |
model(linear); |
| 116 |
//Composite parameters |
| 117 |
#Omega=(1-alppha)/(1-alppha+alppha*epsilon_p); %defined on page 166 |
| 118 |
#psi_n_ya=(1+varphi)/(siggma*(1-alppha)+varphi+alppha); %defined on page 171 |
| 119 |
#psi_n_wa=(1-alppha*psi_n_ya)/(1-alppha); %defined on page 171 |
| 120 |
#aleph_p=alppha*lambda_p/(1-alppha); %defined on page 172 |
| 121 |
#aleph_w=lambda_w*(siggma+varphi/(1-alppha)); %defined on page 172 |
| 122 |
[name='New Keynesian Phillips Curve eq. (18)'] |
| 123 |
pi_p=betta*pi_p(+1)+aleph_p*y_gap+lambda_p*w_gap; |
| 124 |
[name='New Keynesian Wage Phillips Curve eq. (22)'] |
| 125 |
pi_w=betta*pi_w(+1)+aleph_w*y_gap-lambda_w*w_gap; |
| 126 |
[name='Dynamic IS Curve eq. (22)'] |
| 127 |
y_gap=-1/siggma*(i-pi_p(+1)-r_nat)+y_gap(+1); |
| 128 |
[name='Definition natural rate of interest eq. (24)'] |
| 129 |
r_nat=-siggma*psi_n_ya*(1-rho_a)*a+(1-rho_z)*z; |
| 130 |
w_gap=w_gap(-1)+pi_w-pi_p-(w_nat-w_nat(-1)); |
| 131 |
[name='Definition natural wage, eq (16)'] |
| 132 |
w_nat=psi_n_wa*a; |
| 133 |
[name='Definition markup'] |
| 134 |
mu_p=-alppha/(1-alppha)*y_gap-w_gap; |
| 135 |
[name='Definition real wage gap, p. 171'] |
| 136 |
w_gap=w_real-w_nat; |
| 137 |
[name='Definition real interest rate'] |
| 138 |
r_real=i-pi_p(+1); |
| 139 |
[name='Definition natural output, eq. (20)'] |
| 140 |
y_nat=psi_n_ya*a; |
| 141 |
[name='Definition output gap'] |
| 142 |
y_gap=y-y_nat; |
| 143 |
[name='Monetary policy shock'] |
| 144 |
nu=rho_nu*nu(-1)+eps_nu; |
| 145 |
[name='TFP shock'] |
| 146 |
a=rho_a*a(-1)+eps_a; |
| 147 |
[name='Production function, p. 171'] |
| 148 |
y=a+(1-alppha)*n; |
| 149 |
[name='Preference shock, p. 54'] |
| 150 |
z = rho_z*z(-1) - eps_z; |
| 151 |
[name='Money growth (derived from eq. (4))'] |
| 152 |
m_growth_ann=4*(y-y(-1)-eta*(i-i(-1))+pi_p); |
| 153 |
[name='Real money demand (eq. 4)'] |
| 154 |
m_real=y-eta*i; |
| 155 |
[name='Annualized nominal interest rate'] |
| 156 |
i_ann=4*i; |
| 157 |
[name='Annualized real interest rate'] |
| 158 |
r_real_ann=4*r_real; |
| 159 |
[name='Annualized natural interest rate'] |
| 160 |
r_nat_ann=4*r_nat; |
| 161 |
[name='Annualized inflation'] |
| 162 |
pi_p_ann=4*pi_p; |
| 163 |
[name='Annualized wage inflation'] |
| 164 |
pi_w_ann=4*pi_w; |
| 165 |
[name='Output deviation from steady state'] |
| 166 |
yhat=y-steady_state(y); |
| 167 |
[name='Definition price level'] |
| 168 |
pi_p=p-p(-1); |
| 169 |
[name='resource constraint, eq. (12)'] |
| 170 |
y=c; |
| 171 |
[name='definition real wage'] |
| 172 |
w_real=w-p; |
| 173 |
[name='definition real wage'] |
| 174 |
m_nominal=m_real+p; |
| 175 |
|
| 176 |
|
| 177 |
end; |
| 178 |
|
| 179 |
steady_state_model; |
| 180 |
lambda_p=(1-theta_p)*(1-betta*theta_p)/theta_p*((1-alppha)/(1-alppha+alppha*epsilon_p)); %defined on page 166 |
| 181 |
lambda_w=(1-theta_w)*(1-betta*theta_w)/(theta_w*(1+epsilon_w*varphi)); %defined on page 170 |
| 182 |
end; |
| 183 |
%---------------------------------------------------------------- |
| 184 |
% define shock variances |
| 185 |
%--------------------------------------------------------------- |
| 186 |
|
| 187 |
|
| 188 |
shocks; |
| 189 |
var eps_a = 1; |
| 190 |
var eps_z = 1; |
| 191 |
end; |
| 192 |
|
| 193 |
|
| 194 |
%---------------------------------------------------------------- |
| 195 |
% generate IRFs for technology shock under optimal policy, replicates Figures 6.3, p. 182 |
| 196 |
%---------------------------------------------------------------- |
| 197 |
//planner objective, uses lambda_w and lambda_p updated in steady_state_model-block |
| 198 |
planner_objective 0.5*((siggma+(varphi+alppha)/(1-alppha))*y_gap^2+ epsilon_p/lambda_p*pi_p^2+epsilon_w*(1-alppha)/lambda_w*pi_w^2); |
| 199 |
|
| 200 |
ramsey_model(instruments=(i),planner_discount=betta, planner_discount_latex_name = $\delta$); |
| 201 |
stoch_simul(order=1,irf=16,noprint) y_gap pi_p_ann pi_w_ann w_real; |
| 202 |
evaluate_planner_objective; |
| 203 |
|
| 204 |
oo_baseline=oo_; |
| 205 |
|
| 206 |
%flexible wage case |
| 207 |
set_param_value('theta_w',0.0000000001); |
| 208 |
set_param_value('theta_p',3/4); |
| 209 |
stoch_simul(order=1,irf=16,noprint) y_gap pi_p_ann pi_w_ann w_real; |
| 210 |
evaluate_planner_objective; |
| 211 |
oo_flexible_wages=oo_; |
| 212 |
|
| 213 |
%flexible price case |
| 214 |
set_param_value('theta_w',3/4) |
| 215 |
set_param_value('theta_p',0.000000001) |
| 216 |
stoch_simul(order=1,irf=16,noprint) y_gap pi_p_ann pi_w_ann w_real; |
| 217 |
evaluate_planner_objective; |
| 218 |
oo_flexible_prices=oo_; |
| 219 |
|
| 220 |
|
| 221 |
figure('Name','Dynamic Responses to a technology shock under optimal policy') |
| 222 |
subplot(2,2,1) |
| 223 |
plot(1:options_.irf,oo_baseline.irfs.y_gap_eps_a,'-o',1:options_.irf,oo_flexible_wages.irfs.y_gap_eps_a,'-d',1:options_.irf,oo_flexible_prices.irfs.y_gap_eps_a,'-s') |
| 224 |
ylim([-0.1 0.1]) |
| 225 |
title('Output gap') |
| 226 |
ll=legend('baseline','flexible wages','flexible prices'); |
| 227 |
set(ll,'Location','SouthEast'); |
| 228 |
subplot(2,2,2) |
| 229 |
plot(1:options_.irf,oo_baseline.irfs.pi_p_ann_eps_a,'-o',1:options_.irf,oo_flexible_wages.irfs.pi_p_ann_eps_a,'-d',1:options_.irf,oo_flexible_prices.irfs.pi_p_ann_eps_a,'-s') |
| 230 |
title('Price Inflation') |
| 231 |
subplot(2,2,3) |
| 232 |
plot(1:options_.irf,oo_baseline.irfs.pi_w_ann_eps_a,'-o',1:options_.irf,oo_flexible_wages.irfs.pi_w_ann_eps_a,'-d',1:options_.irf,oo_flexible_prices.irfs.pi_w_ann_eps_a,'-s') |
| 233 |
title('Wage inflation') |
| 234 |
subplot(2,2,4) |
| 235 |
plot(1:options_.irf,oo_baseline.irfs.w_real_eps_a,'-o',1:options_.irf,oo_flexible_wages.irfs.w_real_eps_a,'-d',1:options_.irf,oo_flexible_prices.irfs.w_real_eps_a,'-s') |
| 236 |
title('Real wage') |
| 237 |
|
| 238 |
|
| 239 |
%---------------------------------------------------------------- |
| 240 |
% generate first row of Table 6.1, p. 186 |
| 241 |
%---------------------------------------------------------------- |
| 242 |
shocks; |
| 243 |
var eps_a = 1; |
| 244 |
end; |
| 245 |
set_param_value('theta_w',3/4); |
| 246 |
set_param_value('theta_p',3/4); |
| 247 |
|
| 248 |
stoch_simul(order=1,irf=16,noprint) y_gap y_gap pi_p pi_w; |
| 249 |
oo_baseline=oo_; |
| 250 |
|
| 251 |
y_gap_pos=strmatch('y_gap',var_list_ ,'exact'); |
| 252 |
pi_p_pos=strmatch('pi_p',var_list_ ,'exact'); |
| 253 |
pi_w_pos=strmatch('pi_w',var_list_ ,'exact'); |
| 254 |
|
| 255 |
%read out current parameter values |
| 256 |
par.alppha=M_.params(strmatch('alppha',M_.param_names,'exact')); |
| 257 |
par.epsilon_p=M_.params(strmatch('epsilon_p',M_.param_names,'exact')); |
| 258 |
par.epsilon_w=M_.params(strmatch('epsilon_w',M_.param_names,'exact')); |
| 259 |
par.siggma=M_.params(strmatch('siggma',M_.param_names,'exact')); |
| 260 |
par.varphi=M_.params(strmatch('varphi',M_.param_names,'exact')); |
| 261 |
par.lambda_w=M_.params(strmatch('lambda_w',M_.param_names,'exact')); |
| 262 |
par.lambda_p=M_.params(strmatch('lambda_p',M_.param_names,'exact')); |
| 263 |
|
| 264 |
variance.y_gap=oo_.var(y_gap_pos,y_gap_pos); |
| 265 |
variance.pi_p=oo_.var(pi_p_pos,pi_p_pos); |
| 266 |
variance.pi_w=oo_.var(pi_w_pos,pi_w_pos); |
| 267 |
L=0.5*((par.siggma+(par.varphi+par.alppha)/(1-par.alppha))*variance.y_gap+ par.epsilon_p/par.lambda_p*variance.pi_p+par.epsilon_w*(1-par.alppha)/par.lambda_w*variance.pi_w) |
| 268 |
|
| 269 |
labels={'sigma(pi_p)';'sigma(pi_w)';'sigma(tilde y)';'L'}; |
| 270 |
headers={' ';'Optimal'}; |
| 271 |
values=[sqrt([variance.pi_p;variance.pi_w;variance.y_gap]);L]; |
| 272 |
options_.noprint=0; |
| 273 |
dyntable(options_,'Evaluation of Simple Rules',headers,labels,values,size(labels,2)+2,4,3) |
| 274 |
|
| 275 |
if any(isnan(values)) |
| 276 |
error('Parameter updating in steady state went wrong') |
| 277 |
end |