Debian Codegraph @

tests/estimation/system_prior_restriction/Gali_2015.mod

raw
1 /*
2 * This file shows how to use "system prior"-type prior restrictions as in
3 * Michal Andrle/Miroslav Plašil (2018): "Econometrics with system priors",
4 * Economics Letters, 172, pp. 134-137 during estimation based on
5 * the baseline New Keynesian model of Jordi Galí (2015): Monetary Policy, Inflation,
6 * and the Business Cycle, Princeton University Press, Second Edition, Chapter 3
7 *
8 * THIS MOD-FILE REQUIRES DYNARE 4.5 OR HIGHER
9 *
10 * Notes:
11 * - The estimation will automatically take the Gali_2015_prior_restrictions.m into
12 * account, which has the required name and format
13 * - Estimation is based on simulated data
14 * - The file also shows how to use a prior/posterior-function
15 *
16 * This implementation was written by Johannes Pfeifer. In case you spot mistakes,
17 * email me at [email protected]
18 *
19 * Please note that the following copyright notice only applies to this Dynare
20 */
21
22 /*
23 * Copyright © 2021 Dynare Team
24 *
25 * This file is part of Dynare.
26 *
27 * Dynare is free software: you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published by
29 * the Free Software Foundation, either version 3 of the License, or
30 * (at your option) any later version.
31 *
32 * Dynare is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License
38 * along with Dynare. If not, see <http://www.gnu.org/licenses/>.
39 */
40
41 var pi ${\pi}$ (long_name='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 i ${i}$ (long_name='nominal interrst rate')
48 n ${n}$ (long_name='hours worked')
49 nu ${\nu}$ (long_name='AR(1) monetary policy shock process')
50 a ${a}$ (long_name='AR(1) technology shock process')
51 z ${z}$ (long_name='AR(1) preference shock process')
52 p ${p}$ (long_name='price level')
53 w ${w}$ (long_name='nominal wage')
54 c ${c}$ (long_name='consumption')
55 ;
56
57 varexo eps_a ${\varepsilon_a}$ (long_name='technology shock')
58 eps_nu ${\varepsilon_\nu}$ (long_name='monetary policy shock')
59 eps_z ${\varepsilon_z}$ (long_name='preference shock innovation')
60 ;
61
62 parameters alppha ${\alpha}$ (long_name='capital share')
63 betta ${\beta}$ (long_name='discount factor')
64 rho_a ${\rho_a}$ (long_name='autocorrelation technology shock')
65 rho_nu ${\rho_{\nu}}$ (long_name='autocorrelation monetary policy shock')
66 rho_z ${\rho_{z}}$ (long_name='autocorrelation monetary demand shock')
67 siggma ${\sigma}$ (long_name='inverse EIS')
68 varphi ${\varphi}$ (long_name='inverse Frisch elasticity')
69 phi_pi ${\phi_{\pi}}$ (long_name='inflation feedback Taylor Rule')
70 phi_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule')
71 eta ${\eta}$ (long_name='semi-elasticity of money demand')
72 epsilon ${\epsilon}$ (long_name='demand elasticity')
73 theta ${\theta}$ (long_name='Calvo parameter')
74 ;
75 %----------------------------------------------------------------
76 % Parametrization, p. 67 and p. 113-115
77 %----------------------------------------------------------------
78 siggma = 1;
79 varphi = 5;
80 phi_pi = 1.5;
81 phi_y = 0.125;
82 theta = 3/4;
83 rho_nu =0.5;
84 rho_z = 0.5;
85 rho_a = 0.9;
86 betta = 0.99;
87 eta = 3.77; %footnote 11, p. 115
88 alppha = 1/4;
89 epsilon = 9;
90
91 %----------------------------------------------------------------
92 % First Order Conditions
93 %----------------------------------------------------------------
94
95 model(linear);
96 //Composite parameters
97 #Omega=(1-alppha)/(1-alppha+alppha*epsilon); %defined on page 60
98 #psi_n_ya=(1+varphi)/(siggma*(1-alppha)+varphi+alppha); %defined on page 62
99 #lambda=(1-theta)*(1-betta*theta)/theta*Omega; %defined on page 61
100 #kappa=lambda*(siggma+(varphi+alppha)/(1-alppha)); %defined on page 63
101 [name='New Keynesian Phillips Curve eq. (22)']
102 pi=betta*pi(+1)+kappa*y_gap;
103 [name='Dynamic IS Curve eq. (23)']
104 y_gap=-1/siggma*(i-pi(+1)-r_nat)+y_gap(+1);
105 [name='Interest Rate Rule eq. (26)']
106 i=phi_pi*pi+phi_y*yhat+nu;
107 [name='Definition natural rate of interest eq. (24)']
108 r_nat=-siggma*psi_n_ya*(1-rho_a)*a+(1-rho_z)*z;
109 [name='Definition natural output, eq. (20)']
110 y_nat=psi_n_ya*a;
111 [name='Definition output gap']
112 y_gap=y-y_nat;
113 [name='Monetary policy shock']
114 nu=rho_nu*nu(-1)+eps_nu;
115 [name='TFP shock']
116 a=rho_a*a(-1)+eps_a;
117 [name='Production function (eq. 14)']
118 y=a+(1-alppha)*n;
119 [name='Preference shock, p. 54']
120 z=rho_z*z(-1) - eps_z;
121 [name='Output deviation from steady state']
122 yhat=y-steady_state(y);
123 [name='Definition price level']
124 pi=p-p(-1);
125 [name='resource constraint, eq. (12)']
126 y=c;
127 [name='FOC labor, eq. (2)']
128 w-p=siggma*c+varphi*n;
129 end;
130
131
132 shocks;
133 var eps_nu = 0.0025^2; //1 standard deviation shock of 25 basis points, i.e. 1 percentage point annualized
134 end;
135
136 % simulate data
137 stoch_simul(periods=100,drop=0,irf=0) yhat;
138 % save data
139 datatomfile('sim_data',{'yhat'});
140
141 estimated_params;
142 theta,0.75,beta_pdf,0.5,0.1;
143 betta, beta_pdf, 0.993, 0.002;
144 alppha, beta_pdf, 0.25, 0.02;
145 end;
146
147 varobs yhat;
148
149 % Run prior function to get prior slope of the PC based on independent priors
150 hh_fig=figure('Name','Slope of the Phillips Curve');
151 prior_function(function='Gali_2015_PC_slope');
152 PC_slope_vec=cell2mat(oo_.prior_function_results(:,1));
153
154 optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
155 [density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
156 figure(hh_fig)
157 subplot(3,1,1)
158 plot(density(:,1),density(:,2));
159 title('Prior')
160
161 % Run estimation with 1 observation to show effect of _prior_restriction .m
162 % on independent prior
163 estimation(datafile='sim_data',silent_optimizer,mode_compute=5,mh_replic=2001,mh_nblocks=1,diffuse_filter,nobs=1,mh_jscale=0.8);
164 posterior_function(function='Gali_2015_PC_slope');
165 PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
166 optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
167 [density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
168 figure(hh_fig)
169 subplot(3,1,2)
170 plot(density(:,1),density(:,2));
171 title('Updated Prior')
172
173
174 % Run estimation with full observations
175 estimation(datafile='sim_data',silent_optimizer,mode_compute=5,mh_replic=2001,mh_nblocks=1,diffuse_filter,nobs=100,mh_jscale=0.8);
176
177 posterior_function(function='Gali_2015_PC_slope');
178 PC_slope_vec=cell2mat(oo_.posterior_function_results(:,1));
179 optimal_bandwidth = mh_optimal_bandwidth(PC_slope_vec,length(PC_slope_vec),0,'gaussian');
180 [density(:,1),density(:,2)] = kernel_density_estimate(PC_slope_vec,512,length(PC_slope_vec),optimal_bandwidth,'gaussian');
181 figure(hh_fig)
182 subplot(3,1,3)
183 plot(density(:,1),density(:,2));
184 title('Posterior')