Debian Codegraph @

tests/kalman/lyapunov/fs2000_lyap.mod

raw
1 /*
2 * This file replicates the estimation of the cash in advance model described
3 * Frank Schorfheide (2000): "Loss function-based evaluation of DSGE models",
4 * Journal of Applied Econometrics, 15(6), 645-670.
5 *
6 * The data are in file "fsdat_simul.m", and have been artificially generated.
7 * They are therefore different from the original dataset used by Schorfheide.
8 *
9 * The equations are taken from J. Nason and T. Cogley (1994): "Testing the
10 * implications of long-run neutrality for monetary business cycle models",
11 * Journal of Applied Econometrics, 9, S37-S70.
12 * Note that there is an initial minus sign missing in equation (A1), p. S63.
13 *
14 * This implementation was written by Michel Juillard. Please note that the
15 * following copyright notice only applies to this Dynare implementation of the
16 * model.
17 *
18 * NB: mode_compute=4 is used to limit the computational time under Octave on some
19 * machines (e.g. on karaba it does not stop after several hours)
20 */
21
22 /*
23 * Copyright © 2004-2026 Dynare Team
24 *
25 * This file is part of Dynare.
26 *
27 * Dynare is free software: you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published by
29 * the Free Software Foundation, either version 3 of the License, or
30 * (at your option) any later version.
31 *
32 * Dynare is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License
38 * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
39 */
40
41 var m P c e W R k d n l gy_obs gp_obs y dA;
42 varexo e_a e_m;
43
44 parameters alp bet gam mst rho psi del;
45
46 alp = 0.33;
47 bet = 0.99;
48 gam = 0.003;
49 mst = 1.011;
50 rho = 0.7;
51 psi = 0.787;
52 del = 0.02;
53
54 model;
55 dA = exp(gam+e_a);
56 log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
57 -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;
58 W = l/n;
59 -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
60 R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
61 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;
62 c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
63 P*c = m;
64 m-1+d = l;
65 e = exp(e_a);
66 y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
67 gy_obs = dA*y/y(-1);
68 gp_obs = (P/P(-1))*m(-1)/dA;
69 end;
70
71 shocks;
72 var e_a; stderr 0.014;
73 var e_m; stderr 0.005;
74 end;
75
76 steady_state_model;
77 dA = exp(gam);
78 gst = 1/dA;
79 m = mst;
80 khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
81 xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
82 nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
83 n = xist/(nust+xist);
84 P = xist + nust;
85 k = khst*n;
86
87 l = psi*mst*n/( (1-psi)*(1-n) );
88 c = mst/P;
89 d = l - mst + 1;
90 y = k^alp*n^(1-alp)*gst^alp;
91 R = mst/bet;
92 W = l/n;
93 ist = y-c;
94 q = 1 - d;
95
96 e = 1;
97
98 gp_obs = m/dA;
99 gy_obs = dA;
100 end;
101
102 steady;
103
104 check;
105
106 estimated_params;
107 alp, beta_pdf, 0.356, 0.02;
108 bet, beta_pdf, 0.993, 0.002;
109 gam, normal_pdf, 0.0085, 0.003;
110 mst, normal_pdf, 1.0002, 0.007;
111 rho, beta_pdf, 0.129, 0.05;
112 psi, beta_pdf, 0.65, 0.05;
113 del, beta_pdf, 0.01, 0.005;
114 stderr e_a, inv_gamma_pdf, 0.035449, inf;
115 stderr e_m, inv_gamma_pdf, 0.008862, inf;
116 end;
117
118 varobs gp_obs gy_obs;
119
120 options_.plot_priors=0;
121
122 options_.lyapunov_fp = 0;
123 options_.lyapunov_db = 0;
124 options_.lyapunov_srs = 0;
125
126 estimation(lyapunov=doubling,order=1,datafile='../../fs2000/fsdat_simul',silent_optimizer, nobs=192, loglinear, mh_replic=0, mh_nblocks=1, mh_jscale=0.8,nograph, mode_compute=4);
127
128
129 if (isoctave && user_has_octave_package('control')) || (~isoctave && user_has_matlab_license('control_toolbox'))
130 options_.lyapunov_fp = 0;
131 options_.lyapunov_db = 0;
132 options_.lyapunov_srs = 0;
133 estimation(lyapunov=square_root_solver,order=1,datafile='../../fs2000/fsdat_simul',silent_optimizer, nobs=192, loglinear, mh_replic=0, mh_nblocks=1, mh_jscale=0.8,nograph, mode_compute=4);
134 end
135
136 options_.lyapunov_fp = 0;
137 options_.lyapunov_db = 0;
138 options_.lyapunov_srs = 0;
139 estimation(lyapunov=fixed_point,order=1,datafile='../../fs2000/fsdat_simul',silent_optimizer, nobs=192, loglinear, mh_replic=0, mh_nblocks=1, mh_jscale=0.8,nograph, mode_compute=4);