| 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_de_ehic_L1 * DE_EHIC(-1) |
| 135 |
+ res_DE_EHIC ; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
end; |
| 140 |
|
| 141 |
shocks; |
| 142 |
var res_U2_Q_YED = 0.005; |
| 143 |
var res_U2_G_YER = 0.005; |
| 144 |
var res_U2_STN = 0.005; |
| 145 |
var res_U2_ESTN = 0.005; |
| 146 |
var res_U2_EHIC = 0.005; |
| 147 |
var res_DE_Q_YED = 0.005; |
| 148 |
var res_DE_G_YER = 0.005; |
| 149 |
var res_DE_EHIC = 0.005; |
| 150 |
end; |
| 151 |
|
| 152 |
NSIMS = 1; |
| 153 |
|
| 154 |
calibrated_values = M_.params; |
| 155 |
Sigma_e = M_.Sigma_e; |
| 156 |
|
| 157 |
options_.bnlms.set_dynare_seed_to_default = false; |
| 158 |
|
| 159 |
nparampool = length(M_.params); |
| 160 |
BETA = zeros(NSIMS, nparampool); |
| 161 |
for i=1:NSIMS |
| 162 |
firstobs = rand(3, length(M_.endo_names)); |
| 163 |
M_.params = calibrated_values; |
| 164 |
M_.Sigma_e = Sigma_e; |
| 165 |
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000); |
| 166 |
simdata = simdata(simdata.dates(5001:6000)); |
| 167 |
names=regexp(simdata.name, 'res\w*'); |
| 168 |
idxs = []; |
| 169 |
for j=1:length(names) |
| 170 |
if isempty(names{j}) |
| 171 |
idxs = [idxs j]; |
| 172 |
end |
| 173 |
end |
| 174 |
pooled_fgls(simdata{idxs}, ... |
| 175 |
{'de','u2'}, ... |
| 176 |
{'*_q_yed_ecm_*_q_yed_L1', ... |
| 177 |
'*_q_yed_ecm_u2_stn_L1', ... |
| 178 |
'*_q_yed_*_g_yer_L1', ... |
| 179 |
'*_q_yed_u2_stn_L1', ... |
| 180 |
'*_g_yer_ecm_*_q_yed_L1', ... |
| 181 |
'*_g_yer_ecm_u2_stn_L1', ... |
| 182 |
'*_g_yer_*_q_yed_L1', ... |
| 183 |
'*_g_yer_*_g_yer_L1', ... |
| 184 |
'*_g_yer_u2_stn_L1', ... |
| 185 |
'*_ehic_*_ehic_L1'}); |
| 186 |
BETA(i, :) = M_.params'; |
| 187 |
oo_ = rmfield(oo_, 'pooled_fgls'); |
| 188 |
end |
| 189 |
|
| 190 |
if NSIMS > 1 |
| 191 |
if sum(abs(mean(BETA)' - calibrated_values)) > 1e-2 |
| 192 |
error(['sum(abs(mean(BETA)'' - calibrated_values)) ' num2str(sum(abs(mean(BETA)' - calibrated_values)))]); |
| 193 |
end |
| 194 |
else |
| 195 |
if isoctave |
| 196 |
good = [-8.316948155834608e-01 |
| 197 |
-3.234334069775354e-01 |
| 198 |
1.844389028026164e-02 |
| 199 |
5.681483820127380e-02 |
| 200 |
3.240547937543738e-02 |
| 201 |
-9.766788804673115e-02 |
| 202 |
1.056637137077583e-02 |
| 203 |
4.833681328497947e-01 |
| 204 |
-7.893398290308180e-02 |
| 205 |
-2.936396277337527e-02 |
| 206 |
-1.362519309595106e-01 |
| 207 |
3.082943385113618e-03 |
| 208 |
2.979145726897833e-01 |
| 209 |
1.000152555627138e+00 |
| 210 |
1.000546950369327e+00 |
| 211 |
-8.316948155834608e-01 |
| 212 |
-3.234334069775354e-01 |
| 213 |
1.844389028026164e-02 |
| 214 |
5.681483820127380e-02 |
| 215 |
3.240547937543738e-02 |
| 216 |
-9.766788804673115e-02 |
| 217 |
1.056637137077583e-02 |
| 218 |
4.833681328497947e-01 |
| 219 |
-7.893398290308180e-02 |
| 220 |
1.000546950369327e+00]; |
| 221 |
else |
| 222 |
good = [-0.814463611096955 |
| 223 |
-0.327545854281441 |
| 224 |
0.058155751549620 |
| 225 |
0.056956172127541 |
| 226 |
0.004760467203543 |
| 227 |
-0.110209140210870 |
| 228 |
0.000873625473015 |
| 229 |
0.492984603730353 |
| 230 |
-0.110739844810764 |
| 231 |
-0.026953553332579 |
| 232 |
-0.155433250333810 |
| 233 |
0.053391289583053 |
| 234 |
0.275361374992940 |
| 235 |
1.000446511792020 |
| 236 |
0.999278815424852 |
| 237 |
-0.814463611096955 |
| 238 |
-0.327545854281441 |
| 239 |
0.058155751549620 |
| 240 |
0.056956172127541 |
| 241 |
0.004760467203543 |
| 242 |
-0.110209140210870 |
| 243 |
0.000873625473015 |
| 244 |
0.492984603730353 |
| 245 |
-0.110739844810764 |
| 246 |
0.999278815424852]; |
| 247 |
end |
| 248 |
if max(abs(BETA' - good)) > 1e-14 |
| 249 |
error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]); |
| 250 |
end |
| 251 |
return |
| 252 |
end |
| 253 |
|
| 254 |
for i=1:nparampool |
| 255 |
figure |
| 256 |
hold on |
| 257 |
title(strrep(M_.param_names(i,:), '_', '\_')); |
| 258 |
histogram(BETA(:,i),50); |
| 259 |
line([calibrated_values(i) calibrated_values(i)], [0 NSIMS/10], 'LineWidth', 2, 'Color', 'r'); |
| 260 |
hold off |
| 261 |
end |