Debian Codegraph @

tests/ep/zeroshocks/rstrue.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 epsG 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) + 0;
93 lG = (1-rhog)*log(GBar) + rhog * lG(-1) + epsG;
94 pistar = (1-rhopistar) *log(piBar) + rhopistar *pistar(-1) + gssload *(4*lpiavg-pistar) + 0;
95 // Term premium and other auxiliary finance equations
96 Intr = Int(-1) - lpi; // ex post real short rate
97 exp(lsdf) = beta *exp(lC(+1)-lC)^-phi *exp(lDZ(+1))^-phi
98 *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha /exp(lpi(+1));
99 //pricebond = 1 + consoldelta *beta *exp(lC(+1)-lC)^-phi *exp(lDZ(+1))^-phi
100 // *(V(+1) *exp(lDZ(+1))^(1-phi) /Vkp)^-alpha /pi(+1) *pricebond(+1);
101 //pricebondrn = 1 + consoldelta *pricebondrn(+1) /exp(Int);
102 //ytm = log(consoldelta*pricebond/(pricebond-1)) *400; // yield in annualized pct
103 //ytmrn = log(consoldelta*pricebondrn/(pricebondrn-1)) *400;
104 //termprem = 100 * (ytm–ytmrn); // term prem in annualized basis points
105 //ehpr = ( (consoldelta *pricebond + exp(Int(-1))) /pricebond(-1)–exp(Int(-1)) *400;
106 //slope = ytm–Int*400;
107 end;
108
109 steady_state_model;
110 lA = 0;
111 lDZ = log(DZBar);
112 lG = log(GBar);
113 pistar = log(piBar);
114 lpi = log(piBar);
115 lpiavg = lpi;
116 lDisp = 0;
117 Int = log(DZBar^phi/beta)+lpi;
118 Int1 = Int/10;
119 lpi1 = lpi/10;
120 lL = 0;
121 lY = log(YBar);
122 lC = log(exp(lY)-exp(lG)-IBar);
123 lp0 = log(((exp(lpi)^(-1/theta)-xi)/((1-xi)*exp(lpi)^(-1/theta)))^(-theta));
124 lzd = log(exp(lY)/(1-xi *beta *exp(lDZ)^-phi
125 *exp(lpi)^(1/theta)));
126 lzn = log(exp(lp0)^(1+(1+theta)/theta *(1-eta)/eta)*exp(lzd));
127 MC = (exp(lzn)-xi *beta *DZBar^-phi*piBar^((1+theta)/theta/eta)*exp(lzn))/((1+theta)*YBar);
128 lwreal = log(MC*eta /(exp(lY)^((1-eta)/eta) / KBar^((1-eta)/eta)));
129
130 chi0 = exp(lwreal)*exp(lC)^(-phi)/(LMax-exp(lL))^(-chi);
131 V = (exp(lC)^(1-phi) /(1-phi) + chi0 *(LMax-exp(lL))^(1-chi) /(1-chi))/(1-beta*DZBar^(1-phi));
132 k = 1.05;
133 VAIMSS = k*V;
134 Valphaexp = k^(alpha-1);
135 Vkp = DZBar^(1-phi)*V;
136 Intr = Int - lpi;
137 lsdf = log(beta *exp(lDZ)^-phi/exp(lpi));
138 end;
139
140 steady;
141
142 shocks;
143 var epsA; stderr 0.001;
144 var epsG; stderr 0.004;
145 var epsInt; stderr 0.003;
146 end;
147
148 extended_path(periods=10, order=1,integration=unscented);
149
150 if ~oo_.extended_path.status
151 error('Stochastic extended path did not find solution in zeroshocks/rstrue.mod (order=1, integration=unscented).')
152 end
153
154 Simulated_time_series.save('rstrue1');
155
156 extended_path(periods=10, order=2);
157 Simulated_time_series.save('rstrue2');
158 if ~oo_.extended_path.status
159 error('Stochastic extended path did not find solution in zeroshocks/rstrue.mod (order=2, tree=perfect, integration=unscented).')
160 end
161
162 extended_path(periods=10, order=2,tree=sparse);
163 Simulated_time_series.save('rstrue2s');
164 if ~oo_.extended_path.status
165 error('Stochastic extended path did not find solution in zeroshocks/rstrue.mod (order=2, tree=sparse, integration=unscented).')
166 end
167
168 extended_path(periods=10, order=2, hybrid);
169 Simulated_time_series.save('rstrue2sh');
170 if ~oo_.extended_path.status
171 error('Stochastic extended path did not find solution in zeroshocks/rstrue.mod (order=2, tree=sparse, hybrid=2, integration=unscented).')
172 end