Debian Codegraph @

tests/ecb/SUR/panel_var_diff_NB_simulation_zero_eq.mod

raw
1 // --+ options: json=compute +--
2
3 /* REMARK
4 ** ------
5 **
6 ** You need to have the first line on top of the mod file. The options defined on this line are passed
7 ** to the dynare command (you can add other options, separated by spaces or commas). The option defined
8 ** here is mandatory for the decomposition. It forces Dynare to output another representation of the
9 ** model in JSON file (additionaly to the matlab files) which is used here to manipulate the equations.
10 */
11
12 var
13 U2_Q_YED
14 U2_G_YER
15 U2_STN
16 U2_ESTN
17 U2_EHIC
18 DE_Q_YED
19 DE_G_YER
20 DE_EHIC
21 ;
22
23 varexo
24 res_U2_Q_YED
25 res_U2_G_YER
26 res_U2_STN
27 res_DE_Q_YED
28 res_DE_G_YER
29 res_DE_EHIC
30 ;
31
32 parameters
33 u2_q_yed_ecm_u2_q_yed_L1
34 u2_q_yed_ecm_u2_stn_L1
35 u2_q_yed_u2_g_yer_L1
36 u2_q_yed_u2_stn_L1
37 u2_g_yer_ecm_u2_q_yed_L1
38 u2_g_yer_ecm_u2_stn_L1
39 u2_g_yer_u2_q_yed_L1
40 u2_g_yer_u2_g_yer_L1
41 u2_g_yer_u2_stn_L1
42 u2_stn_ecm_u2_q_yed_L1
43 u2_stn_ecm_u2_stn_L1
44 u2_stn_u2_q_yed_L1
45 u2_stn_u2_g_yer_L1
46 u2_estn_u2_estn_L1
47 u2_ehic_u2_ehic_L1
48
49 de_q_yed_ecm_de_q_yed_L1
50 de_q_yed_ecm_u2_stn_L1
51 de_q_yed_de_g_yer_L1
52 de_q_yed_u2_stn_L1
53 de_g_yer_ecm_de_q_yed_L1
54 de_g_yer_ecm_u2_stn_L1
55 de_g_yer_de_q_yed_L1
56 de_g_yer_de_g_yer_L1
57 de_g_yer_u2_stn_L1
58 de_ehic_de_ehic_L1
59 ;
60
61 u2_q_yed_ecm_u2_q_yed_L1 = -0.82237516589315 ;
62 u2_q_yed_ecm_u2_stn_L1 = -0.323715338568976 ;
63 u2_q_yed_u2_g_yer_L1 = 0.0401361895021084 ;
64 u2_q_yed_u2_stn_L1 = 0.058397703958446 ;
65 u2_g_yer_ecm_u2_q_yed_L1 = 0.0189896046977421 ;
66 u2_g_yer_ecm_u2_stn_L1 = -0.109597659887432 ;
67 u2_g_yer_u2_q_yed_L1 = 0.0037667967632025 ;
68 u2_g_yer_u2_g_yer_L1 = 0.480506381923644 ;
69 u2_g_yer_u2_stn_L1 = -0.0722359286123494 ;
70 u2_stn_ecm_u2_q_yed_L1 = -0.0438500662608356 ;
71 u2_stn_ecm_u2_stn_L1 = -0.153283917138772 ;
72 u2_stn_u2_q_yed_L1 = 0.0328744983772825 ;
73 u2_stn_u2_g_yer_L1 = 0.292121949736756 ;
74 u2_estn_u2_estn_L1 = 1 ;
75 u2_ehic_u2_ehic_L1 = 1 ;
76
77 de_q_yed_ecm_de_q_yed_L1 = -0.822375165893149 ;
78 de_q_yed_ecm_u2_stn_L1 = -0.323715338568977 ;
79 de_q_yed_de_g_yer_L1 = 0.0401361895021082 ;
80 de_q_yed_u2_stn_L1 = 0.0583977039584461 ;
81 de_g_yer_ecm_de_q_yed_L1 = 0.0189896046977422 ;
82 de_g_yer_ecm_u2_stn_L1 = -0.109597659887433 ;
83 de_g_yer_de_q_yed_L1 = 0.00376679676320256;
84 de_g_yer_de_g_yer_L1 = 0.480506381923643 ;
85 de_g_yer_u2_stn_L1 = -0.0722359286123494 ;
86 de_ehic_de_ehic_L1 = 1 ;
87
88
89 model(linear);
90 [name = 'eq1']
91 diff(U2_Q_YED) = u2_q_yed_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
92 + u2_q_yed_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
93 + u2_q_yed_u2_g_yer_L1 * diff(U2_G_YER(-1))
94 + u2_q_yed_u2_stn_L1 * diff(U2_STN(-1))
95 + res_U2_Q_YED ;
96
97 [name = 'eq2']
98 diff(U2_G_YER) = u2_g_yer_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
99 + u2_g_yer_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
100 + u2_g_yer_u2_q_yed_L1 * diff(U2_Q_YED(-1))
101 + u2_g_yer_u2_g_yer_L1 * diff(U2_G_YER(-1))
102 + u2_g_yer_u2_stn_L1 * diff(U2_STN(-1))
103 + res_U2_G_YER ;
104
105 [name = 'eq3']
106 diff(U2_STN) = u2_stn_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
107 + u2_stn_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
108 + u2_stn_u2_q_yed_L1 * diff(U2_Q_YED(-1))
109 + u2_stn_u2_g_yer_L1 * diff(U2_G_YER(-1))
110 + res_U2_STN ;
111
112 [name = 'eq4']
113 U2_ESTN = 0 ;
114
115 [name = 'eq5']
116 U2_EHIC = 0 ;
117
118 [name = 'eq6']
119 diff(DE_Q_YED) = de_q_yed_ecm_de_q_yed_L1 * (DE_Q_YED(-1) - DE_EHIC(-1))
120 + de_q_yed_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
121 + de_q_yed_de_g_yer_L1 * diff(DE_G_YER(-1))
122 + de_q_yed_u2_stn_L1 * diff(U2_STN(-1))
123 + res_DE_Q_YED ;
124
125 [name = 'eq7']
126 diff(DE_G_YER) = de_g_yer_ecm_de_q_yed_L1 * (DE_Q_YED(-1) - DE_EHIC(-1))
127 + de_g_yer_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
128 + de_g_yer_de_q_yed_L1 * diff(DE_Q_YED(-1))
129 + de_g_yer_de_g_yer_L1 * diff(DE_G_YER(-1))
130 + de_g_yer_u2_stn_L1 * diff(U2_STN(-1))
131 + res_DE_G_YER ;
132
133 [name = 'eq8']
134 DE_EHIC = DE_EHIC(-1) + res_DE_EHIC ;
135
136 end;
137
138 shocks;
139 var res_U2_Q_YED = 0.005;
140 var res_U2_G_YER = 0.005;
141 var res_U2_STN = 0.005;
142 var res_DE_Q_YED = 0.005;
143 var res_DE_G_YER = 0.005;
144 var res_DE_EHIC = 0.005;
145 end;
146
147 NSIMS = 1;
148
149 options_.noprint = 1;
150 calibrated_values = M_.params;
151 Sigma_e = M_.Sigma_e;
152 options_.bnlms.set_dynare_seed_to_default = false;
153
154 nparampool = length(M_.params);
155 BETA = zeros(NSIMS, nparampool);
156 for i=1:NSIMS
157 firstobs = rand(3, length(M_.endo_names));
158 M_.params = calibrated_values;
159 M_.Sigma_e = Sigma_e;
160 simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000);
161 simdata = simdata(simdata.dates(5001:6000));
162 % fill zeroed-out variables with random data to ensure they are not being referenced
163 simdata.U2_EHIC = dseries(rand(1000, 1), simdata.firstdate, 'U2_EHIC');
164 simdata.U2_ESTN = dseries(rand(1000, 1), simdata.firstdate, 'U2_ESTN');
165 names = regexp(simdata.name, 'res\w*');
166 idxs = [];
167 for j=1:length(names)
168 if isempty(names{j})
169 idxs = [idxs j];
170 end
171 end
172 simdata = sur(simdata{idxs});
173 BETA(i, :) = M_.params';
174 oo_ = rmfield(oo_, 'sur');
175 end
176
177 if NSIMS > 1
178 if max(abs(mean(BETA)' - calibrated_values)) > 1e-2
179 error(['sum(abs(mean(BETA)'' - calibrated_values)) ' num2str(sum(abs(mean(BETA)' - calibrated_values)))]);
180 end
181 else
182 if isoctave
183 good = [-8.508881335545030e-01
184 -3.179264262251253e-01
185 1.706077291589632e-02
186 5.094145179829853e-02
187 2.872070962130504e-02
188 -7.897668797162463e-02
189 1.813470896478606e-02
190 4.750302886967402e-01
191 -1.012751928847461e-01
192 -6.283292307902170e-02
193 -1.545808456642344e-01
194 1.853656209646514e-02
195 3.063655024212261e-01
196 1.000000000000000e+00
197 1.000000000000000e+00
198 -8.099002474688380e-01
199 -3.261126857285238e-01
200 1.076547521814692e-02
201 7.106757398866259e-02
202 5.150937460065234e-02
203 -8.935904867391903e-02
204 2.021540487647845e-03
205 5.175196576194863e-01
206 -8.339003914920010e-02
207 1.000000000000000e+00];
208 else
209 good = [-0.806260229719792
210 -0.354371215026078
211 0.067618717060638
212 0.088053231576354
213 -0.057161898696690
214 -0.136999143481575
215 0.052047088887385
216 0.524022502978068
217 -0.110211572532150
218 -0.041415758049800
219 -0.162997606880957
220 0.091000830792721
221 0.281196660545012
222 1.000000000000000
223 1.000000000000000
224 -0.823354793011220
225 -0.337521089381118
226 0.025493177305917
227 0.059513905441361
228 0.016845886773011
229 -0.151537340795868
230 0.004832174649536
231 0.430883913061161
232 -0.071743697511067
233 1.000000000000000];
234 end
235 if max(abs(BETA' - good)) > 1e-14
236 error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]);
237 end
238 return
239 end
240
241 for i=1:nparampool
242 figure
243 hold on
244 title(strrep(M_.param_names(i,:), '_', '\_'));
245 histogram(BETA(:,i),50);
246 line([calibrated_values(i) calibrated_values(i)], [0 NSIMS/10], 'LineWidth', 2, 'Color', 'r');
247 hold off
248 end