Debian Codegraph @

tests/ecb/SUR/panel_var_diff_NB_simulation_test.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
24 varexo
25 res_U2_Q_YED
26 res_U2_G_YER
27 res_U2_STN
28 res_U2_ESTN
29 res_U2_EHIC
30 res_DE_Q_YED
31 res_DE_G_YER
32 res_DE_EHIC
33 ;
34
35 parameters
36 u2_q_yed_ecm_u2_q_yed_L1
37 u2_q_yed_ecm_u2_stn_L1
38 u2_q_yed_u2_g_yer_L1
39 u2_q_yed_u2_stn_L1
40 u2_g_yer_ecm_u2_q_yed_L1
41 u2_g_yer_ecm_u2_stn_L1
42 u2_g_yer_u2_q_yed_L1
43 u2_g_yer_u2_g_yer_L1
44 u2_g_yer_u2_stn_L1
45 u2_stn_ecm_u2_q_yed_L1
46 u2_stn_ecm_u2_stn_L1
47 u2_stn_u2_q_yed_L1
48 u2_stn_u2_g_yer_L1
49 u2_estn_u2_estn_L1
50 u2_ehic_u2_ehic_L1
51
52 de_q_yed_ecm_de_q_yed_L1
53 de_q_yed_ecm_u2_stn_L1
54 de_q_yed_de_g_yer_L1
55 de_q_yed_u2_stn_L1
56 de_g_yer_ecm_de_q_yed_L1
57 de_g_yer_ecm_u2_stn_L1
58 de_g_yer_de_q_yed_L1
59 de_g_yer_de_g_yer_L1
60 de_g_yer_u2_stn_L1
61 de_ehic_de_ehic_L1
62
63
64 ;
65
66 u2_q_yed_ecm_u2_q_yed_L1 = -0.82237516589315 ;
67 u2_q_yed_ecm_u2_stn_L1 = -0.323715338568976 ;
68 u2_q_yed_u2_g_yer_L1 = 0.0401361895021084 ;
69 u2_q_yed_u2_stn_L1 = 0.058397703958446 ;
70 u2_g_yer_ecm_u2_q_yed_L1 = 0.0189896046977421 ;
71 u2_g_yer_ecm_u2_stn_L1 = -0.109597659887432 ;
72 u2_g_yer_u2_q_yed_L1 = 0.0037667967632025 ;
73 u2_g_yer_u2_g_yer_L1 = 0.480506381923644 ;
74 u2_g_yer_u2_stn_L1 = -0.0722359286123494 ;
75 u2_stn_ecm_u2_q_yed_L1 = -0.0438500662608356 ;
76 u2_stn_ecm_u2_stn_L1 = -0.153283917138772 ;
77 u2_stn_u2_q_yed_L1 = 0.0328744983772825 ;
78 u2_stn_u2_g_yer_L1 = 0.292121949736756 ;
79 u2_estn_u2_estn_L1 = 1 ;
80 u2_ehic_u2_ehic_L1 = 1 ;
81
82 de_q_yed_ecm_de_q_yed_L1 = -0.822375165893149 ;
83 de_q_yed_ecm_u2_stn_L1 = -0.323715338568977 ;
84 de_q_yed_de_g_yer_L1 = 0.0401361895021082 ;
85 de_q_yed_u2_stn_L1 = 0.0583977039584461 ;
86 de_g_yer_ecm_de_q_yed_L1 = 0.0189896046977422 ;
87 de_g_yer_ecm_u2_stn_L1 = -0.109597659887433 ;
88 de_g_yer_de_q_yed_L1 = 0.00376679676320256;
89 de_g_yer_de_g_yer_L1 = 0.480506381923643 ;
90 de_g_yer_u2_stn_L1 = -0.0722359286123494 ;
91 de_ehic_de_ehic_L1 = 1 ;
92
93
94 model(linear);
95 [name = 'eq1']
96 diff(U2_Q_YED) = u2_q_yed_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
97 + u2_q_yed_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
98 + u2_q_yed_u2_g_yer_L1 * diff(U2_G_YER(-1))
99 + u2_q_yed_u2_stn_L1 * diff(U2_STN(-1))
100 + res_U2_Q_YED ;
101 [name = 'eq2']
102 diff(U2_G_YER) = u2_g_yer_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
103 + u2_g_yer_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
104 + u2_g_yer_u2_q_yed_L1 * diff(U2_Q_YED(-1))
105 + u2_g_yer_u2_g_yer_L1 * diff(U2_G_YER(-1))
106 + u2_g_yer_u2_stn_L1 * diff(U2_STN(-1))
107 + res_U2_G_YER ;
108 [name = 'eq3']
109 diff(U2_STN) = u2_stn_ecm_u2_q_yed_L1 * (U2_Q_YED(-1) - U2_EHIC(-1))
110 + u2_stn_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
111 + u2_stn_u2_q_yed_L1 * diff(U2_Q_YED(-1))
112 + u2_stn_u2_g_yer_L1 * diff(U2_G_YER(-1))
113 + res_U2_STN ;
114 [name = 'eq4']
115 U2_ESTN = u2_estn_u2_estn_L1 * U2_ESTN(-1)
116 + res_U2_ESTN ;
117 [name = 'eq5']
118 U2_EHIC = u2_ehic_u2_ehic_L1 * U2_EHIC(-1)
119 + res_U2_EHIC ;
120 [name = 'eq6']
121 diff(DE_Q_YED) = de_q_yed_ecm_de_q_yed_L1 * (DE_Q_YED(-1) - DE_EHIC(-1))
122 + de_q_yed_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
123 + de_q_yed_de_g_yer_L1 * diff(DE_G_YER(-1))
124 + de_q_yed_u2_stn_L1 * diff(U2_STN(-1))
125 + res_DE_Q_YED ;
126 [name = 'eq7']
127 diff(DE_G_YER) = de_g_yer_ecm_de_q_yed_L1 * (DE_Q_YED(-1) - DE_EHIC(-1))
128 + de_g_yer_ecm_u2_stn_L1 * (U2_STN(-1) - U2_ESTN(-1))
129 + de_g_yer_de_q_yed_L1 * diff(DE_Q_YED(-1))
130 + de_g_yer_de_g_yer_L1 * diff(DE_G_YER(-1))
131 + de_g_yer_u2_stn_L1 * diff(U2_STN(-1))
132 + res_DE_G_YER ;
133 [name = 'eq8']
134 DE_EHIC = DE_EHIC(-1) + res_DE_EHIC ;
135
136
137
138 end;
139
140 shocks;
141 var res_U2_Q_YED = 0.005;
142 var res_U2_G_YER = 0.005;
143 var res_U2_STN = 0.005;
144 var res_U2_ESTN = 0.005;
145 var res_U2_EHIC = 0.005;
146 var res_DE_Q_YED = 0.005;
147 var res_DE_G_YER = 0.005;
148 var res_DE_EHIC = 0.005;
149 end;
150
151 NSIMS = 1;
152
153 options_.noprint = 1;
154 calibrated_values = M_.params;
155 Sigma_e = M_.Sigma_e;
156 options_.bnlms.set_dynare_seed_to_default = false;
157
158 nparampool = length(M_.params);
159 BETA = zeros(NSIMS, nparampool);
160 for i=1:NSIMS
161 firstobs = rand(3, length(M_.endo_names));
162 M_.params = calibrated_values;
163 M_.Sigma_e = Sigma_e;
164 simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000);
165 simdata = simdata(simdata.dates(5001:6000));
166 names=regexp(simdata.name, 'res\w*');
167 idxs = [];
168 for j=1:length(names)
169 if isempty(names{j})
170 idxs = [idxs j];
171 end
172 end
173 simdata = sur(simdata{idxs});
174 BETA(i, :) = M_.params';
175 oo_ = rmfield(oo_, 'sur');
176 end
177
178 if NSIMS > 1
179 if max(abs(mean(BETA)' - calibrated_values)) > 1e-2
180 error(['sum(abs(mean(BETA)'' - calibrated_values)) ' num2str(sum(abs(mean(BETA)' - calibrated_values)))]);
181 end
182 else
183 if isoctave
184 good = [-8.352553221721005e-01
185 -3.197321434625048e-01
186 1.833371158471533e-02
187 5.535617069191032e-02
188 1.561983042003726e-02
189 -8.993909626264719e-02
190 1.711785670581707e-02
191 4.757720040796121e-01
192 -8.571091170339767e-02
193 -2.950787496937523e-02
194 -1.364615168219547e-01
195 3.188305976033711e-03
196 2.978809614745770e-01
197 1.000152497234268e+00
198 1.000581562867493e+00
199 -8.285078166013811e-01
200 -3.282738244438672e-01
201 1.707491564143498e-02
202 5.924757545427200e-02
203 4.811130814635710e-02
204 -1.066481566003144e-01
205 4.462314484614635e-03
206 4.862610106651586e-01
207 -7.133910570135164e-02
208 1.000000000000000e+00];
209 else
210 good = [-0.826686196809409
211 -0.346753563700393
212 0.063013991583949
213 0.074802596658698
214 -0.017440119721953
215 -0.127090614348862
216 0.025293280404460
217 0.524290302468866
218 -0.117611206771440
219 -0.027776224547132
220 -0.156590828735908
221 0.054039707976331
222 0.276257666502046
223 1.000417289621684
224 0.999336865129450
225 -0.803258152338916
226 -0.309594948488168
227 0.051602756230521
228 0.039275481081030
229 0.024897596371662
230 -0.096310133845385
231 -0.022630284059365
232 0.461683465196454
233 -0.110278113383114
234 1.000000000000000];
235 end
236 if max(abs(BETA' - good)) > 1e-14
237 error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]);
238 end
239 return
240 end
241
242 for i=1:nparampool
243 figure
244 hold on
245 title(strrep(M_.param_names(i,:), '_', '\_'));
246 histogram(BETA(:,i),50);
247 line([calibrated_values(i) calibrated_values(i)], [0 NSIMS/10], 'LineWidth', 2, 'Color', 'r');
248 hold off
249 end