Debian Codegraph @

tests/ecb/SUR/sur_params_noniterative.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}, {'u2_q_yed_u2_g_yer_L1', 'u2_estn_u2_estn_L1', 'u2_ehic_u2_ehic_L1', 'de_q_yed_de_g_yer_L1', 'u2_g_yer_u2_g_yer_L1', 'u2_stn_u2_q_yed_L1', 'u2_q_yed_ecm_u2_q_yed_L1', 'de_g_yer_u2_stn_L1'}, {}, 'mymodel', true);
174 BETA(i, :) = M_.params';
175 oo_ = rmfield(oo_, 'sur');
176 end
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.387004799504507e-01
184 -3.237153385689760e-01
185 1.627623494498021e-02
186 5.839770395844600e-02
187 1.898960469774210e-02
188 -1.095976598874320e-01
189 3.766796763202500e-03
190 4.616983632734178e-01
191 -7.223592861234940e-02
192 -4.385006626083560e-02
193 -1.532839171387720e-01
194 5.627557877681382e-03
195 2.921219497367560e-01
196 1.000151654801889e+00
197 1.000581567733505e+00
198 -8.223751658931490e-01
199 -3.237153385689770e-01
200 1.795374571546572e-02
201 5.839770395844610e-02
202 1.898960469774220e-02
203 -1.095976598874330e-01
204 3.766796763202560e-03
205 4.805063819236430e-01
206 -5.852923523496190e-02
207 1.000000000000000e+00];
208 else
209 good = [-0.811559435201128
210 -0.323715338568976
211 0.073666282610569
212 0.058397703958446
213 0.018989604697742
214 -0.109597659887432
215 0.003766796763203
216 0.510389966839712
217 -0.072235928612349
218 -0.043850066260836
219 -0.153283917138772
220 0.058739144948151
221 0.292121949736756
222 1.000413662363949
223 0.999337514406012
224 -0.822375165893149
225 -0.323715338568977
226 0.046096335070402
227 0.058397703958446
228 0.018989604697742
229 -0.109597659887433
230 0.003766796763203
231 0.480506381923643
232 -0.111002148299648
233 1.000000000000000];
234 end
235 if max(abs(BETA' - good)) > 2e-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