| 1 |
/* |
| 2 |
* This file implements the optimal monetary policy under commitment exercise |
| 3 |
* in Jordi Galí (2008): Monetary Policy, Inflation, and the Business Cycle, |
| 4 |
* Princeton University Press, Chapter 5.1.2 |
| 5 |
* |
| 6 |
* It demonstrates how to use the ramsey_model command of Dynare. |
| 7 |
* |
| 8 |
* Notes: |
| 9 |
* - all model variables are expressed in deviations from steady state, i.e. |
| 10 |
* in contrast to to the chapter, both the nominal interest rate and |
| 11 |
* natural output are not in log-levels, but rather mean 0 |
| 12 |
* |
| 13 |
* This implementation was written by Johannes Pfeifer. In case you spot mistakes, |
| 14 |
* email me at [email protected] |
| 15 |
* |
| 16 |
* Please note that the following copyright notice only applies to this Dynare |
| 17 |
* implementation of the model. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* Copyright © 2015-19 Johannes Pfeifer |
| 22 |
* |
| 23 |
* This is free software: you can redistribute it and/or modify |
| 24 |
* it under the terms of the GNU General Public License as published by |
| 25 |
* the Free Software Foundation, either version 3 of the License, or |
| 26 |
* (at your option) any later version. |
| 27 |
* |
| 28 |
* It is distributed in the hope that it will be useful, |
| 29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 |
* GNU General Public License for more details. |
| 32 |
* |
| 33 |
* For a copy of the GNU General Public License, |
| 34 |
* see <https://www.gnu.org/licenses/>. |
| 35 |
*/ |
| 36 |
|
| 37 |
|
| 38 |
var pi ${\pi}$ (long_name='inflation') |
| 39 |
y_gap ${tilde y}$ (long_name='output gap') |
| 40 |
y_nat ${y^{nat}}$ (long_name='natural output') |
| 41 |
y ${y}$ (long_name='output') |
| 42 |
r_e ${r^{e}}$ (long_name='efficient interest rate') |
| 43 |
y_e ${y^{nat}}$ (long_name='efficient output') |
| 44 |
x ${x}$ (long_name='welfare-relevant output gap') |
| 45 |
r_nat ${r^{nat}}$ (long_name='natural interest rate') |
| 46 |
r_real ${r^r}$ (long_name='real interest rate') |
| 47 |
i ${i}$ (long_name='nominal interest rate') |
| 48 |
n ${n}$ (long_name='hours worked') |
| 49 |
m_growth_ann ${\Delta m}$ (long_name='money growth') |
| 50 |
u ${u}$ (long_name='AR(1) cost push shock process') |
| 51 |
a ${a}$ (long_name='AR(1) technology shock process') |
| 52 |
r_real_ann ${r^{r,ann}}$ (long_name='annualized real interest rate') |
| 53 |
i_ann ${i^{ann}}$ (long_name='annualized nominal interest rate') |
| 54 |
r_nat_ann ${r^{nat,ann}}$ (long_name='annualized natural interest rate') |
| 55 |
pi_ann ${\pi^{ann}}$ (long_name='annualized inflation rate') |
| 56 |
p ${p}$ (long_name='price level') |
| 57 |
; |
| 58 |
|
| 59 |
varexo eps_a ${\varepsilon_a}$ (long_name='technology shock') |
| 60 |
eps_u ${\varepsilon_u}$ (long_name='monetary policy shock'); |
| 61 |
|
| 62 |
parameters alppha ${\alppha}$ (long_name='capital share') |
| 63 |
betta ${\beta}$ (long_name='discount factor') |
| 64 |
rho_a ${\rho_a}$ (long_name='autocorrelation technology shock') |
| 65 |
rho_u ${\rho_{u}}$ (long_name='autocorrelation cost push shock') |
| 66 |
siggma ${\sigma}$ (long_name='log utility') |
| 67 |
phi ${\phi}$ (long_name='unitary Frisch elasticity') |
| 68 |
phi_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule') |
| 69 |
eta ${\eta}$ (long_name='semi-elasticity of money demand') |
| 70 |
epsilon ${\epsilon}$ (long_name='demand elasticity') |
| 71 |
theta ${\theta}$ (long_name='Calvo parameter') |
| 72 |
; |
| 73 |
%---------------------------------------------------------------- |
| 74 |
% Parametrization, p. 52 |
| 75 |
%---------------------------------------------------------------- |
| 76 |
siggma = 1; |
| 77 |
phi=1; |
| 78 |
phi_y = .5/4; |
| 79 |
theta=2/3; |
| 80 |
rho_u = 0; |
| 81 |
rho_a = 0.9; |
| 82 |
betta = 0.99; |
| 83 |
eta =4; |
| 84 |
alppha=1/3; |
| 85 |
epsilon=6; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
%---------------------------------------------------------------- |
| 90 |
% First Order Conditions |
| 91 |
%---------------------------------------------------------------- |
| 92 |
|
| 93 |
model(linear); |
| 94 |
//Composite parameters |
| 95 |
#Omega=(1-alppha)/(1-alppha+alppha*epsilon); //defined on page 47 |
| 96 |
#psi_n_ya=(1+phi)/(siggma*(1-alppha)+phi+alppha); //defined on page 48 |
| 97 |
#lambda=(1-theta)*(1-betta*theta)/theta*Omega; //defined on page 47 |
| 98 |
#kappa=lambda*(siggma+(phi+alppha)/(1-alppha)); //defined on page 49 |
| 99 |
#alpha_x=kappa/epsilon; //defined on page 96 |
| 100 |
#phi_pi=(1-rho_u)*kappa*siggma/(alpha_x)+rho_u; //defined on page 101 |
| 101 |
|
| 102 |
//1. Definition efficient interest rate, below equation (4) |
| 103 |
r_e=siggma*(y_e(+1)-y_e); |
| 104 |
|
| 105 |
//2. Definition efficient output |
| 106 |
y_e=psi_n_ya*a; |
| 107 |
|
| 108 |
//3. Definition linking various output gaps, bottom page 96 |
| 109 |
y_gap=x+(y_e-y_nat); |
| 110 |
|
| 111 |
//4. New Keynesian Phillips Curve eq. (2) |
| 112 |
pi=betta*pi(+1)+kappa*x + u; |
| 113 |
|
| 114 |
//5. Dynamic IS Curve eq. (4) |
| 115 |
x=-1/siggma*(i-pi(+1)-r_e)+x(+1); |
| 116 |
|
| 117 |
//6. Definition natural rate of interest eq. (23) |
| 118 |
r_nat=siggma*psi_n_ya*(a(+1)-a); |
| 119 |
|
| 120 |
//7. Definition real interest rate |
| 121 |
r_real=i-pi(+1); |
| 122 |
|
| 123 |
//8. Natural output |
| 124 |
y_nat=phi*a; |
| 125 |
|
| 126 |
//9. Definition output gap |
| 127 |
y_gap=y-y_nat; |
| 128 |
|
| 129 |
//10. cost push shock, equation (3) |
| 130 |
u=rho_u*u(-1)+eps_u; |
| 131 |
|
| 132 |
//11. TFP shock |
| 133 |
a=rho_a*a(-1)+eps_a; |
| 134 |
|
| 135 |
//12. Production function (eq. 13) |
| 136 |
y=a+(1-alppha)*n; |
| 137 |
|
| 138 |
//13. Money growth (derived from eq. (4)) |
| 139 |
m_growth_ann=4*(y-y(-1)-eta*(i-i(-1))+pi); |
| 140 |
|
| 141 |
//14. Annualized nominal interest rate |
| 142 |
i_ann=4*i; |
| 143 |
|
| 144 |
//15. Annualized real interest rate |
| 145 |
r_real_ann=4*r_real; |
| 146 |
|
| 147 |
//16. Annualized natural interest rate |
| 148 |
r_nat_ann=4*r_nat; |
| 149 |
|
| 150 |
//17. Annualized inflation |
| 151 |
pi_ann=4*pi; |
| 152 |
|
| 153 |
//18. Definition price level |
| 154 |
pi=p-p(-1); |
| 155 |
|
| 156 |
//19. Interest Rate Rule that implements optimal solution, eq. (10) |
| 157 |
% i=r_e+phi_pi*pi; |
| 158 |
end; |
| 159 |
|
| 160 |
%---------------------------------------------------------------- |
| 161 |
% define shock variances |
| 162 |
%--------------------------------------------------------------- |
| 163 |
|
| 164 |
shocks; |
| 165 |
var eps_u = 1; |
| 166 |
end; |
| 167 |
|
| 168 |
//planner objective using alpha_x expressed as function of deep parameters |
| 169 |
planner_objective pi^2 +(((1-theta)*(1-betta*theta)/theta*((1-alppha)/(1-alppha+alppha*epsilon)))*(siggma+(phi+alppha)/(1-alppha)))/epsilon*y_gap^2; |
| 170 |
|
| 171 |
ramsey_model(instruments=(i),planner_discount=betta); |
| 172 |
resid; |
| 173 |
stoch_simul(order=1,irf=13) x pi p u; |
| 174 |
|
| 175 |
verbatim; |
| 176 |
%% Check correctness |
| 177 |
Omega=(1-alppha)/(1-alppha+alppha*epsilon); %defined on page 47 |
| 178 |
lambda=(1-theta)*(1-betta*theta)/theta*Omega; %defined on page 47 |
| 179 |
kappa=lambda*(siggma+(phi+alppha)/(1-alppha)); %defined on page 49 |
| 180 |
alpha_x=kappa/epsilon; %defined on page 96 |
| 181 |
Psi=1/(kappa^2+alpha_x*(1-betta*rho_u)); %defined on page 99 |
| 182 |
Psi_i=Psi*(kappa*siggma*(1-rho_u)+alpha_x*rho_u); %defined on page 101 |
| 183 |
phi_pi=(1-rho_u)*kappa*siggma/(alpha_x)+rho_u; %defined on page 101 |
| 184 |
a_parameter=alpha_x/(alpha_x*(1+betta)+kappa^2); |
| 185 |
delta = (1-sqrt(1-4*betta*a_parameter^2))/(2*a_parameter*betta); |
| 186 |
|
| 187 |
p_irf(1)=delta/(1-delta*betta*rho_u); |
| 188 |
x_irf(1)=-kappa*delta/(alpha_x*(1-betta*delta*rho_u)); |
| 189 |
u_irf(1)=1; |
| 190 |
for ii=2:options_.irf |
| 191 |
u_irf(ii)=rho_u*u_irf(ii-1); |
| 192 |
p_irf(ii)=delta*p_irf(ii-1)+delta/(1-delta*betta*rho_u)*u_irf(ii); |
| 193 |
x_irf(ii)=delta*x_irf(ii-1)-kappa*delta/(alpha_x*(1-betta*delta*rho_u))*u_irf(ii); |
| 194 |
end |
| 195 |
pi_irf=diff([0 p_irf]); |
| 196 |
|
| 197 |
if max(abs(u_irf-oo_.irfs.u_eps_u))>1e-10 || max(abs(p_irf-oo_.irfs.p_eps_u))>1e-10 || max(abs(p_irf-oo_.irfs.p_eps_u))>1e-10 || max(abs(x_irf-oo_.irfs.x_eps_u))>1e-10 |
| 198 |
error('IRFs do not match theoretical ones') |
| 199 |
end |