Debian Codegraph @

tests/discretionary_policy/Gali_discretion.mod

raw
1 /*
2 * This file implements the baseline New Keynesian model of Jordi Gal� (2008): Monetary Policy, Inflation,
3 * and the Business Cycle, Princeton University Press, Chapter 5
4 *
5 * This implementation was written by Johannes Pfeifer.
6 *
7 * Please note that the following copyright notice only applies to this Dynare
8 * implementation of the model.
9 */
10
11 /*
12 * Copyright © 2013-21 Johannes Pfeifer
13 *
14 * This is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * It is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * For a copy of the GNU General Public License,
25 * see <https://www.gnu.org/licenses/>.
26 */
27
28
29 var pi
30 y_gap
31 r_e
32 y_e
33 r_nat
34 i
35 u
36 a
37 p
38 ;
39
40 varexo eps_a
41 eps_u;
42
43 parameters alppha
44 betta
45 rho_a
46 rho_u
47 siggma
48 phi
49 phi_y
50 eta
51 epsilon
52 theta
53 ;
54 %----------------------------------------------------------------
55 % Parametrization, p. 52
56 %----------------------------------------------------------------
57 siggma = 1;
58 phi=1;
59 phi_y = .5/4;
60 theta=2/3;
61 rho_u = 0;
62 rho_a = 0.9;
63 betta = 0.99;
64 eta =4;
65 alppha=1/3;
66 epsilon=6;
67
68
69
70 %----------------------------------------------------------------
71 % First Order Conditions
72 %----------------------------------------------------------------
73
74 model(linear);
75 //Composite parameters
76 #Omega=(1-alppha)/(1-alppha+alppha*epsilon); //defined on page 47
77 #psi_n_ya=(1+phi)/(siggma*(1-alppha)+phi+alppha); //defined on page 48
78 #lambda=(1-theta)*(1-betta*theta)/theta*Omega; //defined on page 47
79 #kappa=lambda*(siggma+(phi+alppha)/(1-alppha)); //defined on page 49
80 #alpha_x=kappa/epsilon; //defined on page 96
81 #phi_pi=(1-rho_u)*kappa*siggma/(alpha_x)+rho_u; //defined on page 101
82
83 r_e=siggma*(y_e(+1)-y_e);
84 y_e=psi_n_ya*a;
85 pi=betta*pi(+1)+kappa*y_gap + u;
86 y_gap=-1/siggma*(i-pi(+1)-r_e)+y_gap(+1);
87 //3. Interest Rate Rule eq. (25)
88 % i=r_e+phi_pi*pi;
89
90 r_nat=siggma*psi_n_ya*(a(+1)-a);
91 u=rho_u*u(-1)+eps_u;
92 a=rho_a*a(-1)+eps_a;
93
94 pi=p-p(-1);
95 end;
96
97 %----------------------------------------------------------------
98 % define shock variances
99 %---------------------------------------------------------------
100
101
102 shocks;
103 var eps_u = 1;
104 end;
105
106 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;
107
108 discretionary_policy(instruments=(i),irf=20,planner_discount=betta,discretionary_tol=1e-12) y_gap pi p u;
109
110 verbatim;
111 %% Check correctness
112 Omega=(1-alppha)/(1-alppha+alppha*epsilon); %defined on page 47
113 lambda=(1-theta)*(1-betta*theta)/theta*Omega; %defined on page 47
114 kappa=lambda*(siggma+(phi+alppha)/(1-alppha)); %defined on page 49
115 alpha_x=kappa/epsilon; %defined on page 96
116 Psi=1/(kappa^2+alpha_x*(1-betta*rho_u)); %defined on page 99
117 Psi_i=Psi*(kappa*siggma*(1-rho_u)+alpha_x*rho_u); %defined on page 101
118 phi_pi=(1-rho_u)*kappa*siggma/(alpha_x)+rho_u; %defined on page 101
119
120 %Compute theoretical solution
121 var_pi_theoretical=(alpha_x*Psi)^2; %equation (6), p.99
122 var_y_gap_theoretical=(-kappa*Psi)^2; %equation (7), p.99
123
124 pi_pos=strmatch('pi',var_list_,'exact');
125 y_gap_pos=strmatch('y_gap',var_list_,'exact');
126 if abs(oo_.var(pi_pos,pi_pos)-var_pi_theoretical)>1e-10 || abs(oo_.var(y_gap_pos,y_gap_pos)-var_y_gap_theoretical)>1e-10
127 error('Variances under optimal policy are wrong')
128 end
129
130 %Compute theoretical objective function
131 V=betta/(1-betta)*(var_pi_theoretical+alpha_x*var_y_gap_theoretical); %evaluate at steady state in first period
132
133 if any( [ isnan(oo_.planner_objective_value.conditional), abs(V-oo_.planner_objective_value.conditional)>1e-10 ] )
134 error('Computed welfare deviates from theoretical welfare')
135 end
136 end;
137
138 %% repeat exercise with initial shock of 1 to check whether planner objective is correctly specified
139 initval;
140 eps_u = 1;
141 end;
142
143 %Compute theoretical objective function
144 V=var_pi_theoretical+alpha_x*var_y_gap_theoretical+ betta/(1-betta)*(var_pi_theoretical+alpha_x*var_y_gap_theoretical); %evaluate at steady state in first period
145
146 discretionary_policy(instruments=(i),irf=20,discretionary_tol=1e-12,planner_discount=betta) y_gap pi p u;
147 if any( [ isnan(oo_.planner_objective_value.conditional), abs(V-oo_.planner_objective_value.conditional)>1e-10 ] )
148 error('Computed welfare deviates from theoretical welfare')
149 end