Debian Codegraph @

tests/ep/zeroshocks/rs.mod

raw
1 var V lL Vkp Valphaexp lzn lzd lp0 lpi MC lwreal lY lDisp lC lpiavg Int lA lDZ lG pistar Intr
2 lsdf Int1 lpi1;
3 // pricebond pricebondrn ytm ytmrn termprem ehpr slope;
4 varexo epsA epsZ epsG epsPistar epsInt;
5
6 parameters theta xi beta phi alpha eta KBar chi0 LMax chi IBar rhoinflavg taylrho DZBar taylpi tayly YBar rhoa rhoz rhog rhopistar piBar gssload consoldelta VAIMSS GBar;
7
8 DZBar = 1.0025;
9 eta = 2/3;
10 IES = .11;
11 phi = 1/IES;
12 beta = .99 *DZBar^phi;
13 delta = .02;
14
15 Frisch = .28;
16 CRRA = 110;
17
18 LMax = 3;
19 // chi0 = exp(wrealAIMSS -phi*CAIMSS) *(LMax-1)^chi; // normalize L in ss = 1
20 chi0 = 1/3;
21 chi = 1/Frisch *(LMax-1);
22 alpha = (CRRA - 1/(1/phi + 1/chi *(LMax-1))) *(1/(1-phi) + 1/(1-chi) *(LMax-1));
23
24 theta = .2;
25 xi = .78;
26
27 K_Y = 10;
28 YBar = K_Y^((1-eta)/eta);
29 GBar = .17 *YBar;
30 KBar = K_Y *YBar;
31 IBar = (delta +(DZBar-1)) *KBar;
32 piBar = 1.0;
33
34 taylrho = .73;
35 taylpi = .53;
36 tayly = .93;
37
38 rhoa = .96;
39 rhoz = 0;
40 rhog = .95;
41 rhopistar = 0;
42 epsafl = 1; // these flags turn on or off each corresponding shock in the model
43 epsapermfl = 0;
44 epsgfl = 1;
45 epsifl = 1;
46 epspistarfl = 0;
47 rhoinflavg = .7; // for price level targeting; set rhoinflavg = .99 or .999
48 gssload = 0; // this is the GSS theta parameter in the long-run nominal risks section of the paper
49
50 VAIMSS = 1;
51 consoldelta = 1;
52
53 model(use_dll);
54 // Value function and Euler equation
55 V = exp(lC)^(1-phi) /(1-phi) + chi0 *(LMax-exp(lL))^(1-chi) /(1-chi) + beta *Vkp;
56 Int1 = Int/10;
57 lpi1 = lpi/10;
58 exp(lC)^-phi = beta *exp(10*Int1-10*lpi1(+1)) *exp(lC(+1))^-phi *exp(lDZ(+1))^-phi
59 *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha;
60 // The following two equations define the E-Z-W-K-P certainty equivalent term
61 // Vkp = (E_t V(+1)^(1-alpha))^(1/(1-alpha)). It takes two equations to do this because
62 // Perturbation AIM sets the expected value of all equations equal to zero; E_t F(variables) = 0.
63 // Thus; the first equation below defines Valphaexp = E_t V(+1)^(1-alpha). The second
64 // equation then takes the (1-alpha)th root of this expectation.
65 // Finally; the scaling and unscaling of Valphaexp by the constant VAIMSS and DZBar improves the
66 // numerical behavior of the model; without it; the steady-state value of Valphaexp can be minuscule
67 // (e.g.; 10^-50); which requires Mathematica to use astronomical levels of precision to solve. *)
68 Valphaexp = (V(+1) *exp(lDZ(+1))^(1-phi) /VAIMSS /DZBar^(1-phi))^(1-alpha) ⟂ Valphaexp > 1e-5;
69 Vkp = VAIMSS *DZBar^(1-phi) *Valphaexp^(1/(1-alpha));
70
71 exp(lzn) = (1+theta) *MC *exp(lY) + xi *beta *exp(lC(+1)-lC)^-phi *exp(lDZ(+1))^-phi
72 *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha *exp(lpi(+1))^((1+theta)/theta/eta) *exp(lzn(+1));
73 exp(lzd) = exp(lY) + xi *beta *exp(lC(+1)-lC)^-phi*exp(lDZ(+1))^-phi
74 *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha *exp(lpi(+1))^(1/theta) *exp(lzd(+1));
75 exp(lp0)^(1+(1+theta)/theta *(1-eta)/eta) = exp(lzn-lzd);
76 exp(lpi)^(-1/theta) = (1-xi) *exp(lp0+lpi)^(-1/theta) + xi;
77 // Marginal cost and real wage
78 MC = exp(lwreal) /eta *exp(lY)^((1-eta)/eta) /exp(lA)^(1/eta) /KBar^((1-eta)/eta);
79 chi0 *(LMax-exp(lL))^-chi /exp(lC)^-phi = exp(lwreal) ⟂ lL < 1.0986;
80 // Output equations
81 exp(lY) = exp(lA) *KBar^(1-eta) *exp(lL)^eta /exp(lDisp);
82 exp(lDisp)^(1/eta) = (1-xi) *exp(lp0)^(-(1+theta)/theta/eta)
83 + xi *exp(lpi)^((1+theta)/theta/eta) *exp(lDisp(-1))^(1/eta);
84 exp(lC) = exp(lY)-exp(lG)-IBar; // aggregate resource constraint; no adj costs
85 // Monetary Policy Rule
86 lpiavg = rhoinflavg *lpiavg(-1) + (1-rhoinflavg) *lpi;
87 4*Int = (1-taylrho) * ( 4*log(1/beta *DZBar^phi) + 4*lpiavg
88 + taylpi * (4*lpiavg-pistar) + tayly * (exp(lY)-YBar)/YBar )
89 + taylrho * 4*Int(-1) + epsInt; // multiply Int; infl by 4 to put at annual rate
90 // Exogenous Shocks
91 lA = rhoa * lA(-1) + epsA;
92 lDZ = (1-rhoz)*log(DZBar) + rhoz * lDZ(-1) + epsZ;
93 lG = (1-rhog)*log(GBar) + rhog * lG(-1) + epsG;
94 pistar = (1-rhopistar) *log(piBar) + rhopistar *pistar(-1) + gssload *(4*lpiavg-pistar)
95 + epsPistar;
96 // Term premium and other auxiliary finance equations
97 Intr = Int(-1) - lpi; // ex post real short rate
98 exp(lsdf) = beta *exp(lC(+1)-lC)^-phi *exp(lDZ(+1))^-phi
99 *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha /exp(lpi(+1));
100 //pricebond = 1 + consoldelta *beta *exp(lC(+1)-lC)^-phi *exp(lDZ(+1))^-phi
101 // *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha /pi(+1) *pricebond(+1);
102 //pricebondrn = 1 + consoldelta *pricebondrn(+1) /exp(Int);
103 //ytm = log(consoldelta*pricebond/(pricebond-1)) *400; // yield in annualized pct
104 //ytmrn = log(consoldelta*pricebondrn/(pricebondrn-1)) *400;
105 //termprem = 100 * (ytm–ytmrn); // term prem in annualized basis points
106 //ehpr = ( (consoldelta *pricebond + exp(Int(-1))) /pricebond(-1)–exp(Int(-1)) *400;
107 //slope = ytm–Int*400;
108 end;
109
110 steady_state_model;
111 lA = 0;
112 lDZ = log(DZBar);
113 lG = log(GBar);
114 pistar = log(piBar);
115 lpi = log(piBar);
116 lpiavg = lpi;
117 lDisp = 0;
118 Int = log(DZBar^phi/beta)+lpi;
119 Int1 = Int/10;
120 lpi1 = lpi/10;
121 lL = 0;
122 lY = log(YBar);
123 lC = log(exp(lY)-exp(lG)-IBar);
124 lp0 = log(((exp(lpi)^(-1/theta)-xi)/((1-xi)*exp(lpi)^(-1/theta)))^(-theta));
125 lzd = log(exp(lY)/(1-xi *beta *exp(lDZ)^-phi
126 *exp(lpi)^(1/theta)));
127 lzn = log(exp(lp0)^(1+(1+theta)/theta *(1-eta)/eta)*exp(lzd));
128 MC = (exp(lzn)-xi *beta *DZBar^-phi*piBar^((1+theta)/theta/eta)*exp(lzn))/((1+theta)*YBar);
129 lwreal = log(MC*eta /(exp(lY)^((1-eta)/eta) / KBar^((1-eta)/eta)));
130
131 chi0 = exp(lwreal)*exp(lC)^(-phi)/(LMax-exp(lL))^(-chi);
132 V = (exp(lC)^(1-phi) /(1-phi) + chi0 *(LMax-exp(lL))^(1-chi) /(1-chi))/(1-beta*DZBar^(1-phi));
133 k = 1.05;
134 VAIMSS = k*V;
135 Valphaexp = k^(alpha-1);
136 Vkp = DZBar^(1-phi)*V;
137 Intr = Int - lpi;
138 lsdf = log(beta *exp(lDZ)^-phi/exp(lpi));
139 end;
140
141 steady;
142
143 shocks;
144 var epsA; stderr 0.001;
145 var epsG; stderr 0.004;
146 var epsInt; stderr 0.003;
147 end;
148
149 // Test SEP(1)
150
151 extended_path(periods=10, order=1,integration=unscented);
152
153 Simulated_time_series1 = dseries('rstrue1.mat');
154
155 if ~oo_.extended_path.status || max((abs(Simulated_time_series.data(:)-Simulated_time_series1.data(:))))>1e-12
156 error('SEP(1): the simulated time series do not match the expected results.');
157 end
158
159 if size(oo_.exo_simul,1)~=size(oo_.endo_simul,2)
160 error('Variable dimensions are incorrect')
161 end
162 if size(oo_.exo_simul,2)~=M_.exo_nbr
163 error('Dimension of exo_simul is incorrect')
164 end
165
166 delete('rstrue1.mat')
167
168 // Test SEP(2)
169
170 extended_path(periods=10, order=2);
171
172 Simulated_time_series2 = dseries('rstrue2.mat');
173
174 if ~oo_.extended_path.status || max((abs(Simulated_time_series.data(:)-Simulated_time_series2.data(:))))>1e-12
175 error('SEP(2): the simulated time series do not match the expected results.');
176 end
177
178 if size(oo_.exo_simul,1)~=size(oo_.endo_simul,2)
179 error('Variable dimensions are incorrect')
180 end
181 if size(oo_.exo_simul,2)~=M_.exo_nbr
182 error('Dimension of exo_simul is incorrect')
183 end
184
185
186 delete('rstrue2.mat');
187
188 // Test SEP(2, sparse)
189
190 extended_path(periods=10, order=2, tree=sparse);
191
192 Simulated_time_series2s = dseries('rstrue2s.mat');
193
194 if ~oo_.extended_path.status || max((abs(Simulated_time_series.data(:)-Simulated_time_series2s.data(:))))>1e-12
195 error('SEP(2, sparse): the simulated time series do not match the expected results.');
196 end
197
198 if size(oo_.exo_simul,1)~=size(oo_.endo_simul,2)
199 error('Variable dimensions are incorrect')
200 end
201 if size(oo_.exo_simul,2)~=M_.exo_nbr
202 error('Dimension of exo_simul is incorrect')
203 end
204
205 delete('rstrue2s.mat');
206
207 // Test SEP(2, sparse, hybrid)
208 extended_path(periods=10, order=2, hybrid, tree=sparse);
209
210 Simulated_time_series2sh = dseries('rstrue2sh.mat');
211
212 if ~oo_.extended_path.status || max((abs(Simulated_time_series.data(:)-Simulated_time_series2sh.data(:))))>1e-12
213 error('SEP(2, sparse, hybrid): the simulated time series do not match the expected results.');
214 end
215
216 if size(oo_.exo_simul,1)~=size(oo_.endo_simul,2)
217 error('Variable dimensions are incorrect')
218 end
219 if size(oo_.exo_simul,2)~=M_.exo_nbr
220 error('Dimension of exo_simul is incorrect')
221 end
222
223 delete('rstrue2sh.mat');