| 1 |
% DSGE model based on replication files of |
| 2 |
% Andreasen, Fernandez-Villaverde, Rubio-Ramirez (2018), The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications, Review of Economic Studies, 85, p. 1-49 |
| 3 |
% Original code by Martin M. Andreasen, Jan 2016 |
| 4 |
% Adapted for Dynare by Willi Mutschler (@wmutschl, [email protected]), Jan 2021 |
| 5 |
% ========================================================================= |
| 6 |
% Copyright © 2021 Dynare Team |
| 7 |
% |
| 8 |
% This file is part of Dynare. |
| 9 |
% |
| 10 |
% Dynare is free software: you can redistribute it and/or modify |
| 11 |
% it under the terms of the GNU General Public License as published by |
| 12 |
% the Free Software Foundation, either version 3 of the License, or |
| 13 |
% (at your option) any later version. |
| 14 |
% |
| 15 |
% Dynare is distributed in the hope that it will be useful, |
| 16 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
% GNU General Public License for more details. |
| 19 |
% |
| 20 |
% You should have received a copy of the GNU General Public License |
| 21 |
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. |
| 22 |
% ========================================================================= |
| 23 |
|
| 24 |
%-------------------------------------------------------------------------- |
| 25 |
% Variable declaration |
| 26 |
%-------------------------------------------------------------------------- |
| 27 |
var |
| 28 |
ln_k |
| 29 |
ln_s |
| 30 |
ln_a |
| 31 |
ln_g |
| 32 |
ln_d |
| 33 |
|
| 34 |
ln_c |
| 35 |
ln_r |
| 36 |
ln_pai |
| 37 |
ln_h |
| 38 |
ln_q |
| 39 |
ln_evf |
| 40 |
ln_iv |
| 41 |
ln_x2 |
| 42 |
ln_la |
| 43 |
ln_goy |
| 44 |
ln_Esdf |
| 45 |
|
| 46 |
xhr20 |
| 47 |
xhr40 |
| 48 |
Exhr |
| 49 |
|
| 50 |
@#for i in 1:40 |
| 51 |
ln_p@{i} |
| 52 |
@#endfor |
| 53 |
|
| 54 |
Obs_Gr_C |
| 55 |
Obs_Gr_I |
| 56 |
Obs_Infl |
| 57 |
Obs_r1 |
| 58 |
Obs_r40 |
| 59 |
Obs_xhr40 |
| 60 |
Obs_GoY |
| 61 |
Obs_hours |
| 62 |
; |
| 63 |
|
| 64 |
predetermined_variables ln_k ln_s; |
| 65 |
|
| 66 |
varobs Obs_Gr_C Obs_Gr_I Obs_Infl Obs_r1 Obs_r40 Obs_xhr40 Obs_GoY Obs_hours; |
| 67 |
|
| 68 |
%-------------------------------------------------------------------------- |
| 69 |
% Exogenous shocks |
| 70 |
%-------------------------------------------------------------------------- |
| 71 |
varexo |
| 72 |
eps_a |
| 73 |
eps_d |
| 74 |
eps_g |
| 75 |
; |
| 76 |
|
| 77 |
%-------------------------------------------------------------------------- |
| 78 |
% Parameter declaration |
| 79 |
%-------------------------------------------------------------------------- |
| 80 |
parameters |
| 81 |
BETTA |
| 82 |
B |
| 83 |
INHABIT |
| 84 |
H |
| 85 |
PHI1 |
| 86 |
PHI2 |
| 87 |
RRA |
| 88 |
PHI4 |
| 89 |
KAPAone |
| 90 |
KAPAtwo |
| 91 |
DELTA |
| 92 |
THETA |
| 93 |
ETA |
| 94 |
ALFA |
| 95 |
CHI |
| 96 |
RHOR |
| 97 |
BETTAPAI |
| 98 |
BETTAY |
| 99 |
MYYPS |
| 100 |
MYZ |
| 101 |
RHOA |
| 102 |
%STDA |
| 103 |
RHOG |
| 104 |
%STDG |
| 105 |
RHOD |
| 106 |
%STDD |
| 107 |
CONSxhr40 |
| 108 |
BETTAxhr |
| 109 |
BETTAxhr40 |
| 110 |
CONSxhr20 |
| 111 |
PAI |
| 112 |
GAMA |
| 113 |
GoY |
| 114 |
|
| 115 |
%auxiliary |
| 116 |
PHIzero |
| 117 |
AA |
| 118 |
PHI3 |
| 119 |
negVf |
| 120 |
; |
| 121 |
|
| 122 |
|
| 123 |
%-------------------------------------------------------------------------- |
| 124 |
% Model equations |
| 125 |
%-------------------------------------------------------------------------- |
| 126 |
% Based on DSGE_model_NegVf_yieldCurve.m and DSGE_model_PosVf_yieldCurve.m |
| 127 |
% Note that we include an auxiliary parameter negVf to distinguish whether |
| 128 |
% the steady state value function is positive (negVf=0) or negative (negVf=1). |
| 129 |
% This parameter is endogenously determined in the steady_state_model block. |
| 130 |
|
| 131 |
model; |
| 132 |
%-------------------------------------------------------------------------- |
| 133 |
% Auxiliary expressions |
| 134 |
%-------------------------------------------------------------------------- |
| 135 |
% do exp transform such that variables are logged variables |
| 136 |
@#for var in [ "k", "s", "c", "r", "a", "g", "d", "pai", "h", "q", "evf", "iv", "x2", "la", "goy", "Esdf" ] |
| 137 |
#@{var}_ba1 = exp(ln_@{var}(-1)); |
| 138 |
#@{var}_cu = exp(ln_@{var}); |
| 139 |
#@{var}_cup = exp(ln_@{var}(+1)); |
| 140 |
@#endfor |
| 141 |
@#for i in 1:40 |
| 142 |
#p@{i}_cu = exp(ln_p@{i}); |
| 143 |
#p@{i}_cup = exp(ln_p@{i}(+1)); |
| 144 |
@#endfor |
| 145 |
% these variables are not transformed |
| 146 |
#xhr20_cu = xhr20; |
| 147 |
#xhr20_cup = xhr20(+1); |
| 148 |
#xhr40_cu = xhr40; |
| 149 |
#xhr40_cup = xhr40(+1); |
| 150 |
#Exhr_cu = Exhr; |
| 151 |
#Exhr_cup = Exhr(+1); |
| 152 |
|
| 153 |
% auxiliary steady state variables |
| 154 |
#K = exp(steady_state(ln_k)); |
| 155 |
#IV = exp(steady_state(ln_iv)); |
| 156 |
#C = exp(steady_state(ln_c)); |
| 157 |
#Y = (C + IV)/(1-GoY); |
| 158 |
#R = exp(steady_state(ln_r)); |
| 159 |
#G = Y-C-IV; |
| 160 |
|
| 161 |
#removeMeanXhr = 1; |
| 162 |
|
| 163 |
% The atemporal relations if possible |
| 164 |
% No stochastic trend in investment specific shocks |
| 165 |
#myyps_cu = MYYPS; |
| 166 |
#myyps_cup = MYYPS; |
| 167 |
|
| 168 |
% No stochastic trend in non-stationary technology shocks |
| 169 |
#myz_cu = MYZ; |
| 170 |
#myz_cup = MYZ; |
| 171 |
|
| 172 |
% Defining myzstar |
| 173 |
#MYZSTAR = MYYPS^(THETA/(1-THETA))*MYZ; |
| 174 |
#myzstar_cu = myyps_cu ^(THETA/(1-THETA))*myz_cu; |
| 175 |
#myzstar_cup= myyps_cup^(THETA/(1-THETA))*myz_cup; |
| 176 |
|
| 177 |
% The expression for the value function (only valid for deterministic trends!) |
| 178 |
% Note that we make use of auxiliary parameter negVf to switch signs |
| 179 |
#mvf_cup = -negVf*(d_cup/(1-PHI2)*((c_cup-B*c_cu*MYZSTAR^-1)^(1-PHI2)-1) + d_cup*PHIzero/(1-PHI1)*(1-h_cup)^(1-PHI1) - negVf* BETTA*MYZSTAR^((1-PHI4)*(1-PHI2))*AA*evf_cup^(1/(1-PHI3))); |
| 180 |
|
| 181 |
% The growth rate in lambda |
| 182 |
#myla_cup = (la_cup/la_cu)*(AA*evf_cu^(1/(1-PHI3))/mvf_cup)^PHI3*myzstar_cup^(-PHI2*(1-PHI4)-PHI4); |
| 183 |
|
| 184 |
% The relation between the optimal price for the firms and the pris and inflation |
| 185 |
%ptil_cu = ((1-ALFA*(pai_ba1^CHI/pai_cu )^(1-ETA))/(1-ALFA))^(1/(1-ETA)); |
| 186 |
%ptil_cup = ((1-ALFA*(pai_cu ^CHI/pai_cup)^(1-ETA))/(1-ALFA))^(1/(1-ETA)); |
| 187 |
#ptil_cu = ((1-ALFA*(1/pai_cu )^(1-ETA))/(1-ALFA))^(1/(1-ETA)); |
| 188 |
#ptil_cup = ((1-ALFA*(1/pai_cup)^(1-ETA))/(1-ALFA))^(1/(1-ETA)); |
| 189 |
|
| 190 |
% From the households' FOC for labor |
| 191 |
#w_cu = d_cu*PHIzero*(1-h_cu )^(-PHI1)/la_cu; |
| 192 |
#w_cup = d_cu*PHIzero*(1-h_cup)^(-PHI1)/la_cup; |
| 193 |
% Shouldn't w_cup include d_cup? Let's stick to the original (wrong) code in the replication files as results don't change dramatically... [@wmutschl] |
| 194 |
|
| 195 |
% The firms' FOC for labor |
| 196 |
#mc_cu = w_cu /((1-THETA)*a_cu *myyps_cu ^(-THETA/(1-THETA))*myz_cu ^-THETA *k_cu ^THETA*h_cu ^(-THETA)); |
| 197 |
#mc_cup = w_cup/((1-THETA)*a_cup*myyps_cup^(-THETA/(1-THETA))*myz_cup^-THETA *k_cup^THETA*h_cup^(-THETA)); |
| 198 |
|
| 199 |
% The firms' FOC for capital |
| 200 |
#rk_cu = mc_cu *THETA* a_cu *myyps_cu *myz_cu ^(1-THETA)*k_cu ^(THETA-1)*h_cu ^(1-THETA); |
| 201 |
#rk_cup = mc_cup*THETA* a_cup*myyps_cup*myz_cup^(1-THETA)*k_cup^(THETA-1)*h_cup^(1-THETA); |
| 202 |
|
| 203 |
% The income identity |
| 204 |
#y_cu = c_cu + iv_cu + g_cu; |
| 205 |
|
| 206 |
%-------------------------------------------------------------------------- |
| 207 |
% Actual model equations |
| 208 |
%-------------------------------------------------------------------------- |
| 209 |
|
| 210 |
[name='Expected value of the value function'] |
| 211 |
0 = -evf_cu + (mvf_cup/AA)^(1-PHI3); |
| 212 |
|
| 213 |
[name='Households FOC for capital'] |
| 214 |
0 = -q_cu+BETTA*myla_cup/myyps_cup*(rk_cup+q_cup*(1-DELTA) -q_cup*KAPAtwo/2*(iv_cup/k_cup*myyps_cup*myzstar_cup - IV/K*MYYPS*MYZSTAR)^2 +q_cup*KAPAtwo*(iv_cup/k_cup*myyps_cup*myzstar_cup - IV/K*MYYPS*MYZSTAR)*iv_cup/k_cup*myyps_cup*myzstar_cup); |
| 215 |
|
| 216 |
[name='Households FOC for investments'] |
| 217 |
0 = -1+q_cu*(1-KAPAone/2*(iv_cu/IV-1)^2-iv_cu/IV*KAPAone*(iv_cu/IV-1)-KAPAtwo*(iv_cu/k_cu*myyps_cu*myzstar_cu - IV/K*MYYPS*MYZSTAR)); |
| 218 |
|
| 219 |
[name='Euler equation for consumption'] |
| 220 |
0 = -1+BETTA*r_cu*exp(CONSxhr40*xhr40_cu + CONSxhr20*xhr20_cu)*myla_cup/pai_cup; |
| 221 |
|
| 222 |
[name='Households FOC for consumption'] |
| 223 |
0 = -la_cu + d_cu*(c_cu -B*c_ba1*myzstar_cu^-1)^(-PHI2) -INHABIT*B*BETTA*d_cup*(AA*evf_cu^(1/(1-PHI3))/mvf_cup)^PHI3*(c_cup -B*c_cu*myzstar_cup^-1)^(-PHI2)*myzstar_cup^(-PHI2*(1-PHI4)-PHI4); |
| 224 |
|
| 225 |
[name='Nonlinear pricing, relation for x1 = (ETA-1)/ETA*x2'] |
| 226 |
0= -(ETA-1)/ETA*x2_cu+y_cu*mc_cu*ptil_cu^(-ETA-1) +ALFA*BETTA*myla_cup*(ptil_cu/ptil_cup)^(-ETA-1)*(1/pai_cup)^(-ETA)*(ETA-1)/ETA*x2_cup*myzstar_cup; |
| 227 |
|
| 228 |
[name='Nonlinear pricing, relation for x2'] |
| 229 |
0=-x2_cu+y_cu*ptil_cu^-ETA +ALFA*BETTA*myla_cup*(ptil_cu/ptil_cup)^(-ETA)*(1/pai_cup)^(1-ETA)*x2_cup*myzstar_cup; |
| 230 |
|
| 231 |
[name='Nonlinear pricing, relation for s'] |
| 232 |
0= -s_cup+(1-ALFA)*ptil_cu^(-ETA)+ALFA*(pai_cu/1)^ETA*s_cu; |
| 233 |
|
| 234 |
[name='Interest rate rule'] |
| 235 |
0 = -log(r_cu/R)+RHOR*log(r_ba1/R)+(1-RHOR)*(BETTAPAI*log(pai_cu/PAI)+BETTAY*log(y_cu/Y) + BETTAxhr*(BETTAxhr40*xhr40_cu - removeMeanXhr*Exhr_cu)); |
| 236 |
|
| 237 |
[name='Production function'] |
| 238 |
0 = -y_cu*s_cup + a_cu *(k_cu *myyps_cu ^(-1/(1-THETA))*myz_cu ^-1)^THETA*h_cu ^(1-THETA); |
| 239 |
|
| 240 |
[name='Relation for physical capital stock'] |
| 241 |
0= -k_cup + (1-DELTA)*k_cu*(myyps_cu*myzstar_cu)^-1 + iv_cu - iv_cu*KAPAone/2*(iv_cu/IV-1)^2 - k_cu*(myyps_cu*myzstar_cu)^-1*KAPAtwo/2*(iv_cu/k_cu*myyps_cu*myzstar_cu - IV/K*MYYPS*MYZSTAR)^2; |
| 242 |
|
| 243 |
[name='Goverment spending over output'] |
| 244 |
0=-goy_cu + g_cu/y_cu; |
| 245 |
|
| 246 |
[name='The yield curve: p1'] |
| 247 |
0= -p1_cu + 1/r_cu; |
| 248 |
|
| 249 |
@#for i in 2:40 |
| 250 |
[name='The yield curve: p@{i}'] |
| 251 |
0= -p@{i}_cu + BETTA*myla_cup/pai_cup*p@{i-1}_cup; |
| 252 |
@#endfor |
| 253 |
|
| 254 |
[name='Stochastic discount factor'] |
| 255 |
0= -Esdf_cu+ BETTA*myla_cup/pai_cup; |
| 256 |
|
| 257 |
[name='Expected 5 year excess holding period return'] |
| 258 |
0= -xhr20_cu+ log(p19_cup) - log(p20_cu) - log(r_cu); |
| 259 |
|
| 260 |
[name='Expected 10 year excess holding period return'] |
| 261 |
0= -xhr40_cu+ log(p39_cup) - log(p40_cu) - log(r_cu); |
| 262 |
|
| 263 |
[name='Mean of expected excess holding period return in Taylor rule'] |
| 264 |
0= -Exhr_cu + (1-GAMA)*(BETTAxhr40*xhr40_cu) + GAMA*Exhr_cup; |
| 265 |
|
| 266 |
[name='Exogenous process for productivity'] |
| 267 |
0 = -log(a_cu)+RHOA*log(a_ba1) + eps_a; |
| 268 |
|
| 269 |
[name='Exogenous process for government spending'] |
| 270 |
0 = -log(g_cu/G)+RHOG*log(g_ba1/G) + eps_g; |
| 271 |
|
| 272 |
[name='Exogenous process for discount factor shifter'] |
| 273 |
0 = -log(d_cu)+RHOD*log(d_ba1) + eps_d; |
| 274 |
|
| 275 |
[name='Observable annualized consumption growth'] |
| 276 |
Obs_Gr_C = 4*( ln_c -ln_c(-1) + log(MYZSTAR)); |
| 277 |
|
| 278 |
[name='Observable annualized investment growth'] |
| 279 |
Obs_Gr_I = 4*( ln_iv - ln_iv(-1) + log(MYZSTAR)+log(MYYPS)); |
| 280 |
|
| 281 |
[name='Observable annualized inflation'] |
| 282 |
Obs_Infl = 4*( ln_pai); |
| 283 |
|
| 284 |
[name='Observable annualized one-quarter nominal yield'] |
| 285 |
Obs_r1 = 4*( ln_r); |
| 286 |
|
| 287 |
[name='Observable annualized 10-year nominal yield'] |
| 288 |
Obs_r40 = 4*( -1/40*ln_p40); |
| 289 |
|
| 290 |
[name='Observable annualized 10-year ex post excess holding period return'] |
| 291 |
Obs_xhr40 = 4*( ln_p39 - ln_p40(-1) - ln_r(-1) ); |
| 292 |
|
| 293 |
[name='Observable annualized log ratio of government spending to GDP'] |
| 294 |
Obs_GoY = 4*( 1/4*ln_goy); |
| 295 |
|
| 296 |
[name='Observable annualized log of hours'] |
| 297 |
Obs_hours = 4*( 1/100*ln_h); |
| 298 |
end; |
| 299 |
|
| 300 |
|
| 301 |
%-------------------------------------------------------------------------- |
| 302 |
% Steady State Computations |
| 303 |
%-------------------------------------------------------------------------- |
| 304 |
% Based on DSGE_model_yieldCurve_ss.m, getPHI3.m, ObjectGMM.m |
| 305 |
% Note that we include an auxiliary parameter negVf to distinguish whether |
| 306 |
% the steady state value function is positive (negVf=0) or negative (negVf=1). |
| 307 |
% This parameter is endogenously determined in the steady_state_model block. |
| 308 |
|
| 309 |
|
| 310 |
steady_state_model; |
| 311 |
|
| 312 |
% The growth rate in the firms' fixed costs |
| 313 |
MYZSTARBAR = MYYPS^(THETA/(1-THETA))*MYZ; |
| 314 |
|
| 315 |
% The growth rate for lampda |
| 316 |
MYLABAR = MYZSTARBAR^(-PHI2*(1-PHI4)-PHI4); |
| 317 |
|
| 318 |
% The relative optimal price for firms |
| 319 |
PTILBAR = ((1-ALFA*PAI^((CHI-1)*(1-ETA)))/(1-ALFA))^(1/(1-ETA)); |
| 320 |
|
| 321 |
% The state variable s for distortions between output and produktion |
| 322 |
SBAR = ((1-ALFA)*PTILBAR^(-ETA))/(1-ALFA*PAI^((1-CHI)*ETA)); |
| 323 |
|
| 324 |
% The 1-period interest rate |
| 325 |
RBAR = PAI/(BETTA*MYLABAR); |
| 326 |
|
| 327 |
% The market price of capital |
| 328 |
QBAR = 1; |
| 329 |
|
| 330 |
% The real price of renting capital |
| 331 |
RKBAR = QBAR*(MYYPS/(BETTA*MYLABAR)-(1-DELTA)); |
| 332 |
|
| 333 |
% The marginal costs in the firms |
| 334 |
MCBAR = (1-ALFA*BETTA*MYLABAR*PAI^((1-CHI)*ETA)*MYZSTARBAR)*(ETA-1)/ETA*PTILBAR/(1-ALFA*BETTA*MYLABAR*PAI^((CHI-1)*(1-ETA))*MYZSTARBAR); |
| 335 |
|
| 336 |
% The capital stock |
| 337 |
KBAR = H*(RKBAR/(MCBAR*THETA*MYYPS*MYZ^(1-THETA)))^(1/(THETA-1)); |
| 338 |
|
| 339 |
% The wage level |
| 340 |
WBAR = MCBAR*(1-THETA)*MYYPS^(-THETA/(1-THETA))*MYZ^-THETA*(KBAR/H)^THETA; |
| 341 |
|
| 342 |
% The level of investment |
| 343 |
IVBAR = KBAR - (1-DELTA)*KBAR*MYYPS^(-1/(1-THETA))*MYZ^-1; |
| 344 |
|
| 345 |
% The consumption level |
| 346 |
CBAR = ((1-GoY)*(KBAR*MYYPS^(-1/(1-THETA))*MYZ^-1)^THETA*H^(1-THETA))/SBAR-IVBAR; |
| 347 |
|
| 348 |
% The output level |
| 349 |
YBAR = (CBAR + IVBAR)/(1-GoY); |
| 350 |
|
| 351 |
% The value of lambda |
| 352 |
LABAR = (CBAR-B*CBAR*MYZSTARBAR^-1)^-PHI2 - INHABIT*B*BETTA*(CBAR-B*CBAR*MYZSTARBAR^-1)^-PHI2*MYZSTARBAR^(-PHI2*(1-PHI4)-PHI4); |
| 353 |
|
| 354 |
% The value of PHIzero |
| 355 |
PHIzero = LABAR*WBAR*(1-H)^PHI1; |
| 356 |
|
| 357 |
% The level of the value function |
| 358 |
VFBAR = 1/(1-BETTA*MYZSTARBAR^((1-PHI4)*(1-PHI2)))*(1/(1-PHI2)*((CBAR-B*CBAR*MYZSTARBAR^-1)^(1-PHI2)-1)+PHIzero/(1-PHI1)*(1-H)^(1-PHI1)); |
| 359 |
UBAR = 1/(1-PHI2)*((CBAR-B*CBAR*MYZSTARBAR^-1)^(1-PHI2)-1)+PHIzero/(1-PHI1)*(1-H)^(1-PHI1); |
| 360 |
[AA, EVFBAR, PHI3, negVf, info]= AFVRR_steady_helper(VFBAR,RBAR,IVBAR,CBAR,KBAR,LABAR,QBAR,YBAR, BETTA,B,PAI,H,PHIzero,PHI1,PHI2,THETA,MYYPS,MYZ,INHABIT,RRA,CONSxhr40); |
| 361 |
% The value of X2 |
| 362 |
X2BAR = YBAR*PTILBAR^(-ETA)/(1-BETTA*ALFA*MYLABAR*PAI^((CHI-1)*(1-ETA))*MYZSTARBAR); |
| 363 |
|
| 364 |
% Government spending |
| 365 |
GBAR = GoY*YBAR; |
| 366 |
%************************************************************************** |
| 367 |
|
| 368 |
% map into model variables |
| 369 |
ln_k = log(KBAR); |
| 370 |
ln_s = log(SBAR); |
| 371 |
ln_c_ba1 = log(CBAR); |
| 372 |
ln_r_ba1 = log(RBAR); |
| 373 |
ln_a = log(1); |
| 374 |
ln_g = log(GBAR); |
| 375 |
ln_d = log(1); |
| 376 |
|
| 377 |
ln_c = log(CBAR); |
| 378 |
ln_r = log(RBAR); |
| 379 |
ln_pai = log(PAI); |
| 380 |
ln_h = log(H); |
| 381 |
ln_q = log(QBAR); |
| 382 |
ln_evf = log(EVFBAR); |
| 383 |
ln_iv = log(IVBAR); |
| 384 |
ln_x2 = log(X2BAR); |
| 385 |
ln_la = log(LABAR); |
| 386 |
ln_goy = log(GoY); |
| 387 |
ln_Esdf = log(1/RBAR); |
| 388 |
xhr20 = 0; |
| 389 |
xhr40 = 0; |
| 390 |
Exhr = 0; |
| 391 |
% The yield curve |
| 392 |
ln_p1 = log((1/RBAR)^1); |
| 393 |
ln_p2 = log((1/RBAR)^2); |
| 394 |
ln_p3 = log((1/RBAR)^3); |
| 395 |
ln_p4 = log((1/RBAR)^4); |
| 396 |
ln_p5 = log((1/RBAR)^5); |
| 397 |
ln_p6 = log((1/RBAR)^6); |
| 398 |
ln_p7 = log((1/RBAR)^7); |
| 399 |
ln_p8 = log((1/RBAR)^8); |
| 400 |
ln_p9 = log((1/RBAR)^9); |
| 401 |
ln_p10 = log((1/RBAR)^10); |
| 402 |
ln_p11 = log((1/RBAR)^11); |
| 403 |
ln_p12 = log((1/RBAR)^12); |
| 404 |
ln_p13 = log((1/RBAR)^13); |
| 405 |
ln_p14 = log((1/RBAR)^14); |
| 406 |
ln_p15 = log((1/RBAR)^15); |
| 407 |
ln_p16 = log((1/RBAR)^16); |
| 408 |
ln_p17 = log((1/RBAR)^17); |
| 409 |
ln_p18 = log((1/RBAR)^18); |
| 410 |
ln_p19 = log((1/RBAR)^19); |
| 411 |
ln_p20 = log((1/RBAR)^20); |
| 412 |
ln_p21 = log((1/RBAR)^21); |
| 413 |
ln_p22 = log((1/RBAR)^22); |
| 414 |
ln_p23 = log((1/RBAR)^23); |
| 415 |
ln_p24 = log((1/RBAR)^24); |
| 416 |
ln_p25 = log((1/RBAR)^25); |
| 417 |
ln_p26 = log((1/RBAR)^26); |
| 418 |
ln_p27 = log((1/RBAR)^27); |
| 419 |
ln_p28 = log((1/RBAR)^28); |
| 420 |
ln_p29 = log((1/RBAR)^29); |
| 421 |
ln_p30 = log((1/RBAR)^30); |
| 422 |
ln_p31 = log((1/RBAR)^31); |
| 423 |
ln_p32 = log((1/RBAR)^32); |
| 424 |
ln_p33 = log((1/RBAR)^33); |
| 425 |
ln_p34 = log((1/RBAR)^34); |
| 426 |
ln_p35 = log((1/RBAR)^35); |
| 427 |
ln_p36 = log((1/RBAR)^36); |
| 428 |
ln_p37 = log((1/RBAR)^37); |
| 429 |
ln_p38 = log((1/RBAR)^38); |
| 430 |
ln_p39 = log((1/RBAR)^39); |
| 431 |
ln_p40 = log((1/RBAR)^40); |
| 432 |
|
| 433 |
Obs_Gr_C = 4*( log(MYZSTARBAR) ); |
| 434 |
Obs_Gr_I = 4*( log(MYZSTARBAR)+log(MYYPS) ); |
| 435 |
Obs_Infl = 4*( ln_pai ); |
| 436 |
Obs_r1 = 4*( ln_r ); |
| 437 |
Obs_r40 = 4*( -1/40*ln_p40 ); |
| 438 |
Obs_xhr40 = 4*( xhr40 ); |
| 439 |
Obs_GoY = 4*( 1/4*ln_goy ); |
| 440 |
Obs_hours = 4*( 1/100*ln_h ); |
| 441 |
end; |
| 442 |
|
| 443 |
%-------------------------------------------------------------------------- |
| 444 |
% Declare moments to use in estimation |
| 445 |
%-------------------------------------------------------------------------- |
| 446 |
% These are the moments used in the paper; corresponds to momentSet=2 in the replication files |
| 447 |
|
| 448 |
matched_moments; |
| 449 |
%first moments: all |
| 450 |
Obs_Gr_C; |
| 451 |
Obs_Gr_I; |
| 452 |
Obs_Infl; |
| 453 |
Obs_r1; |
| 454 |
Obs_r40; |
| 455 |
Obs_xhr40; |
| 456 |
Obs_GoY; |
| 457 |
Obs_hours; |
| 458 |
|
| 459 |
%second moments |
| 460 |
% (i) all variances, (2) all covariances excluding GoY and hours, (3) own first autocovariances |
| 461 |
Obs_Gr_C*Obs_Gr_C; |
| 462 |
Obs_Gr_C*Obs_Gr_I; |
| 463 |
Obs_Gr_C*Obs_Infl; |
| 464 |
Obs_Gr_C*Obs_r1; |
| 465 |
Obs_Gr_C*Obs_r40; |
| 466 |
Obs_Gr_C*Obs_xhr40; |
| 467 |
|
| 468 |
Obs_Gr_I*Obs_Gr_I; |
| 469 |
Obs_Gr_I*Obs_Infl; |
| 470 |
Obs_Gr_I*Obs_r1; |
| 471 |
Obs_Gr_I*Obs_r40; |
| 472 |
Obs_Gr_I*Obs_xhr40; |
| 473 |
|
| 474 |
Obs_Infl*Obs_Infl; |
| 475 |
Obs_Infl*Obs_r1; |
| 476 |
Obs_Infl*Obs_r40; |
| 477 |
Obs_Infl*Obs_xhr40; |
| 478 |
|
| 479 |
Obs_r1*Obs_r1; |
| 480 |
Obs_r1*Obs_r40; |
| 481 |
Obs_r1*Obs_xhr40; |
| 482 |
|
| 483 |
Obs_r40*Obs_r40; |
| 484 |
Obs_r40*Obs_xhr40; |
| 485 |
|
| 486 |
Obs_xhr40*Obs_xhr40; |
| 487 |
|
| 488 |
Obs_GoY*Obs_GoY; |
| 489 |
|
| 490 |
Obs_hours*Obs_hours; |
| 491 |
|
| 492 |
Obs_Gr_C*Obs_Gr_C(-1); |
| 493 |
Obs_Gr_I*Obs_Gr_I(-1); |
| 494 |
Obs_Infl*Obs_Infl(-1); |
| 495 |
Obs_r1*Obs_r1(-1); |
| 496 |
Obs_r40*Obs_r40(-1); |
| 497 |
Obs_xhr40*Obs_xhr40(-1); |
| 498 |
Obs_GoY*Obs_GoY(-1); |
| 499 |
Obs_hours*Obs_hours(-1); |
| 500 |
end; |
| 501 |
|
| 502 |
|
| 503 |
%-------------------------------------------------------------------------- |
| 504 |
% Create Data |
| 505 |
%-------------------------------------------------------------------------- |
| 506 |
@#ifdef CreateData |
| 507 |
verbatim; |
| 508 |
% From 1961Q3 to 2007Q4 |
| 509 |
DataUS = xlsread('Data_PruningPaper_v5.xlsx','Data_used','E3:M188'); |
| 510 |
% ANNUALIZED (except for hours and GoY) |
| 511 |
% 1 2 3 4 5 6 7 8 9 |
| 512 |
% Lables: Date Gr_C Gr_I GoY hours Infl_C r1 r40 xhr40 |
| 513 |
%label_data = {'Gr_C ', 'Gr_I ','Infl ', 'r1 ', 'r40 ', 'xhr40 ','GoY ', 'hours '}; |
| 514 |
%DataUS = [DataUS(:,2:3) DataUS(:,6:8) DataUS(:,9) log(DataUS(:,4)) 4*log(DataUS(:,5))/100]; |
| 515 |
Obs_Gr_C = DataUS(:,2); |
| 516 |
Obs_Gr_I = DataUS(:,3); |
| 517 |
Obs_Infl = DataUS(:,6); |
| 518 |
Obs_r1 = DataUS(:,7); |
| 519 |
Obs_r40 = DataUS(:,8); |
| 520 |
Obs_xhr40 = DataUS(:,9); |
| 521 |
Obs_GoY = log(DataUS(:,4)); |
| 522 |
Obs_hours = 4*log(DataUS(:,5))/100; |
| 523 |
|
| 524 |
save('AFVRR_data.mat','Obs_Gr_C','Obs_Gr_I','Obs_Infl','Obs_r1','Obs_r40','Obs_xhr40','Obs_GoY','Obs_hours'); |
| 525 |
pause(1); |
| 526 |
end; |
| 527 |
@#endif |