Debian Codegraph @

tests/kalman_initial_state/fs2000_ns_smoother_only_initial_state.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
19 /*
20 * Copyright © 2004-2010 Dynare Team
21 *
22 * This file is part of Dynare.
23 *
24 * Dynare is free software: you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation, either version 3 of the License, or
27 * (at your option) any later version.
28 *
29 * Dynare is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
36 */
37
38 var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA;
39 varexo e_a e_m;
40
41 parameters alp bet gam mst rho psi del;
42
43 alp = 0.33;
44 bet = 0.99;
45 gam = 0.003;
46 mst = 1.011;
47 rho = 0.7;
48 psi = 0.787;
49 del = 0.02;
50
51 model;
52 dA = exp(gam+e_a);
53 log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
54 -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;
55 W = l/n;
56 -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
57 R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
58 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;
59 c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
60 P*c = m;
61 m-1+d = l;
62 e = exp(e_a);
63 y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
64 gy_obs = dA*y/y(-1);
65 gp_obs = (P/P(-1))*m(-1)/dA;
66 Y_obs/Y_obs(-1) = gy_obs;
67 P_obs/P_obs(-1) = gp_obs;
68 end;
69
70 steady_state_model;
71 dA = exp(gam);
72 gst = 1/dA;
73 m = mst;
74 khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
75 xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
76 nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
77 n = xist/(nust+xist);
78 P = xist + nust;
79 k = khst*n;
80
81 l = psi*mst*n/( (1-psi)*(1-n) );
82 c = mst/P;
83 d = l - mst + 1;
84 y = k^alp*n^(1-alp)*gst^alp;
85 R = mst/bet;
86 W = l/n;
87 ist = y-c;
88 q = 1 - d;
89
90 e = 1;
91
92 gp_obs = m/dA;
93 gy_obs = dA;
94 Y_obs = gy_obs;
95 P_obs = gp_obs;
96 end;
97
98 filter_initial_state;
99 P(0)=2.24;
100 k(0)=5.8;
101 y(0)=0.58;
102 m(0)=1.01;
103 Y_obs(0)=1;
104 P_obs(0)=1;
105 end;
106
107 shocks;
108 var e_a; stderr 0.014;
109 var e_m; stderr 0.005;
110 end;
111
112 varobs P_obs Y_obs;
113
114 observation_trends;
115 P_obs (log(mst)-gam);
116 Y_obs (gam);
117 end;
118
119 estimation(order=1, datafile='../fs2000/fsdat_simul', mode_compute=0,nobs=192, loglinear,diffuse_filter, smoother,smoothed_state_uncertainty) m P c e W R k d n l gy_obs gp_obs y dA;
120 estimation(order=1, datafile='../fs2000/fsdat_simul', mode_compute=0,nobs=192, loglinear,diffuse_filter, smoother,kalman_algo=3,smoothed_state_uncertainty) m P c e W R k d n l gy_obs gp_obs y dA;
121 estimation(order=1, datafile='../fs2000/fsdat_simul', mode_compute=0,nobs=192, loglinear,diffuse_filter, smoother,kalman_algo=4,smoothed_state_uncertainty) m P c e W R k d n l gy_obs gp_obs y dA;