| 1 |
/* |
| 2 |
* This file replicates the model studied in: |
| 3 |
* Lawrence J. Christiano, Roberto Motto and Massimo Rostagno (2007): |
| 4 |
* "Notes on Ramsey-Optimal Monetary Policy", Section 2 |
| 5 |
* The paper is available at http://faculty.wcas.northwestern.edu/~lchrist/d16/d1606/ramsey.pdf |
| 6 |
* |
| 7 |
* Notes: |
| 8 |
* |
| 9 |
* - This mod-file tests OSR with a planner_objective |
| 10 |
* |
| 11 |
* - Due to divine coincidence, the first best policy involves fully stabilizing inflation |
| 12 |
* and thereby the output gap. As a consequence, the optimal inflation feedback coefficient |
| 13 |
* in a Taylor rule would be infinity. The OSR command therefore estimates it to be at the |
| 14 |
* upper bound defined via osr_params_bounds. |
| 15 |
* |
| 16 |
* - The mod-file also allows to conduct estimation under Ramsey policy by setting the |
| 17 |
* Estimation_under_Ramsey switch to 1. |
| 18 |
* |
| 19 |
* This implementation was written by Johannes Pfeifer. |
| 20 |
* |
| 21 |
* If you spot mistakes, email me at [email protected] |
| 22 |
* |
| 23 |
* Please note that the following copyright notice only applies to this Dynare |
| 24 |
* implementation of the model. |
| 25 |
*/ |
| 26 |
|
| 27 |
/* |
| 28 |
* Copyright © 2019 Dynare Team |
| 29 |
* |
| 30 |
* This is free software: you can redistribute it and/or modify |
| 31 |
* it under the terms of the GNU General Public License as published by |
| 32 |
* the Free Software Foundation, either version 3 of the License, or |
| 33 |
* (at your option) any later version. |
| 34 |
* |
| 35 |
* It is distributed in the hope that it will be useful, |
| 36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 38 |
* GNU General Public License for more details. |
| 39 |
* |
| 40 |
* For a copy of the GNU General Public License, |
| 41 |
* see <https://www.gnu.org/licenses/>. |
| 42 |
*/ |
| 43 |
|
| 44 |
//**********Define which monetary policy setup to use *********** |
| 45 |
|
| 46 |
@#ifndef Ramsey |
| 47 |
@#define Ramsey=0 |
| 48 |
@#endif |
| 49 |
|
| 50 |
//**********Define whether to use distorted steady state*********** |
| 51 |
|
| 52 |
var C $C$ (long_name='Consumption') |
| 53 |
pi $\pi$ (long_name='Gross inflation') |
| 54 |
h $h$ (long_name='hours worked') |
| 55 |
Z $Z$ (long_name='TFP') |
| 56 |
R $R$ (long_name='Net nominal interest rate') |
| 57 |
log_C ${\ln C}$ (long_name='Log Consumption') |
| 58 |
log_h ${\ln h}$ (long_name='Log hours worked') |
| 59 |
pi_ann ${\pi^{ann}}$ (long_name='Annualized net inflation') |
| 60 |
R_ann ${R^{ann}}$ (long_name='Annualized net nominal interest rate') |
| 61 |
r_real ${r^{ann,real}}$ (long_name='Annualized net real interest rate') |
| 62 |
y_nat ${y^{nat}}$ (long_name='Natural (flex price) output') |
| 63 |
y_gap ${r^{gap}}$ (long_name='Output gap') |
| 64 |
; |
| 65 |
|
| 66 |
varexo epsilon ${\varepsilon}$ (long_name='TFP shock') |
| 67 |
; |
| 68 |
|
| 69 |
parameters beta ${\beta}$ (long_name='discount factor') |
| 70 |
theta ${\theta}$ (long_name='substitution elasticity') |
| 71 |
tau ${\tau}$ (long_name='labor subsidy') |
| 72 |
chi ${\chi}$ (long_name='labor disutility') |
| 73 |
phi ${\phi}$ (long_name='price adjustment costs') |
| 74 |
rho ${\rho}$ (long_name='TFP autocorrelation') |
| 75 |
@# if !defined(Ramsey) || Ramsey==0 |
| 76 |
pi_star ${\pi^*}$ (long_name='steady state inflation') |
| 77 |
alpha ${\alpha}$ (long_name='inflation feedback Taylor rule') |
| 78 |
@# endif |
| 79 |
; |
| 80 |
|
| 81 |
beta=0.99; |
| 82 |
theta=5; |
| 83 |
phi=100; |
| 84 |
rho=0.9; |
| 85 |
@# if !defined(Ramsey) || Ramsey==0 |
| 86 |
alpha=1.5; |
| 87 |
pi_star=1; |
| 88 |
@# endif |
| 89 |
tau=0; |
| 90 |
chi=1; |
| 91 |
|
| 92 |
model; |
| 93 |
[name='Euler equation'] |
| 94 |
1/(1+R)=beta*C/(C(+1)*pi(+1)); |
| 95 |
[name='Firm FOC'] |
| 96 |
(tau-1/(theta-1))*(1-theta)+theta*(chi*h*C/(exp(Z))-1)=phi*(pi-1)*pi-beta*phi*(pi(+1)-1)*pi(+1); |
| 97 |
[name='Resource constraint'] |
| 98 |
C*(1+phi/2*(pi-1)^2)=exp(Z)*h; |
| 99 |
[name='TFP process'] |
| 100 |
Z=rho*Z(-1)+epsilon; |
| 101 |
@#if !defined(Ramsey) || Ramsey==0 |
| 102 |
[name='Taylor rule'] |
| 103 |
R=pi_star/beta-1+alpha*(pi-pi_star); |
| 104 |
@#endif |
| 105 |
[name='Definition log consumption'] |
| 106 |
log_C=log(C); |
| 107 |
[name='Definition log hours worked'] |
| 108 |
log_h=log(h); |
| 109 |
[name='Definition annualized inflation rate'] |
| 110 |
pi_ann=4*log(pi); |
| 111 |
[name='Definition annualized nominal interest rate'] |
| 112 |
R_ann=4*R; |
| 113 |
[name='Definition annualized real interest rate'] |
| 114 |
r_real=4*log((1+R)/pi(+1)); |
| 115 |
[name='Definition natural output'] |
| 116 |
y_nat=exp(Z)*sqrt((theta-1)/theta*(1+tau)/chi); |
| 117 |
[name='output gap'] |
| 118 |
y_gap=log_C-log(y_nat); |
| 119 |
end; |
| 120 |
|
| 121 |
steady_state_model; |
| 122 |
Z=0; |
| 123 |
@# if !defined(Ramsey) || Ramsey==0 |
| 124 |
R=pi_star/beta-1; %only set this if not conditional steady state file for Ramsey |
| 125 |
@# endif |
| 126 |
pi=(R+1)*beta; |
| 127 |
C=sqrt((1+1/theta*((1-beta)*(pi-1)*pi-(tau-1/(theta-1))*(1-theta)))/(chi*(1+phi/2*(pi-1)^2))); |
| 128 |
h=C*(1+phi/2*(pi-1)^2); |
| 129 |
log_C=log(C); |
| 130 |
log_h=log(h); |
| 131 |
pi_ann=4*log(pi); |
| 132 |
R_ann=4*R; |
| 133 |
r_real=4*log((1+R)/pi); |
| 134 |
y_nat=sqrt((theta-1)/theta*(1+tau)/chi); |
| 135 |
y_gap=log_C-log(y_nat); |
| 136 |
end; |
| 137 |
|
| 138 |
@# if defined(Ramsey) && Ramsey==1 |
| 139 |
//define initial value of instrument for Ramsey |
| 140 |
initval; |
| 141 |
R=1/beta-1; |
| 142 |
end; |
| 143 |
@# endif |
| 144 |
|
| 145 |
shocks; |
| 146 |
var epsilon = 0.01^2; |
| 147 |
end; |
| 148 |
|
| 149 |
@# if !defined(Ramsey) || Ramsey==0 |
| 150 |
|
| 151 |
//starting value for OSR parameter |
| 152 |
alpha = 1.5; |
| 153 |
|
| 154 |
//define planner objective, which corresponds to utility function of agents |
| 155 |
planner_objective log(C)-chi/2*h^2; |
| 156 |
stoch_simul(order=2,irf=20,periods=0) pi_ann log_h R_ann log_C Z r_real; |
| 157 |
|
| 158 |
//define OSR parameters to be optimized |
| 159 |
osr_params alpha; |
| 160 |
|
| 161 |
//starting value for OSR parameter |
| 162 |
alpha = 1.5; |
| 163 |
|
| 164 |
//define bounds for OSR during optimization |
| 165 |
osr_params_bounds; |
| 166 |
alpha, 1, 200; |
| 167 |
end; |
| 168 |
|
| 169 |
//compute OSR and provide output |
| 170 |
osr(opt_algo=9,planner_discount=beta) pi_ann log_h R_ann log_C Z r_real; |
| 171 |
evaluate_planner_objective; |
| 172 |
|
| 173 |
@# else |
| 174 |
//use Ramsey optimal policy |
| 175 |
|
| 176 |
//define planner objective, which corresponds to utility function of agents |
| 177 |
planner_objective log(C)-chi/2*h^2; |
| 178 |
|
| 179 |
//set up Ramsey optimal policy problem with interest rate R as the instrument,... |
| 180 |
// defining the discount factor in the planner objective to be the one of private agents |
| 181 |
ramsey_model(instruments=(R),planner_discount=beta,planner_discount_latex_name=$\beta$); |
| 182 |
|
| 183 |
//conduct stochastic simulations of the Ramsey problem |
| 184 |
stoch_simul(order=1,irf=20,periods=0) pi_ann log_h R_ann log_C Z r_real; |
| 185 |
evaluate_planner_objective; |
| 186 |
@# endif |
| 187 |
|
| 188 |
//Compare results to Ramsey results |
| 189 |
if max(abs(-51.15717757-oo_.planner_objective_value.unconditional))>2e-6 |
| 190 |
error('Planner objective value does not match.') |
| 191 |
end |
| 192 |
if max(abs(200-oo_.osr.optim_params.alpha))>1e-6 |
| 193 |
error('Optimal parameter value does not match.') |
| 194 |
end |