| 1 |
/* |
| 2 |
* This file replicates the estimation of the cash in advance model (termed M1 |
| 3 |
* in the paper) described in Frank Schorfheide (2000): "Loss function-based |
| 4 |
* evaluation of DSGE models", Journal of Applied Econometrics, 15(6), 645-670. |
| 5 |
* |
| 6 |
* The data are taken from the replication package at |
| 7 |
* http://dx.doi.org/10.15456/jae.2022314.0708799949 |
| 8 |
* |
| 9 |
* The prior distribution follows the one originally specified in Schorfheide's |
| 10 |
* paper. Note that the elicited beta prior for rho in the paper |
| 11 |
* implies an asymptote and corresponding prior mode at 0. It is generally |
| 12 |
* recommended to avoid this extreme type of prior. |
| 13 |
* |
| 14 |
* Because the data are already logged and we use the loglinear option to conduct |
| 15 |
* a full log-linearization, we need to use the logdata option. |
| 16 |
* |
| 17 |
* The equations are taken from J. Nason and T. Cogley (1994): "Testing the |
| 18 |
* implications of long-run neutrality for monetary business cycle models", |
| 19 |
* Journal of Applied Econometrics, 9, S37-S70, NC in the following. |
| 20 |
* Note that there is an initial minus sign missing in equation (A1), p. S63. |
| 21 |
* |
| 22 |
* This implementation was originally written by Michel Juillard. Please note that the |
| 23 |
* following copyright notice only applies to this Dynare implementation of the |
| 24 |
* model. |
| 25 |
*/ |
| 26 |
|
| 27 |
/* |
| 28 |
* Copyright © 2004-2025 Dynare Team |
| 29 |
* |
| 30 |
* This file is part of Dynare. |
| 31 |
* |
| 32 |
* Dynare is free software: you can redistribute it and/or modify |
| 33 |
* it under the terms of the GNU General Public License as published by |
| 34 |
* the Free Software Foundation, either version 3 of the License, or |
| 35 |
* (at your option) any later version. |
| 36 |
* |
| 37 |
* Dynare is distributed in the hope that it will be useful, |
| 38 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 39 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 40 |
* GNU General Public License for more details. |
| 41 |
* |
| 42 |
* You should have received a copy of the GNU General Public License |
| 43 |
* along with Dynare. If not, see <https://www.gnu.org/licenses/>. |
| 44 |
*/ |
| 45 |
|
| 46 |
var m ${m}$ (long_name='money growth') |
| 47 |
P ${P}$ (long_name='Price level') |
| 48 |
c ${c}$ (long_name='consumption') |
| 49 |
e ${e}$ (long_name='capital stock') |
| 50 |
W ${W}$ (long_name='Wage rate') |
| 51 |
R ${R}$ (long_name='interest rate') |
| 52 |
k ${k}$ (long_name='capital stock') |
| 53 |
d ${d}$ (long_name='dividends') |
| 54 |
n ${n}$ (long_name='labor') |
| 55 |
l ${l}$ (long_name='loans') |
| 56 |
A |
| 57 |
gy_obs ${\Delta \ln GDP}$ (long_name='detrended capital stock') |
| 58 |
gp_obs ${\Delta \ln P}$ (long_name='detrended capital stock') |
| 59 |
y ${y}$ (long_name='detrended output') |
| 60 |
dA ${\Delta A}$ (long_name='TFP growth') |
| 61 |
; |
| 62 |
varexo e_a ${\epsilon_A}$ (long_name='TFP shock') |
| 63 |
e_m ${\epsilon_M}$ (long_name='Money growth shock') |
| 64 |
; |
| 65 |
|
| 66 |
parameters alp ${\alpha}$ (long_name='capital share') |
| 67 |
bet ${\beta}$ (long_name='discount factor') |
| 68 |
gam ${\gamma}$ (long_name='long-run TFP growth') |
| 69 |
logmst ${\log(m^*)}$ (long_name='long-run money growth') |
| 70 |
rho ${\rho}$ (long_name='autocorrelation money growth') |
| 71 |
phi ${\phi}$ (long_name='labor weight in consumption') |
| 72 |
del ${\delta}$ (long_name='depreciation rate') |
| 73 |
; |
| 74 |
|
| 75 |
% roughly picked values to allow simulating the model before estimation |
| 76 |
alp = 0.33; |
| 77 |
bet = 0.99; |
| 78 |
gam = 0.003; |
| 79 |
logmst = log(1.011); |
| 80 |
rho = 0.7; |
| 81 |
phi = 0.787; |
| 82 |
del = 0.02; |
| 83 |
|
| 84 |
model; |
| 85 |
[name='NC before eq. (1), TFP growth equation'] |
| 86 |
dA = exp(gam+e_a); |
| 87 |
[name='NC eq. (2), money growth rate'] |
| 88 |
log(m) = (1-rho)*logmst + rho*log(m(-1))+e_m; |
| 89 |
[name='NC eq. (A1), Euler equation'] |
| 90 |
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; |
| 91 |
[name='NC below eq. (A1), firm borrowing constraint'] |
| 92 |
W = l/n; |
| 93 |
[name='NC eq. (A2), intratemporal labour market condition'] |
| 94 |
-(phi/(1-phi))*(c*P/(1-n))+l/n = 0; |
| 95 |
[name='NC below eq. (A2), credit market clearing'] |
| 96 |
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W; |
| 97 |
[name='NC eq. (A3), credit market optimality'] |
| 98 |
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0; |
| 99 |
[name='NC eq. (18), aggregate resource constraint'] |
| 100 |
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1); |
| 101 |
[name='NC eq. (19), money market condition'] |
| 102 |
P*c = m; |
| 103 |
[name='NC eq. (20), credit market equilibrium condition'] |
| 104 |
m-1+d = l; |
| 105 |
[name='Definition TFP shock'] |
| 106 |
e = exp(e_a); |
| 107 |
[name='Implied by NC eq. (18), production function'] |
| 108 |
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); |
| 109 |
[name='Observation equation GDP growth'] |
| 110 |
gy_obs = dA*y/y(-1); |
| 111 |
[name='Observation equation price level'] |
| 112 |
gp_obs = (P/P(-1))*m(-1)/dA; |
| 113 |
A= rho*A(-1)+e_a; |
| 114 |
end; |
| 115 |
|
| 116 |
shocks; |
| 117 |
var e_a; stderr 0.01; |
| 118 |
var e_m; stderr 0.005; |
| 119 |
end; |
| 120 |
|
| 121 |
steady_state_model; |
| 122 |
dA = exp(gam); |
| 123 |
gst = 1/dA; |
| 124 |
m = exp(logmst); |
| 125 |
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1)); |
| 126 |
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/m )^(-1); |
| 127 |
nust = phi*m^2/( (1-alp)*(1-phi)*bet*gst^alp*khst^alp ); |
| 128 |
n = xist/(nust+xist); |
| 129 |
P = xist + nust; |
| 130 |
k = khst*n; |
| 131 |
|
| 132 |
l = phi*m*n/( (1-phi)*(1-n) ); |
| 133 |
c = m/P; |
| 134 |
d = l - m + 1; |
| 135 |
y = k^alp*n^(1-alp)*gst^alp; |
| 136 |
R = m/bet; |
| 137 |
W = l/n; |
| 138 |
ist = y-c; |
| 139 |
q = 1 - d; |
| 140 |
|
| 141 |
e = 1; |
| 142 |
|
| 143 |
gp_obs = m/dA; |
| 144 |
gy_obs = dA; |
| 145 |
end; |
| 146 |
|
| 147 |
|
| 148 |
stoch_simul(order=1,irf=0); |
| 149 |
|
| 150 |
forecast(periods=500,conf_sig=0.95) A; |
| 151 |
%% get theoretical forecast error variance for AR(1) process: |
| 152 |
var_analytical=NaN(1+500,1); |
| 153 |
var_analytical(1)=0; %zero variance in initial period |
| 154 |
for ii=1:500 |
| 155 |
var_analytical(ii+1)=var_analytical(ii)+(rho^(ii-1))^2*0.01^2; |
| 156 |
end |
| 157 |
std_analytical=sqrt(var_analytical); |
| 158 |
|
| 159 |
if norm(oo_.forecast.Mean.A-0,Inf)>1e-9 |
| 160 |
error('Mean forecast does not match theoretical moments') |
| 161 |
end |
| 162 |
if norm(oo_.forecast.HPDsup.A-norminv(0.975)*std_analytical(2:end),Inf)>1e-9 |
| 163 |
error('Forecast variance does not match theoretical moments') |
| 164 |
end |
| 165 |
|
| 166 |
varobs A; |
| 167 |
|
| 168 |
shocks; |
| 169 |
var e_a=0.01^2; |
| 170 |
var A=0.01^2; |
| 171 |
end; |
| 172 |
|
| 173 |
forecast(periods=500,conf_sig=0.95) A; |
| 174 |
std_analytical_ME=sqrt(var_analytical+0.01^2); |
| 175 |
if norm(oo_.forecast.Mean.A-0,Inf)>1e-9 |
| 176 |
error('Mean forecast with ME does not match theoretical moments') |
| 177 |
end |
| 178 |
if norm(oo_.forecast.HPDsup.A-norminv(0.975)*std_analytical(2:end),Inf)>1e-9 |
| 179 |
error('Forecast variance with ME does not match theoretical moments') |
| 180 |
end |
| 181 |
if norm(oo_.forecast.HPDsup_ME.A-norminv(0.975)*std_analytical_ME(2:end),Inf)>1e-9 |
| 182 |
error('Forecast variance with ME does not match theoretical moments') |
| 183 |
end |
| 184 |
|
| 185 |
|
| 186 |
forecast(periods=500,conf_sig=0.95); |
| 187 |
std_analytical_ME=sqrt(var_analytical+0.01^2); |
| 188 |
if norm(oo_.forecast.Mean.A-0,Inf)>1e-9 |
| 189 |
error('Mean forecast with ME does not match theoretical moments') |
| 190 |
end |
| 191 |
if norm(oo_.forecast.HPDsup.A-norminv(0.975)*std_analytical(2:end),Inf)>1e-9 |
| 192 |
error('Forecast variance with ME does not match theoretical moments') |
| 193 |
end |
| 194 |
if norm(oo_.forecast.HPDsup_ME.A-norminv(0.975)*std_analytical_ME(2:end),Inf)>1e-9 |
| 195 |
error('Forecast variance with ME does not match theoretical moments') |
| 196 |
end |