Debian Codegraph @

tests/optimal_policy/Ramsey/Ramsey_Example_estimation.mod

raw
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 * - This mod-files allows to simulate a simple New Keynesian Model with Rotemberg price
9 * adjustment costs under three different monetary policy arrangements:
10 * 1. a Taylor rule with a fixed inflation feedback coefficient alpha
11 * -> set the Optimal_policy switch to 0
12 * 2. a Taylor rule where the inflation feedback coefficient alpha is chosen
13 * optimally to minimize a quadratic loss function (optimal simple rule (OSR))
14 * -> set the Optimal_policy switch to 1 and the Ramsey switch to 0
15 * 3. fully optimal monetary under commitment (Ramsey)
16 * -> set the Optimal_policy switch to 1 and the Ramsey switch to 1
17 *
18 * - The Efficent_steady_state switch can be used to switch from an distorted steady state
19 * due to a monopolistic distortion to one where a labor subsidy counteracts this
20 * distortion. Note that the purely quadratic loss function in the OSR case does not capture
21 * the full welfare losses with a distorted steady state as there would be a linear term
22 * appearing.
23 *
24 * - This files shows how to use a conditional steady state file in the Ramsey case. It takes
25 * the value of the defined instrument R as given and then computes the rest of the steady
26 * state, including the steady state inflation rate, based on this value. The initial value
27 * of the instrument for steady state search must then be defined in an initval-block.
28 *
29 * - The optim_weights in the OSR case are based on a second order approximation to the welfare function
30 * as in Gali (2015). The relative weight between inflation and output gap volatility is essentially
31 * given by the slope of the New Keynesian Phillips Curve. Note that the linear terms that would be
32 * present in case of a distorted steady state need to be dropped for OSR.
33 *
34 * - Due to divine coincidence, the first best policy involves fully stabilizing inflation
35 * and thereby the output gap. As a consequence, the optimal inflation feedback coefficient
36 * in a Taylor rule would be infinity. The OSR command therefore estimates it to be at the
37 * upper bound defined via osr_params_bounds.
38 *
39 * - The mod-file also allows to conduct estimation under Ramsey policy by setting the
40 * Estimation_under_Ramsey switch to 1.
41 *
42 * This implementation was written by Johannes Pfeifer.
43 *
44 * If you spot mistakes, email me at [email protected]
45 *
46 * Please note that the following copyright notice only applies to this Dynare
47 * implementation of the model.
48 */
49
50 /*
51 * Copyright © 2019 Dynare Team
52 *
53 * This is free software: you can redistribute it and/or modify
54 * it under the terms of the GNU General Public License as published by
55 * the Free Software Foundation, either version 3 of the License, or
56 * (at your option) any later version.
57 *
58 * It is distributed in the hope that it will be useful,
59 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 * GNU General Public License for more details.
62 *
63 * For a copy of the GNU General Public License,
64 * see <https://www.gnu.org/licenses/>.
65 */
66
67 //**********Define which monetary policy setup to use ***********
68
69 @#ifndef Optimal_policy
70 @#define Optimal_policy=1
71 @#ifndef Ramsey
72 @#define Ramsey=1
73 @#endif
74 @#endif
75
76 //**********Define whether to use distorted steady state***********
77
78 @#ifndef Efficent_steady_state
79 @#define Efficent_steady_state=0
80 @#endif
81
82 @#ifndef Estimation_under_Ramsey
83 @#define Estimation_under_Ramsey=1
84 @#endif
85
86 var C $C$ (long_name='Consumption')
87 pi $\pi$ (long_name='Gross inflation')
88 h $h$ (long_name='hours worked')
89 Z $Z$ (long_name='TFP')
90 R $R$ (long_name='Net nominal interest rate')
91 log_C ${\ln C}$ (long_name='Log Consumption')
92 log_h ${\ln h}$ (long_name='Log hours worked')
93 pi_ann ${\pi^{ann}}$ (long_name='Annualized net inflation')
94 R_ann ${R^{ann}}$ (long_name='Annualized net nominal interest rate')
95 r_real ${r^{ann,real}}$ (long_name='Annualized net real interest rate')
96 y_nat ${y^{nat}}$ (long_name='Natural (flex price) output')
97 y_gap ${r^{gap}}$ (long_name='Output gap')
98 ;
99
100 varexo epsilon ${\varepsilon}$ (long_name='TFP shock')
101 ;
102
103 parameters beta ${\beta}$ (long_name='discount factor')
104 theta ${\theta}$ (long_name='substitution elasticity')
105 tau ${\tau}$ (long_name='labor subsidy')
106 chi ${\chi}$ (long_name='labor disutility')
107 phi ${\phi}$ (long_name='price adjustment costs')
108 rho ${\rho}$ (long_name='TFP autocorrelation')
109 @# if !defined(Ramsey) || Ramsey==0
110 pi_star ${\pi^*}$ (long_name='steady state inflation')
111 alpha ${\alpha}$ (long_name='inflation feedback Taylor rule')
112 @# endif
113 ;
114
115 beta=0.99;
116 theta=5;
117 phi=100;
118 rho=0.9;
119 @# if !defined(Ramsey) || Ramsey==0
120 alpha=1.5;
121 pi_star=1;
122 @# endif
123 @# if Efficent_steady_state
124 tau=1/(theta-1);
125 @# else
126 tau=0;
127 @# endif
128 chi=1;
129
130 model;
131 [name='Euler equation']
132 1/(1+R)=beta*C/(C(+1)*pi(+1));
133 [name='Firm FOC']
134 (tau-1/(theta-1))*(1-theta)+theta*(chi*h*C/(exp(Z))-1)=phi*(pi-1)*pi-beta*phi*(pi(+1)-1)*pi(+1);
135 [name='Resource constraint']
136 C*(1+phi/2*(pi-1)^2)=exp(Z)*h;
137 [name='TFP process']
138 Z=rho*Z(-1)+epsilon;
139 @#if !defined(Ramsey) || Ramsey==0
140 [name='Taylor rule']
141 R=pi_star/beta-1+alpha*(pi-pi_star);
142 @#endif
143 [name='Definition log consumption']
144 log_C=log(C);
145 [name='Definition log hours worked']
146 log_h=log(h);
147 [name='Definition annualized inflation rate']
148 pi_ann=4*log(pi);
149 [name='Definition annualized nominal interest rate']
150 R_ann=4*R;
151 [name='Definition annualized real interest rate']
152 r_real=4*log((1+R)/pi(+1));
153 [name='Definition natural output']
154 y_nat=exp(Z)*sqrt((theta-1)/theta*(1+tau)/chi);
155 [name='output gap']
156 y_gap=log_C-log(y_nat);
157 end;
158
159 steady_state_model;
160 Z=0;
161 @# if !defined(Ramsey) || Ramsey==0
162 R=pi_star/beta-1; %only set this if not conditional steady state file for Ramsey
163 @# endif
164 pi=(R+1)*beta;
165 C=sqrt((1+1/theta*((1-beta)*(pi-1)*pi-(tau-1/(theta-1))*(1-theta)))/(chi*(1+phi/2*(pi-1)^2)));
166 h=C*(1+phi/2*(pi-1)^2);
167 log_C=log(C);
168 log_h=log(h);
169 pi_ann=4*log(pi);
170 R_ann=4*R;
171 r_real=4*log((1+R)/pi);
172 y_nat=sqrt((theta-1)/theta*(1+tau)/chi);
173 y_gap=log_C-log(y_nat);
174 end;
175
176 @# if defined(Ramsey) && Ramsey==1
177 //define initial value of instrument for Ramsey
178 initval;
179 R=1/beta-1;
180 end;
181 @# endif
182
183 shocks;
184 var epsilon = 0.01^2;
185 end;
186
187 @#if Optimal_policy==0
188 //use Taylor rule
189 stoch_simul(order=2) pi_ann log_h R_ann log_C Z r_real y_nat;
190 @#else
191 @# if !defined(Ramsey) || Ramsey==0
192 //use OSR Taylor rule
193
194 //set weights on (co-)variances for OSR
195 optim_weights;
196 pi theta/((theta-1)/phi);
197 y_gap 1;
198 end;
199
200 //define OSR parameters to be optimized
201 osr_params alpha;
202
203 //starting value for OSR parameter
204 alpha = 1.5;
205
206 //define bounds for OSR during optimization
207 osr_params_bounds;
208 alpha, 0, 100;
209 end;
210
211 //compute OSR and provide output
212 osr(opt_algo=9) pi_ann log_h R_ann log_C Z r_real;
213
214 @# else
215 //use Ramsey optimal policy
216
217 //define planner objective, which corresponds to utility function of agents
218 planner_objective log(C)-chi/2*h^2;
219
220 //set up Ramsey optimal policy problem with interest rate R as the instrument,...
221 // defining the discount factor in the planner objective to be the one of private agents
222 ramsey_model(instruments=(R),planner_discount=beta,planner_discount_latex_name=$\beta$);
223
224 //conduct stochastic simulations of the Ramsey problem
225 stoch_simul(TeX,order=1,irf=20,periods=500) pi_ann log_h R_ann log_C Z r_real;
226 evaluate_planner_objective;
227
228 @# if Estimation_under_Ramsey==1
229 datatomfile('ramsey_simulation',{'log_C'})
230
231 estimated_params;
232 rho,0.5,uniform_pdf, , ,0,1;
233 end;
234 varobs log_C;
235
236 estimation(datafile=ramsey_simulation,mode_compute=5,mh_nblocks=1,mh_replic=0);
237 identification(parameter_set=posterior_mode);
238 @# endif
239 @# endif
240 @# endif
241
242 write_latex_static_model(write_equation_tags);
243 write_latex_dynamic_model(write_equation_tags);
244 write_latex_original_model(write_equation_tags);
245 write_latex_steady_state_model;
246
247 collect_latex_files;
248 [status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
249 if status
250 cmdout
251 error('TeX-File did not compile.')
252 end