Convert files to Unix EOL
parent
c079ace8c3
commit
02efbd31a8
|
@ -1,53 +1,53 @@
|
||||||
% computes the steady state of fs2000 analyticaly
|
% computes the steady state of fs2000 analyticaly
|
||||||
% largely inspired by the program of F. Schorfheide
|
% largely inspired by the program of F. Schorfheide
|
||||||
function [ys,check] = fs2000ns_steadystate(ys,exe)
|
function [ys,check] = fs2000ns_steadystate(ys,exe)
|
||||||
global M_
|
global M_
|
||||||
|
|
||||||
alp = M_.params(1);
|
alp = M_.params(1);
|
||||||
bet = M_.params(2);
|
bet = M_.params(2);
|
||||||
gam = M_.params(3);
|
gam = M_.params(3);
|
||||||
mst = M_.params(4);
|
mst = M_.params(4);
|
||||||
rho = M_.params(5);
|
rho = M_.params(5);
|
||||||
psi = M_.params(6);
|
psi = M_.params(6);
|
||||||
del = M_.params(7);
|
del = M_.params(7);
|
||||||
|
|
||||||
check = 0;
|
check = 0;
|
||||||
|
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
gst = 1/dA;
|
gst = 1/dA;
|
||||||
m = mst;
|
m = mst;
|
||||||
|
|
||||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||||
n = xist/(nust+xist);
|
n = xist/(nust+xist);
|
||||||
P = xist + nust;
|
P = xist + nust;
|
||||||
k = khst*n;
|
k = khst*n;
|
||||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||||
c = mst/P;
|
c = mst/P;
|
||||||
d = l - mst + 1;
|
d = l - mst + 1;
|
||||||
y = k^alp*n^(1-alp)*gst^alp;
|
y = k^alp*n^(1-alp)*gst^alp;
|
||||||
R = mst/bet;
|
R = mst/bet;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
ist = y-c;
|
ist = y-c;
|
||||||
q = 1 - d;
|
q = 1 - d;
|
||||||
e = 1;
|
e = 1;
|
||||||
|
|
||||||
P_obs = 1;
|
P_obs = 1;
|
||||||
Y_obs = 1;
|
Y_obs = 1;
|
||||||
|
|
||||||
ys =[
|
ys =[
|
||||||
m
|
m
|
||||||
P
|
P
|
||||||
c
|
c
|
||||||
e
|
e
|
||||||
W
|
W
|
||||||
R
|
R
|
||||||
k
|
k
|
||||||
d
|
d
|
||||||
n
|
n
|
||||||
l
|
l
|
||||||
Y_obs
|
Y_obs
|
||||||
P_obs
|
P_obs
|
||||||
y
|
y
|
||||||
dA ];
|
dA ];
|
|
@ -1,210 +1,210 @@
|
||||||
data_q = [
|
data_q = [
|
||||||
18.02 1474.5 150.2
|
18.02 1474.5 150.2
|
||||||
17.94 1538.2 150.9
|
17.94 1538.2 150.9
|
||||||
18.01 1584.5 151.4
|
18.01 1584.5 151.4
|
||||||
18.42 1644.1 152
|
18.42 1644.1 152
|
||||||
18.73 1678.6 152.7
|
18.73 1678.6 152.7
|
||||||
19.46 1693.1 153.3
|
19.46 1693.1 153.3
|
||||||
19.55 1724 153.9
|
19.55 1724 153.9
|
||||||
19.56 1758.2 154.7
|
19.56 1758.2 154.7
|
||||||
19.79 1760.6 155.4
|
19.79 1760.6 155.4
|
||||||
19.77 1779.2 156
|
19.77 1779.2 156
|
||||||
19.82 1778.8 156.6
|
19.82 1778.8 156.6
|
||||||
20.03 1790.9 157.3
|
20.03 1790.9 157.3
|
||||||
20.12 1846 158
|
20.12 1846 158
|
||||||
20.1 1882.6 158.6
|
20.1 1882.6 158.6
|
||||||
20.14 1897.3 159.2
|
20.14 1897.3 159.2
|
||||||
20.22 1887.4 160
|
20.22 1887.4 160
|
||||||
20.27 1858.2 160.7
|
20.27 1858.2 160.7
|
||||||
20.34 1849.9 161.4
|
20.34 1849.9 161.4
|
||||||
20.39 1848.5 162
|
20.39 1848.5 162
|
||||||
20.42 1868.9 162.8
|
20.42 1868.9 162.8
|
||||||
20.47 1905.6 163.6
|
20.47 1905.6 163.6
|
||||||
20.56 1959.6 164.3
|
20.56 1959.6 164.3
|
||||||
20.62 1994.4 164.9
|
20.62 1994.4 164.9
|
||||||
20.78 2020.1 165.7
|
20.78 2020.1 165.7
|
||||||
21 2030.5 166.5
|
21 2030.5 166.5
|
||||||
21.2 2023.6 167.2
|
21.2 2023.6 167.2
|
||||||
21.33 2037.7 167.9
|
21.33 2037.7 167.9
|
||||||
21.62 2033.4 168.7
|
21.62 2033.4 168.7
|
||||||
21.71 2066.2 169.5
|
21.71 2066.2 169.5
|
||||||
22.01 2077.5 170.2
|
22.01 2077.5 170.2
|
||||||
22.15 2071.9 170.9
|
22.15 2071.9 170.9
|
||||||
22.27 2094 171.7
|
22.27 2094 171.7
|
||||||
22.29 2070.8 172.5
|
22.29 2070.8 172.5
|
||||||
22.56 2012.6 173.1
|
22.56 2012.6 173.1
|
||||||
22.64 2024.7 173.8
|
22.64 2024.7 173.8
|
||||||
22.77 2072.3 174.5
|
22.77 2072.3 174.5
|
||||||
22.88 2120.6 175.3
|
22.88 2120.6 175.3
|
||||||
22.92 2165 176.045
|
22.92 2165 176.045
|
||||||
22.91 2223.3 176.727
|
22.91 2223.3 176.727
|
||||||
22.94 2221.4 177.481
|
22.94 2221.4 177.481
|
||||||
23.03 2230.95 178.268
|
23.03 2230.95 178.268
|
||||||
23.13 2279.22 179.694
|
23.13 2279.22 179.694
|
||||||
23.22 2265.48 180.335
|
23.22 2265.48 180.335
|
||||||
23.32 2268.29 181.094
|
23.32 2268.29 181.094
|
||||||
23.4 2238.57 181.915
|
23.4 2238.57 181.915
|
||||||
23.45 2251.68 182.634
|
23.45 2251.68 182.634
|
||||||
23.51 2292.02 183.337
|
23.51 2292.02 183.337
|
||||||
23.56 2332.61 184.103
|
23.56 2332.61 184.103
|
||||||
23.63 2381.01 184.894
|
23.63 2381.01 184.894
|
||||||
23.75 2422.59 185.553
|
23.75 2422.59 185.553
|
||||||
23.81 2448.01 186.203
|
23.81 2448.01 186.203
|
||||||
23.87 2471.86 186.926
|
23.87 2471.86 186.926
|
||||||
23.94 2476.67 187.68
|
23.94 2476.67 187.68
|
||||||
24 2508.7 188.299
|
24 2508.7 188.299
|
||||||
24.07 2538.05 188.906
|
24.07 2538.05 188.906
|
||||||
24.12 2586.26 189.631
|
24.12 2586.26 189.631
|
||||||
24.29 2604.62 190.362
|
24.29 2604.62 190.362
|
||||||
24.35 2666.69 190.954
|
24.35 2666.69 190.954
|
||||||
24.41 2697.54 191.56
|
24.41 2697.54 191.56
|
||||||
24.52 2729.63 192.256
|
24.52 2729.63 192.256
|
||||||
24.64 2739.75 192.938
|
24.64 2739.75 192.938
|
||||||
24.77 2808.88 193.467
|
24.77 2808.88 193.467
|
||||||
24.88 2846.34 193.994
|
24.88 2846.34 193.994
|
||||||
25.01 2898.79 194.647
|
25.01 2898.79 194.647
|
||||||
25.17 2970.48 195.279
|
25.17 2970.48 195.279
|
||||||
25.32 3042.35 195.763
|
25.32 3042.35 195.763
|
||||||
25.53 3055.53 196.277
|
25.53 3055.53 196.277
|
||||||
25.79 3076.51 196.877
|
25.79 3076.51 196.877
|
||||||
26.02 3102.36 197.481
|
26.02 3102.36 197.481
|
||||||
26.14 3127.15 197.967
|
26.14 3127.15 197.967
|
||||||
26.31 3129.53 198.455
|
26.31 3129.53 198.455
|
||||||
26.6 3154.19 199.012
|
26.6 3154.19 199.012
|
||||||
26.9 3177.98 199.572
|
26.9 3177.98 199.572
|
||||||
27.21 3236.18 199.995
|
27.21 3236.18 199.995
|
||||||
27.49 3292.07 200.452
|
27.49 3292.07 200.452
|
||||||
27.75 3316.11 200.997
|
27.75 3316.11 200.997
|
||||||
28.12 3331.22 201.538
|
28.12 3331.22 201.538
|
||||||
28.39 3381.86 201.955
|
28.39 3381.86 201.955
|
||||||
28.73 3390.23 202.419
|
28.73 3390.23 202.419
|
||||||
29.14 3409.65 202.986
|
29.14 3409.65 202.986
|
||||||
29.51 3392.6 203.584
|
29.51 3392.6 203.584
|
||||||
29.94 3386.49 204.086
|
29.94 3386.49 204.086
|
||||||
30.36 3391.61 204.721
|
30.36 3391.61 204.721
|
||||||
30.61 3422.95 205.419
|
30.61 3422.95 205.419
|
||||||
31.02 3389.36 206.13
|
31.02 3389.36 206.13
|
||||||
31.5 3481.4 206.763
|
31.5 3481.4 206.763
|
||||||
31.93 3500.95 207.362
|
31.93 3500.95 207.362
|
||||||
32.27 3523.8 208
|
32.27 3523.8 208
|
||||||
32.54 3533.79 208.642
|
32.54 3533.79 208.642
|
||||||
33.02 3604.73 209.142
|
33.02 3604.73 209.142
|
||||||
33.2 3687.9 209.637
|
33.2 3687.9 209.637
|
||||||
33.49 3726.18 210.181
|
33.49 3726.18 210.181
|
||||||
33.95 3790.44 210.737
|
33.95 3790.44 210.737
|
||||||
34.36 3892.22 211.192
|
34.36 3892.22 211.192
|
||||||
34.94 3919.01 211.663
|
34.94 3919.01 211.663
|
||||||
35.61 3907.08 212.191
|
35.61 3907.08 212.191
|
||||||
36.29 3947.11 212.708
|
36.29 3947.11 212.708
|
||||||
37.01 3908.15 213.144
|
37.01 3908.15 213.144
|
||||||
37.79 3922.57 213.602
|
37.79 3922.57 213.602
|
||||||
38.96 3879.98 214.147
|
38.96 3879.98 214.147
|
||||||
40.13 3854.13 214.7
|
40.13 3854.13 214.7
|
||||||
41.05 3800.93 215.135
|
41.05 3800.93 215.135
|
||||||
41.66 3835.21 215.652
|
41.66 3835.21 215.652
|
||||||
42.41 3907.02 216.289
|
42.41 3907.02 216.289
|
||||||
43.19 3952.48 216.848
|
43.19 3952.48 216.848
|
||||||
43.69 4044.59 217.314
|
43.69 4044.59 217.314
|
||||||
44.15 4072.19 217.776
|
44.15 4072.19 217.776
|
||||||
44.77 4088.49 218.338
|
44.77 4088.49 218.338
|
||||||
45.57 4126.39 218.917
|
45.57 4126.39 218.917
|
||||||
46.32 4176.28 219.427
|
46.32 4176.28 219.427
|
||||||
47.07 4260.08 219.956
|
47.07 4260.08 219.956
|
||||||
47.66 4329.46 220.573
|
47.66 4329.46 220.573
|
||||||
48.63 4328.33 221.201
|
48.63 4328.33 221.201
|
||||||
49.42 4345.51 221.719
|
49.42 4345.51 221.719
|
||||||
50.41 4510.73 222.281
|
50.41 4510.73 222.281
|
||||||
51.27 4552.14 222.933
|
51.27 4552.14 222.933
|
||||||
52.35 4603.65 223.583
|
52.35 4603.65 223.583
|
||||||
53.51 4605.65 224.152
|
53.51 4605.65 224.152
|
||||||
54.65 4615.64 224.737
|
54.65 4615.64 224.737
|
||||||
55.82 4644.93 225.418
|
55.82 4644.93 225.418
|
||||||
56.92 4656.23 226.117
|
56.92 4656.23 226.117
|
||||||
58.18 4678.96 226.754
|
58.18 4678.96 226.754
|
||||||
59.55 4566.62 227.389
|
59.55 4566.62 227.389
|
||||||
61.01 4562.25 228.07
|
61.01 4562.25 228.07
|
||||||
62.59 4651.86 228.689
|
62.59 4651.86 228.689
|
||||||
64.15 4739.16 229.155
|
64.15 4739.16 229.155
|
||||||
65.37 4696.82 229.674
|
65.37 4696.82 229.674
|
||||||
66.65 4753.02 230.301
|
66.65 4753.02 230.301
|
||||||
67.87 4693.76 230.903
|
67.87 4693.76 230.903
|
||||||
68.86 4615.89 231.395
|
68.86 4615.89 231.395
|
||||||
69.72 4634.88 231.906
|
69.72 4634.88 231.906
|
||||||
70.66 4612.08 232.498
|
70.66 4612.08 232.498
|
||||||
71.44 4618.26 233.074
|
71.44 4618.26 233.074
|
||||||
72.08 4662.97 233.546
|
72.08 4662.97 233.546
|
||||||
72.83 4763.57 234.028
|
72.83 4763.57 234.028
|
||||||
73.48 4849 234.603
|
73.48 4849 234.603
|
||||||
74.19 4939.23 235.153
|
74.19 4939.23 235.153
|
||||||
75.02 5053.56 235.605
|
75.02 5053.56 235.605
|
||||||
75.58 5132.87 236.082
|
75.58 5132.87 236.082
|
||||||
76.25 5170.34 236.657
|
76.25 5170.34 236.657
|
||||||
76.81 5203.68 237.232
|
76.81 5203.68 237.232
|
||||||
77.63 5257.26 237.673
|
77.63 5257.26 237.673
|
||||||
78.25 5283.73 238.176
|
78.25 5283.73 238.176
|
||||||
78.76 5359.6 238.789
|
78.76 5359.6 238.789
|
||||||
79.45 5393.57 239.387
|
79.45 5393.57 239.387
|
||||||
79.81 5460.83 239.861
|
79.81 5460.83 239.861
|
||||||
80.22 5466.95 240.368
|
80.22 5466.95 240.368
|
||||||
80.84 5496.29 240.962
|
80.84 5496.29 240.962
|
||||||
81.45 5526.77 241.539
|
81.45 5526.77 241.539
|
||||||
82.09 5561.8 242.009
|
82.09 5561.8 242.009
|
||||||
82.68 5618 242.52
|
82.68 5618 242.52
|
||||||
83.33 5667.39 243.12
|
83.33 5667.39 243.12
|
||||||
84.09 5750.57 243.721
|
84.09 5750.57 243.721
|
||||||
84.67 5785.29 244.208
|
84.67 5785.29 244.208
|
||||||
85.56 5844.05 244.716
|
85.56 5844.05 244.716
|
||||||
86.66 5878.7 245.354
|
86.66 5878.7 245.354
|
||||||
87.44 5952.83 245.966
|
87.44 5952.83 245.966
|
||||||
88.45 6010.96 246.46
|
88.45 6010.96 246.46
|
||||||
89.39 6055.61 247.017
|
89.39 6055.61 247.017
|
||||||
90.13 6087.96 247.698
|
90.13 6087.96 247.698
|
||||||
90.88 6093.51 248.374
|
90.88 6093.51 248.374
|
||||||
92 6152.59 248.928
|
92 6152.59 248.928
|
||||||
93.18 6171.57 249.564
|
93.18 6171.57 249.564
|
||||||
94.14 6142.1 250.299
|
94.14 6142.1 250.299
|
||||||
95.11 6078.96 251.031
|
95.11 6078.96 251.031
|
||||||
96.27 6047.49 251.65
|
96.27 6047.49 251.65
|
||||||
97 6074.66 252.295
|
97 6074.66 252.295
|
||||||
97.7 6090.14 253.033
|
97.7 6090.14 253.033
|
||||||
98.31 6105.25 253.743
|
98.31 6105.25 253.743
|
||||||
99.13 6175.69 254.338
|
99.13 6175.69 254.338
|
||||||
99.79 6214.22 255.032
|
99.79 6214.22 255.032
|
||||||
100.17 6260.74 255.815
|
100.17 6260.74 255.815
|
||||||
100.88 6327.12 256.543
|
100.88 6327.12 256.543
|
||||||
101.84 6327.93 257.151
|
101.84 6327.93 257.151
|
||||||
102.35 6359.9 257.785
|
102.35 6359.9 257.785
|
||||||
102.83 6393.5 258.516
|
102.83 6393.5 258.516
|
||||||
103.51 6476.86 259.191
|
103.51 6476.86 259.191
|
||||||
104.13 6524.5 259.738
|
104.13 6524.5 259.738
|
||||||
104.71 6600.31 260.351
|
104.71 6600.31 260.351
|
||||||
105.39 6629.47 261.04
|
105.39 6629.47 261.04
|
||||||
106.09 6688.61 261.692
|
106.09 6688.61 261.692
|
||||||
106.75 6717.46 262.236
|
106.75 6717.46 262.236
|
||||||
107.24 6724.2 262.847
|
107.24 6724.2 262.847
|
||||||
107.75 6779.53 263.527
|
107.75 6779.53 263.527
|
||||||
108.29 6825.8 264.169
|
108.29 6825.8 264.169
|
||||||
108.91 6882 264.681
|
108.91 6882 264.681
|
||||||
109.24 6983.91 265.258
|
109.24 6983.91 265.258
|
||||||
109.74 7020 265.887
|
109.74 7020 265.887
|
||||||
110.23 7093.12 266.491
|
110.23 7093.12 266.491
|
||||||
111 7166.68 266.987
|
111 7166.68 266.987
|
||||||
111.43 7236.5 267.545
|
111.43 7236.5 267.545
|
||||||
111.76 7311.24 268.171
|
111.76 7311.24 268.171
|
||||||
112.08 7364.63 268.815
|
112.08 7364.63 268.815
|
||||||
];
|
];
|
||||||
%GDPD GDPQ GPOP
|
%GDPD GDPQ GPOP
|
||||||
|
|
||||||
series = zeros(193,2);
|
series = zeros(193,2);
|
||||||
series(:,2) = data_q(:,1);
|
series(:,2) = data_q(:,1);
|
||||||
series(:,1) = 1000*data_q(:,2)./data_q(:,3);
|
series(:,1) = 1000*data_q(:,2)./data_q(:,3);
|
||||||
|
|
||||||
Y_obs = series(:,1);
|
Y_obs = series(:,1);
|
||||||
P_obs = series(:,2);
|
P_obs = series(:,2);
|
||||||
|
|
||||||
series = series(2:193,:)./series(1:192,:);
|
series = series(2:193,:)./series(1:192,:);
|
||||||
|
|
||||||
gy_obs = series(:,1);
|
gy_obs = series(:,1);
|
||||||
gp_obs = series(:,2);
|
gp_obs = series(:,2);
|
||||||
|
|
||||||
ti = [1950:0.25:1997.75];
|
ti = [1950:0.25:1997.75];
|
|
@ -1,157 +1,157 @@
|
||||||
function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
|
function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
|
||||||
|
|
||||||
% Copyright (C) 2007-2012 Dynare Team
|
% Copyright (C) 2007-2012 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
% it under the terms of the GNU General Public License as published by
|
% it under the terms of the GNU General Public License as published by
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
% (at your option) any later version.
|
% (at your option) any later version.
|
||||||
%
|
%
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
% GNU General Public License for more details.
|
% GNU General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
global M_ options_
|
global M_ options_
|
||||||
persistent Hold
|
persistent Hold
|
||||||
|
|
||||||
options_ = set_default_option(options_,'qz_criterium',1.000001);
|
options_ = set_default_option(options_,'qz_criterium',1.000001);
|
||||||
options_ = set_default_option(options_,'solve_maxit',3000);
|
options_ = set_default_option(options_,'solve_maxit',3000);
|
||||||
|
|
||||||
% safeguard against issues like running ramsey policy first and then running discretion
|
% safeguard against issues like running ramsey policy first and then running discretion
|
||||||
if isfield(M_,'orig_model')
|
if isfield(M_,'orig_model')
|
||||||
orig_model = M_.orig_model;
|
orig_model = M_.orig_model;
|
||||||
M_.endo_nbr = orig_model.endo_nbr;
|
M_.endo_nbr = orig_model.endo_nbr;
|
||||||
M_.endo_names = orig_model.endo_names;
|
M_.endo_names = orig_model.endo_names;
|
||||||
M_.lead_lag_incidence = orig_model.lead_lag_incidence;
|
M_.lead_lag_incidence = orig_model.lead_lag_incidence;
|
||||||
M_.maximum_lead = orig_model.maximum_lead;
|
M_.maximum_lead = orig_model.maximum_lead;
|
||||||
M_.maximum_endo_lead = orig_model.maximum_endo_lead;
|
M_.maximum_endo_lead = orig_model.maximum_endo_lead;
|
||||||
M_.maximum_lag = orig_model.maximum_lag;
|
M_.maximum_lag = orig_model.maximum_lag;
|
||||||
M_.maximum_endo_lag = orig_model.maximum_endo_lag;
|
M_.maximum_endo_lag = orig_model.maximum_endo_lag;
|
||||||
else
|
else
|
||||||
M_.orig_model = M_;
|
M_.orig_model = M_;
|
||||||
end
|
end
|
||||||
|
|
||||||
beta = get_optimal_policy_discount_factor(M_.params,M_.param_names);
|
beta = get_optimal_policy_discount_factor(M_.params,M_.param_names);
|
||||||
|
|
||||||
exo_nbr = M_.exo_nbr;
|
exo_nbr = M_.exo_nbr;
|
||||||
if isfield(M_,'orig_model')
|
if isfield(M_,'orig_model')
|
||||||
orig_model = M_.orig_model;
|
orig_model = M_.orig_model;
|
||||||
endo_nbr = orig_model.endo_nbr;
|
endo_nbr = orig_model.endo_nbr;
|
||||||
endo_names = orig_model.endo_names;
|
endo_names = orig_model.endo_names;
|
||||||
lead_lag_incidence = orig_model.lead_lag_incidence;
|
lead_lag_incidence = orig_model.lead_lag_incidence;
|
||||||
MaxLead = orig_model.maximum_lead;
|
MaxLead = orig_model.maximum_lead;
|
||||||
MaxLag = orig_model.maximum_lag;
|
MaxLag = orig_model.maximum_lag;
|
||||||
else
|
else
|
||||||
endo_names = M_.endo_names;
|
endo_names = M_.endo_names;
|
||||||
endo_nbr = M_.endo_nbr;
|
endo_nbr = M_.endo_nbr;
|
||||||
MaxLag=M_.maximum_lag;
|
MaxLag=M_.maximum_lag;
|
||||||
MaxLead=M_.maximum_lead;
|
MaxLead=M_.maximum_lead;
|
||||||
lead_lag_incidence = M_.lead_lag_incidence;
|
lead_lag_incidence = M_.lead_lag_incidence;
|
||||||
end
|
end
|
||||||
|
|
||||||
[U,Uy,W] = feval([M_.fname,'_objective_static'],zeros(endo_nbr,1),[], M_.params);
|
[U,Uy,W] = feval([M_.fname,'_objective_static'],zeros(endo_nbr,1),[], M_.params);
|
||||||
if any(any(Uy~=0))
|
if any(any(Uy~=0))
|
||||||
error(['discretionary_policy: the objective function must have zero ' ...
|
error(['discretionary_policy: the objective function must have zero ' ...
|
||||||
'first order derivatives'])
|
'first order derivatives'])
|
||||||
end
|
end
|
||||||
|
|
||||||
W=reshape(W,endo_nbr,endo_nbr);
|
W=reshape(W,endo_nbr,endo_nbr);
|
||||||
|
|
||||||
klen = MaxLag + MaxLead + 1;
|
klen = MaxLag + MaxLead + 1;
|
||||||
iyv=lead_lag_incidence';
|
iyv=lead_lag_incidence';
|
||||||
% Find the jacobian
|
% Find the jacobian
|
||||||
z = repmat(zeros(endo_nbr,1),1,klen);
|
z = repmat(zeros(endo_nbr,1),1,klen);
|
||||||
z = z(nonzeros(iyv)) ;
|
z = z(nonzeros(iyv)) ;
|
||||||
it_ = MaxLag + 1 ;
|
it_ = MaxLag + 1 ;
|
||||||
|
|
||||||
if exo_nbr == 0
|
if exo_nbr == 0
|
||||||
oo_.exo_steady_state = [] ;
|
oo_.exo_steady_state = [] ;
|
||||||
end
|
end
|
||||||
[junk,jacobia_] = feval([M_.fname '_dynamic'],z, [oo_.exo_simul ...
|
[junk,jacobia_] = feval([M_.fname '_dynamic'],z, [oo_.exo_simul ...
|
||||||
oo_.exo_det_simul], M_.params, zeros(endo_nbr,1), it_);
|
oo_.exo_det_simul], M_.params, zeros(endo_nbr,1), it_);
|
||||||
if any(junk~=0)
|
if any(junk~=0)
|
||||||
error(['discretionary_policy: the model must be written in deviation ' ...
|
error(['discretionary_policy: the model must be written in deviation ' ...
|
||||||
'form and not have constant terms'])
|
'form and not have constant terms'])
|
||||||
end
|
end
|
||||||
|
|
||||||
eq_nbr= size(jacobia_,1);
|
eq_nbr= size(jacobia_,1);
|
||||||
instr_nbr=endo_nbr-eq_nbr;
|
instr_nbr=endo_nbr-eq_nbr;
|
||||||
|
|
||||||
instr_id=nan(instr_nbr,1);
|
instr_id=nan(instr_nbr,1);
|
||||||
for j=1:instr_nbr
|
for j=1:instr_nbr
|
||||||
vj=deblank(Instruments(j,:));
|
vj=deblank(Instruments(j,:));
|
||||||
vj_id=strmatch(vj,endo_names,'exact');
|
vj_id=strmatch(vj,endo_names,'exact');
|
||||||
if ~isempty(vj_id)
|
if ~isempty(vj_id)
|
||||||
instr_id(j)=vj_id;
|
instr_id(j)=vj_id;
|
||||||
else
|
else
|
||||||
error([mfilename,':: instrument ',vj,' not found'])
|
error([mfilename,':: instrument ',vj,' not found'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Indices={'lag','0','lead'};
|
Indices={'lag','0','lead'};
|
||||||
iter=1;
|
iter=1;
|
||||||
for j=1:numel(Indices)
|
for j=1:numel(Indices)
|
||||||
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
|
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
|
||||||
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
|
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
|
||||||
[junk,row,col]=find(lead_lag_incidence(iter,:));
|
[junk,row,col]=find(lead_lag_incidence(iter,:));
|
||||||
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
|
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
|
||||||
iter=iter+1;
|
iter=iter+1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
B=jacobia_(:,nnz(iyv)+1:end);
|
B=jacobia_(:,nnz(iyv)+1:end);
|
||||||
|
|
||||||
%%% MAIN ENGINE %%%
|
%%% MAIN ENGINE %%%
|
||||||
qz_criterium = options_.qz_criterium;
|
qz_criterium = options_.qz_criterium;
|
||||||
solve_maxit = options_.solve_maxit;
|
solve_maxit = options_.solve_maxit;
|
||||||
discretion_tol = options_.discretionary_tol;
|
discretion_tol = options_.discretionary_tol;
|
||||||
|
|
||||||
if ~isempty(Hold)
|
if ~isempty(Hold)
|
||||||
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium,Hold);
|
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium,Hold);
|
||||||
else
|
else
|
||||||
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium);
|
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium);
|
||||||
end
|
end
|
||||||
|
|
||||||
if info
|
if info
|
||||||
dr=[];
|
dr=[];
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
Hold=H;
|
Hold=H;
|
||||||
% Hold=[]; use this line if persistent command is not used.
|
% Hold=[]; use this line if persistent command is not used.
|
||||||
end
|
end
|
||||||
% update the following elements
|
% update the following elements
|
||||||
|
|
||||||
LLI=lead_lag_incidence;
|
LLI=lead_lag_incidence;
|
||||||
LLI(MaxLag,:)=any(H);
|
LLI(MaxLag,:)=any(H);
|
||||||
|
|
||||||
LLI=LLI';
|
LLI=LLI';
|
||||||
tmp=find(LLI);
|
tmp=find(LLI);
|
||||||
LLI(tmp)=1:numel(tmp);
|
LLI(tmp)=1:numel(tmp);
|
||||||
|
|
||||||
M_.lead_lag_incidence = LLI';
|
M_.lead_lag_incidence = LLI';
|
||||||
|
|
||||||
% set the state
|
% set the state
|
||||||
dr=oo_.dr;
|
dr=oo_.dr;
|
||||||
dr.ys =zeros(endo_nbr,1);
|
dr.ys =zeros(endo_nbr,1);
|
||||||
dr=set_state_space(dr,M_);
|
dr=set_state_space(dr,M_);
|
||||||
order_var=dr.order_var;
|
order_var=dr.order_var;
|
||||||
|
|
||||||
T=H(order_var,order_var);
|
T=H(order_var,order_var);
|
||||||
dr.ghu=G(order_var,:);
|
dr.ghu=G(order_var,:);
|
||||||
Selection=any(T);
|
Selection=any(T);
|
||||||
dr.ghx=T(:,Selection);
|
dr.ghx=T(:,Selection);
|
||||||
|
|
||||||
ys=NondistortionarySteadyState(M_);
|
ys=NondistortionarySteadyState(M_);
|
||||||
dr.ys=ys; % <--- dr.ys =zeros(NewEndo_nbr,1);
|
dr.ys=ys; % <--- dr.ys =zeros(NewEndo_nbr,1);
|
||||||
|
|
||||||
function ys=NondistortionarySteadyState(M_)
|
function ys=NondistortionarySteadyState(M_)
|
||||||
if exist([M_.fname,'_steadystate.m'],'file')
|
if exist([M_.fname,'_steadystate.m'],'file')
|
||||||
eval(['ys=',M_.fname,'_steadystate.m;'])
|
eval(['ys=',M_.fname,'_steadystate.m;'])
|
||||||
else
|
else
|
||||||
ys=zeros(M_.endo_nbr,1);
|
ys=zeros(M_.endo_nbr,1);
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,299 +1,299 @@
|
||||||
function [H,G,retcode]=discretionary_policy_engine(AAlag,AA0,AAlead,BB,bigw,instr_id,beta,solve_maxit,discretion_tol,qz_criterium,H00,verbose)
|
function [H,G,retcode]=discretionary_policy_engine(AAlag,AA0,AAlead,BB,bigw,instr_id,beta,solve_maxit,discretion_tol,qz_criterium,H00,verbose)
|
||||||
|
|
||||||
% Solves the discretionary problem for a model of the form:
|
% Solves the discretionary problem for a model of the form:
|
||||||
% AAlag*yy_{t-1}+AA0*yy_t+AAlead*yy_{t+1}+BB*e=0, with W the weight on the
|
% AAlag*yy_{t-1}+AA0*yy_t+AAlead*yy_{t+1}+BB*e=0, with W the weight on the
|
||||||
% variables in vector y_t and instr_id is the location of the instruments
|
% variables in vector y_t and instr_id is the location of the instruments
|
||||||
% in the yy_t vector.
|
% in the yy_t vector.
|
||||||
% We use the Dennis (2007, Macroeconomic Dynamics) algorithm and so we need
|
% We use the Dennis (2007, Macroeconomic Dynamics) algorithm and so we need
|
||||||
% to re-write the model in the form
|
% to re-write the model in the form
|
||||||
% A0*y_t=A1*y_{t-1}+A2*y_{t+1}+A3*x_t+A4*x_{t+1}+A5*e_t, with W the
|
% A0*y_t=A1*y_{t-1}+A2*y_{t+1}+A3*x_t+A4*x_{t+1}+A5*e_t, with W the
|
||||||
% weight on the y_t vector and Q the weight on the x_t vector of
|
% weight on the y_t vector and Q the weight on the x_t vector of
|
||||||
% instruments.
|
% instruments.
|
||||||
|
|
||||||
% Copyright (C) 2007-2012 Dynare Team
|
% Copyright (C) 2007-2012 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
% it under the terms of the GNU General Public License as published by
|
% it under the terms of the GNU General Public License as published by
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
% (at your option) any later version.
|
% (at your option) any later version.
|
||||||
%
|
%
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
% GNU General Public License for more details.
|
% GNU General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if nargin<12
|
if nargin<12
|
||||||
verbose=0;
|
verbose=0;
|
||||||
if nargin<11
|
if nargin<11
|
||||||
H00=[];
|
H00=[];
|
||||||
if nargin<10
|
if nargin<10
|
||||||
qz_criterium=1.000001;
|
qz_criterium=1.000001;
|
||||||
if nargin<9
|
if nargin<9
|
||||||
discretion_tol=sqrt(eps);
|
discretion_tol=sqrt(eps);
|
||||||
if nargin<8
|
if nargin<8
|
||||||
solve_maxit=3000;
|
solve_maxit=3000;
|
||||||
if nargin<7
|
if nargin<7
|
||||||
beta=.99;
|
beta=.99;
|
||||||
if nargin<6
|
if nargin<6
|
||||||
error([mfilename,':: Insufficient number of input arguments'])
|
error([mfilename,':: Insufficient number of input arguments'])
|
||||||
elseif nargin>12
|
elseif nargin>12
|
||||||
error([mfilename,':: Number of input arguments cannot exceed 12'])
|
error([mfilename,':: Number of input arguments cannot exceed 12'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[A0,A1,A2,A3,A4,A5,W,Q,endo_nbr,exo_nbr,aux,endo_augm_id]=GetDennisMatrices(AAlag,AA0,AAlead,BB,bigw,instr_id);
|
[A0,A1,A2,A3,A4,A5,W,Q,endo_nbr,exo_nbr,aux,endo_augm_id]=GetDennisMatrices(AAlag,AA0,AAlead,BB,bigw,instr_id);
|
||||||
% aux is a logical index of the instruments which appear with lags in the
|
% aux is a logical index of the instruments which appear with lags in the
|
||||||
% model. Their location in the state vector is instr_id(aux)
|
% model. Their location in the state vector is instr_id(aux)
|
||||||
% endo_augm_id is index (not logical) of locations of the augmented vector
|
% endo_augm_id is index (not logical) of locations of the augmented vector
|
||||||
% of non-instrumental variables
|
% of non-instrumental variables
|
||||||
|
|
||||||
AuxiliaryVariables_nbr=sum(aux);
|
AuxiliaryVariables_nbr=sum(aux);
|
||||||
H0=zeros(endo_nbr+AuxiliaryVariables_nbr);
|
H0=zeros(endo_nbr+AuxiliaryVariables_nbr);
|
||||||
if ~isempty(H00)
|
if ~isempty(H00)
|
||||||
H0(1:endo_nbr,1:endo_nbr)=H00;clear H00
|
H0(1:endo_nbr,1:endo_nbr)=H00;clear H00
|
||||||
end
|
end
|
||||||
|
|
||||||
H10=H0(endo_augm_id,endo_augm_id);
|
H10=H0(endo_augm_id,endo_augm_id);
|
||||||
F10=H0(instr_id,endo_augm_id);
|
F10=H0(instr_id,endo_augm_id);
|
||||||
|
|
||||||
iter=0;
|
iter=0;
|
||||||
H1=H10;
|
H1=H10;
|
||||||
F1=F10;
|
F1=F10;
|
||||||
while 1
|
while 1
|
||||||
iter=iter+1;
|
iter=iter+1;
|
||||||
P=SylvesterDoubling(W+beta*F1'*Q*F1,beta*H1',H1,discretion_tol,solve_maxit);
|
P=SylvesterDoubling(W+beta*F1'*Q*F1,beta*H1',H1,discretion_tol,solve_maxit);
|
||||||
if any(any(isnan(P)))
|
if any(any(isnan(P)))
|
||||||
P=SylvesterHessenbergSchur(W+beta*F1'*Q*F1,beta*H1',H1);
|
P=SylvesterHessenbergSchur(W+beta*F1'*Q*F1,beta*H1',H1);
|
||||||
if any(any(isnan(P)))
|
if any(any(isnan(P)))
|
||||||
retcode=2;
|
retcode=2;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
D=A0-A2*H1-A4*F1;
|
D=A0-A2*H1-A4*F1;
|
||||||
Dinv=inv(D);
|
Dinv=inv(D);
|
||||||
A3DPD=A3'*Dinv'*P*Dinv;
|
A3DPD=A3'*Dinv'*P*Dinv;
|
||||||
F1=-(Q+A3DPD*A3)\(A3DPD*A1);
|
F1=-(Q+A3DPD*A3)\(A3DPD*A1);
|
||||||
H1=Dinv*(A1+A3*F1);
|
H1=Dinv*(A1+A3*F1);
|
||||||
|
|
||||||
[rcode,NQ]=CheckConvergence([H1;F1]-[H10;F10],iter,solve_maxit,discretion_tol);
|
[rcode,NQ]=CheckConvergence([H1;F1]-[H10;F10],iter,solve_maxit,discretion_tol);
|
||||||
if rcode
|
if rcode
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
if verbose
|
if verbose
|
||||||
disp(NQ)
|
disp(NQ)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
H10=H1;
|
H10=H1;
|
||||||
F10=F1;
|
F10=F1;
|
||||||
end
|
end
|
||||||
|
|
||||||
retcode = 0;
|
retcode = 0;
|
||||||
switch rcode
|
switch rcode
|
||||||
case 3 % nan
|
case 3 % nan
|
||||||
retcode=63;
|
retcode=63;
|
||||||
retcode(2)=10000;
|
retcode(2)=10000;
|
||||||
if verbose
|
if verbose
|
||||||
disp([mfilename,':: NAN elements in the solution'])
|
disp([mfilename,':: NAN elements in the solution'])
|
||||||
end
|
end
|
||||||
case 2% maxiter
|
case 2% maxiter
|
||||||
retcode = 61
|
retcode = 61
|
||||||
if verbose
|
if verbose
|
||||||
disp([mfilename,':: Maximum Number of Iterations reached'])
|
disp([mfilename,':: Maximum Number of Iterations reached'])
|
||||||
end
|
end
|
||||||
case 1
|
case 1
|
||||||
BadEig=max(abs(eig(H1)))>qz_criterium;
|
BadEig=max(abs(eig(H1)))>qz_criterium;
|
||||||
if BadEig
|
if BadEig
|
||||||
retcode=62;
|
retcode=62;
|
||||||
retcode(2)=100*max(abs(eig(H1)));
|
retcode(2)=100*max(abs(eig(H1)));
|
||||||
if verbose
|
if verbose
|
||||||
disp([mfilename,':: Some eigenvalues greater than qz_criterium, Model potentially unstable'])
|
disp([mfilename,':: Some eigenvalues greater than qz_criterium, Model potentially unstable'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if retcode(1)
|
if retcode(1)
|
||||||
H=[];
|
H=[];
|
||||||
G=[];
|
G=[];
|
||||||
else
|
else
|
||||||
F2=-(Q+A3DPD*A3)\(A3DPD*A5);
|
F2=-(Q+A3DPD*A3)\(A3DPD*A5);
|
||||||
H2=Dinv*(A5+A3*F2);
|
H2=Dinv*(A5+A3*F2);
|
||||||
H=zeros(endo_nbr+AuxiliaryVariables_nbr);
|
H=zeros(endo_nbr+AuxiliaryVariables_nbr);
|
||||||
G=zeros(endo_nbr+AuxiliaryVariables_nbr,exo_nbr);
|
G=zeros(endo_nbr+AuxiliaryVariables_nbr,exo_nbr);
|
||||||
H(endo_augm_id,endo_augm_id)=H1;
|
H(endo_augm_id,endo_augm_id)=H1;
|
||||||
H(instr_id,endo_augm_id)=F1;
|
H(instr_id,endo_augm_id)=F1;
|
||||||
G(endo_augm_id,:)=H2;
|
G(endo_augm_id,:)=H2;
|
||||||
G(instr_id,:)=F2;
|
G(instr_id,:)=F2;
|
||||||
|
|
||||||
% Account for auxilliary variables
|
% Account for auxilliary variables
|
||||||
H(:,instr_id(aux))=H(:,end-(AuxiliaryVariables_nbr-1:-1:0));
|
H(:,instr_id(aux))=H(:,end-(AuxiliaryVariables_nbr-1:-1:0));
|
||||||
H=H(1:endo_nbr,1:endo_nbr);
|
H=H(1:endo_nbr,1:endo_nbr);
|
||||||
G=G(1:endo_nbr,:);
|
G=G(1:endo_nbr,:);
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function [rcode,NQ]=CheckConvergence(Q,iter,MaxIter,crit)
|
function [rcode,NQ]=CheckConvergence(Q,iter,MaxIter,crit)
|
||||||
|
|
||||||
NQ=max(max(abs(Q)));% norm(Q); seems too costly
|
NQ=max(max(abs(Q)));% norm(Q); seems too costly
|
||||||
if isnan(NQ)
|
if isnan(NQ)
|
||||||
rcode=3;
|
rcode=3;
|
||||||
elseif iter>MaxIter;
|
elseif iter>MaxIter;
|
||||||
rcode=2;
|
rcode=2;
|
||||||
elseif NQ<crit
|
elseif NQ<crit
|
||||||
rcode=1;
|
rcode=1;
|
||||||
else
|
else
|
||||||
rcode=0;
|
rcode=0;
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function [A00,A11,A22,A33,A44,A55,WW,Q,endo_nbr,exo_nbr,aux,endo_augm_id]=GetDennisMatrices(AAlag,AA0,AAlead,BB,bigw,instr_id)
|
function [A00,A11,A22,A33,A44,A55,WW,Q,endo_nbr,exo_nbr,aux,endo_augm_id]=GetDennisMatrices(AAlag,AA0,AAlead,BB,bigw,instr_id)
|
||||||
[eq_nbr,endo_nbr]=size(AAlag);
|
[eq_nbr,endo_nbr]=size(AAlag);
|
||||||
exo_nbr=size(BB,2);
|
exo_nbr=size(BB,2);
|
||||||
y=setdiff(1:endo_nbr,instr_id);
|
y=setdiff(1:endo_nbr,instr_id);
|
||||||
instr_nbr=numel(instr_id);
|
instr_nbr=numel(instr_id);
|
||||||
|
|
||||||
A0=AA0(:,y);
|
A0=AA0(:,y);
|
||||||
A1=-AAlag(:,y);
|
A1=-AAlag(:,y);
|
||||||
A2=-AAlead(:,y);
|
A2=-AAlead(:,y);
|
||||||
A3=-AA0(:,instr_id);
|
A3=-AA0(:,instr_id);
|
||||||
A4=-AAlead(:,instr_id);
|
A4=-AAlead(:,instr_id);
|
||||||
A5=-BB;
|
A5=-BB;
|
||||||
W=bigw(y,y);
|
W=bigw(y,y);
|
||||||
Q=bigw(instr_id,instr_id);
|
Q=bigw(instr_id,instr_id);
|
||||||
% Adjust for possible lags in instruments by creating auxiliary equations
|
% Adjust for possible lags in instruments by creating auxiliary equations
|
||||||
A6=-AAlag(:,instr_id);
|
A6=-AAlag(:,instr_id);
|
||||||
aux=any(A6);
|
aux=any(A6);
|
||||||
AuxiliaryVariables_nbr=sum(aux);
|
AuxiliaryVariables_nbr=sum(aux);
|
||||||
ny=eq_nbr;
|
ny=eq_nbr;
|
||||||
m=eq_nbr+AuxiliaryVariables_nbr;
|
m=eq_nbr+AuxiliaryVariables_nbr;
|
||||||
A00=zeros(m);A00(1:ny,1:ny)=A0;A00(ny+1:end,ny+1:end)=eye(AuxiliaryVariables_nbr);
|
A00=zeros(m);A00(1:ny,1:ny)=A0;A00(ny+1:end,ny+1:end)=eye(AuxiliaryVariables_nbr);
|
||||||
A11=zeros(m);A11(1:ny,1:ny)=A1;A11(1:ny,ny+1:end)=A6(:,aux);
|
A11=zeros(m);A11(1:ny,1:ny)=A1;A11(1:ny,ny+1:end)=A6(:,aux);
|
||||||
A22=zeros(m);A22(1:ny,1:ny)=A2;
|
A22=zeros(m);A22(1:ny,1:ny)=A2;
|
||||||
A33=zeros(m,instr_nbr);A33(1:ny,1:end)=A3;A33(ny+1:end,aux)=eye(AuxiliaryVariables_nbr);
|
A33=zeros(m,instr_nbr);A33(1:ny,1:end)=A3;A33(ny+1:end,aux)=eye(AuxiliaryVariables_nbr);
|
||||||
A44=zeros(m,instr_nbr);A44(1:ny,1:end)=A4;
|
A44=zeros(m,instr_nbr);A44(1:ny,1:end)=A4;
|
||||||
A55=zeros(m,exo_nbr);A55(1:ny,1:end)=A5;
|
A55=zeros(m,exo_nbr);A55(1:ny,1:end)=A5;
|
||||||
WW=zeros(m);WW(1:ny,1:ny)=W;
|
WW=zeros(m);WW(1:ny,1:ny)=W;
|
||||||
endo_augm_id=setdiff(1:endo_nbr+AuxiliaryVariables_nbr,instr_id);
|
endo_augm_id=setdiff(1:endo_nbr+AuxiliaryVariables_nbr,instr_id);
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function v= SylvesterDoubling (d,g,h,tol,maxit)
|
function v= SylvesterDoubling (d,g,h,tol,maxit)
|
||||||
|
|
||||||
% DOUBLES Solves a Sylvester equation using doubling
|
% DOUBLES Solves a Sylvester equation using doubling
|
||||||
%
|
%
|
||||||
% [v,info] = doubles (g,d,h,tol,maxit) uses a doubling algorithm
|
% [v,info] = doubles (g,d,h,tol,maxit) uses a doubling algorithm
|
||||||
% to solve the Sylvester equation v = d + g v h
|
% to solve the Sylvester equation v = d + g v h
|
||||||
|
|
||||||
v = d;
|
v = d;
|
||||||
for i =1:maxit,
|
for i =1:maxit,
|
||||||
vadd = g*v*h;
|
vadd = g*v*h;
|
||||||
v = v+vadd;
|
v = v+vadd;
|
||||||
if norm (vadd,1) <= (tol*norm(v,1))
|
if norm (vadd,1) <= (tol*norm(v,1))
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
g = g*g;
|
g = g*g;
|
||||||
h = h*h;
|
h = h*h;
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function v = SylvesterHessenbergSchur(d,g,h)
|
function v = SylvesterHessenbergSchur(d,g,h)
|
||||||
%
|
%
|
||||||
% DSYLHS Solves a discrete time sylvester equation using the
|
% DSYLHS Solves a discrete time sylvester equation using the
|
||||||
% Hessenberg-Schur algorithm
|
% Hessenberg-Schur algorithm
|
||||||
%
|
%
|
||||||
% v = DSYLHS(g,d,h) computes the matrix v that satisfies the
|
% v = DSYLHS(g,d,h) computes the matrix v that satisfies the
|
||||||
% discrete time sylvester equation
|
% discrete time sylvester equation
|
||||||
%
|
%
|
||||||
% v = d + g'vh
|
% v = d + g'vh
|
||||||
|
|
||||||
if size(g,1) >= size(h,1)
|
if size(g,1) >= size(h,1)
|
||||||
[u,gbarp] = hess(g');
|
[u,gbarp] = hess(g');
|
||||||
[t,hbar] = schur(h);
|
[t,hbar] = schur(h);
|
||||||
[vbar] = sylvest_private(gbarp,u'*d*t,hbar,1e-15);
|
[vbar] = sylvest_private(gbarp,u'*d*t,hbar,1e-15);
|
||||||
v = u*vbar*t';
|
v = u*vbar*t';
|
||||||
else
|
else
|
||||||
[u,gbar] = schur(g);
|
[u,gbar] = schur(g);
|
||||||
[t,hbarp] = hess(h');
|
[t,hbarp] = hess(h');
|
||||||
[vbar] = sylvest_private(hbarp,t'*d'*u,gbar,1e-15);
|
[vbar] = sylvest_private(hbarp,t'*d'*u,gbar,1e-15);
|
||||||
v = u*vbar'*t';
|
v = u*vbar'*t';
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function v = sylvest_private(g,d,h,tol)
|
function v = sylvest_private(g,d,h,tol)
|
||||||
%
|
%
|
||||||
% SYLVEST Solves a Sylvester equation
|
% SYLVEST Solves a Sylvester equation
|
||||||
%
|
%
|
||||||
% solves the Sylvester equation
|
% solves the Sylvester equation
|
||||||
% v = d + g v h
|
% v = d + g v h
|
||||||
% for v where both g and h must be upper block triangular.
|
% for v where both g and h must be upper block triangular.
|
||||||
% The output info is zero on a successful return.
|
% The output info is zero on a successful return.
|
||||||
% The input tol indicates when an element of g or h should be considered
|
% The input tol indicates when an element of g or h should be considered
|
||||||
% zero.
|
% zero.
|
||||||
|
|
||||||
[m,n] = size(d);
|
[m,n] = size(d);
|
||||||
v = zeros(m,n);
|
v = zeros(m,n);
|
||||||
w = eye(m);
|
w = eye(m);
|
||||||
i = 1;
|
i = 1;
|
||||||
temp = [];
|
temp = [];
|
||||||
|
|
||||||
%First handle the i = 1 case outside the loop
|
%First handle the i = 1 case outside the loop
|
||||||
|
|
||||||
if i< n,
|
if i< n,
|
||||||
if abs(h(i+1,i)) < tol,
|
if abs(h(i+1,i)) < tol,
|
||||||
v(:,i)= (w - g*h(i,i))\d(:,i);
|
v(:,i)= (w - g*h(i,i))\d(:,i);
|
||||||
i = i+1;
|
i = i+1;
|
||||||
else
|
else
|
||||||
A = [w-g*h(i,i) (-g*h(i+1,i));...
|
A = [w-g*h(i,i) (-g*h(i+1,i));...
|
||||||
-g*h(i,i+1) w-g*h(i+1,i+1)];
|
-g*h(i,i+1) w-g*h(i+1,i+1)];
|
||||||
C = [d(:,i); d(:,i+1)];
|
C = [d(:,i); d(:,i+1)];
|
||||||
X = A\C;
|
X = A\C;
|
||||||
v(:,i) = X(1:m,:);
|
v(:,i) = X(1:m,:);
|
||||||
v(:,i+1) = X(m+1:2*m, :);
|
v(:,i+1) = X(m+1:2*m, :);
|
||||||
i = i+2;
|
i = i+2;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%Handle the rest of the matrix with the possible exception of i=n
|
%Handle the rest of the matrix with the possible exception of i=n
|
||||||
|
|
||||||
while i<n,
|
while i<n,
|
||||||
b= i-1;
|
b= i-1;
|
||||||
temp = [temp g*v(:,size(temp,2)+1:b)]; %#ok<AGROW>
|
temp = [temp g*v(:,size(temp,2)+1:b)]; %#ok<AGROW>
|
||||||
if abs(h(i+1,i)) < tol,
|
if abs(h(i+1,i)) < tol,
|
||||||
v(:,i) = (w - g*h(i,i))\(d(:,i) + temp*h(1:b,i));
|
v(:,i) = (w - g*h(i,i))\(d(:,i) + temp*h(1:b,i));
|
||||||
i = i+1;
|
i = i+1;
|
||||||
else
|
else
|
||||||
A = [w - g*h(i,i) (-g*h(i+1,i)); ...
|
A = [w - g*h(i,i) (-g*h(i+1,i)); ...
|
||||||
-g*h(i,i+1) w - g*h(i+1,i+1)];
|
-g*h(i,i+1) w - g*h(i+1,i+1)];
|
||||||
C = [d(:,i) + temp*h(1:b,i); ...
|
C = [d(:,i) + temp*h(1:b,i); ...
|
||||||
d(:,i+1) + temp*h(1:b,i+1)];
|
d(:,i+1) + temp*h(1:b,i+1)];
|
||||||
X = A\C;
|
X = A\C;
|
||||||
v(:,i) = X(1:m,:);
|
v(:,i) = X(1:m,:);
|
||||||
v(:,i+1) = X(m+1:2*m, :);
|
v(:,i+1) = X(m+1:2*m, :);
|
||||||
i = i+2;
|
i = i+2;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%Handle the i = n case if i=n was not in a 2-2 block
|
%Handle the i = n case if i=n was not in a 2-2 block
|
||||||
|
|
||||||
if i==n,
|
if i==n,
|
||||||
b = i-1;
|
b = i-1;
|
||||||
temp = [temp g*v(:,size(temp,2)+1:b)];
|
temp = [temp g*v(:,size(temp,2)+1:b)];
|
||||||
v(:,i) = (w-g*h(i,i))\(d(:,i) + temp*h(1:b,i));
|
v(:,i) = (w-g*h(i,i))\(d(:,i) + temp*h(1:b,i));
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,102 +1,102 @@
|
||||||
function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX)
|
function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX)
|
||||||
% function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX)
|
% function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX)
|
||||||
%
|
%
|
||||||
% given the Jacobian matrix J of moment derivatives w.r.t. parameters
|
% given the Jacobian matrix J of moment derivatives w.r.t. parameters
|
||||||
% computes, for each column of J, the groups of columns from 1 to n that
|
% computes, for each column of J, the groups of columns from 1 to n that
|
||||||
% can repliate at best the derivatives of that column
|
% can repliate at best the derivatives of that column
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% pars : cell array with groupf of params for each column of J for 1 to n
|
% pars : cell array with groupf of params for each column of J for 1 to n
|
||||||
% cosnJ : the cosn of each column with the selected group of columns
|
% cosnJ : the cosn of each column with the selected group of columns
|
||||||
|
|
||||||
% Copyright (C) 2009-2011 Dynare Team
|
% Copyright (C) 2009-2011 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
% it under the terms of the GNU General Public License as published by
|
% it under the terms of the GNU General Public License as published by
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
% (at your option) any later version.
|
% (at your option) any later version.
|
||||||
%
|
%
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
% GNU General Public License for more details.
|
% GNU General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licen
|
% along with Dynare. If not, see <http://www.gnu.org/licen
|
||||||
global M_ options_
|
global M_ options_
|
||||||
|
|
||||||
OutputDirectoryName = CheckPath('Identification',M_.dname);
|
OutputDirectoryName = CheckPath('Identification',M_.dname);
|
||||||
|
|
||||||
k = size(J,2); % number of parameters
|
k = size(J,2); % number of parameters
|
||||||
|
|
||||||
if nargin<2 || isempty(n)
|
if nargin<2 || isempty(n)
|
||||||
n = 4; % max n-tuple
|
n = 4; % max n-tuple
|
||||||
end
|
end
|
||||||
if nargin<3 || isempty(TeX)
|
if nargin<3 || isempty(TeX)
|
||||||
TeX = 0; % max n-tuple
|
TeX = 0; % max n-tuple
|
||||||
end
|
end
|
||||||
|
|
||||||
cosnJ=zeros(k,n);
|
cosnJ=zeros(k,n);
|
||||||
pars{k,n}=[];
|
pars{k,n}=[];
|
||||||
for ll = 1:n,
|
for ll = 1:n,
|
||||||
h = dyn_waitbar(0,['Brute force collinearity for ' int2str(ll) ' parameters.']);
|
h = dyn_waitbar(0,['Brute force collinearity for ' int2str(ll) ' parameters.']);
|
||||||
for ii = 1:k
|
for ii = 1:k
|
||||||
tmp = find([1:k]~=ii);
|
tmp = find([1:k]~=ii);
|
||||||
tmp2 = nchoosek(tmp,ll);
|
tmp2 = nchoosek(tmp,ll);
|
||||||
cosnJ2=zeros(size(tmp2,1),1);
|
cosnJ2=zeros(size(tmp2,1),1);
|
||||||
b=[];
|
b=[];
|
||||||
for jj = 1:size(tmp2,1)
|
for jj = 1:size(tmp2,1)
|
||||||
[cosnJ2(jj,1), b(:,jj)] = cosn([J(:,ii),J(:,tmp2(jj,:))]);
|
[cosnJ2(jj,1), b(:,jj)] = cosn([J(:,ii),J(:,tmp2(jj,:))]);
|
||||||
end
|
end
|
||||||
cosnJ(ii,ll) = max(cosnJ2(:,1));
|
cosnJ(ii,ll) = max(cosnJ2(:,1));
|
||||||
if cosnJ(ii,ll)>1.e-8,
|
if cosnJ(ii,ll)>1.e-8,
|
||||||
if ll>1 && ((cosnJ(ii,ll)-cosnJ(ii,ll-1))<1.e-8),
|
if ll>1 && ((cosnJ(ii,ll)-cosnJ(ii,ll-1))<1.e-8),
|
||||||
pars{ii,ll} = [pars{ii,ll-1} NaN];
|
pars{ii,ll} = [pars{ii,ll-1} NaN];
|
||||||
cosnJ(ii,ll) = cosnJ(ii,ll-1);
|
cosnJ(ii,ll) = cosnJ(ii,ll-1);
|
||||||
else
|
else
|
||||||
pars{ii,ll} = tmp2(find(cosnJ2(:,1)==max(cosnJ2(:,1))),:);
|
pars{ii,ll} = tmp2(find(cosnJ2(:,1)==max(cosnJ2(:,1))),:);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pars{ii,ll} = NaN(1,ll);
|
pars{ii,ll} = NaN(1,ll);
|
||||||
end
|
end
|
||||||
dyn_waitbar(ii/k,h)
|
dyn_waitbar(ii/k,h)
|
||||||
end
|
end
|
||||||
dyn_waitbar_close(h);
|
dyn_waitbar_close(h);
|
||||||
if TeX
|
if TeX
|
||||||
filename = [OutputDirectoryName '/' M_.fname '_collinearity_patterns' int2str(ll) '.TeX'];
|
filename = [OutputDirectoryName '/' M_.fname '_collinearity_patterns' int2str(ll) '.TeX'];
|
||||||
fidTeX = fopen(filename,'w');
|
fidTeX = fopen(filename,'w');
|
||||||
fprintf(fidTeX,'%% TeX-table generated by ident_bruteforce (Dynare).\n');
|
fprintf(fidTeX,'%% TeX-table generated by ident_bruteforce (Dynare).\n');
|
||||||
fprintf(fidTeX,['%% Collinearity patterns with ',int2str(ll),' parameter(s)\n']);
|
fprintf(fidTeX,['%% Collinearity patterns with ',int2str(ll),' parameter(s)\n']);
|
||||||
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
fprintf(fidTeX,'{\\tiny \n');
|
fprintf(fidTeX,'{\\tiny \n');
|
||||||
fprintf(fidTeX,'\\begin{table}\n');
|
fprintf(fidTeX,'\\begin{table}\n');
|
||||||
fprintf(fidTeX,'\\centering\n');
|
fprintf(fidTeX,'\\centering\n');
|
||||||
fprintf(fidTeX,'\\begin{tabular}{l|lc} \n');
|
fprintf(fidTeX,'\\begin{tabular}{l|lc} \n');
|
||||||
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||||
fprintf(fidTeX,' Parameter & Explanatory & cosn \\\\ \n');
|
fprintf(fidTeX,' Parameter & Explanatory & cosn \\\\ \n');
|
||||||
fprintf(fidTeX,' & parameter(s) & \\\\ \n');
|
fprintf(fidTeX,' & parameter(s) & \\\\ \n');
|
||||||
fprintf(fidTeX,'\\hline \\\\ \n');
|
fprintf(fidTeX,'\\hline \\\\ \n');
|
||||||
for i=1:k,
|
for i=1:k,
|
||||||
plist='';
|
plist='';
|
||||||
for ii=1:ll,
|
for ii=1:ll,
|
||||||
plist = [plist ' $' pnames_TeX(pars{i,ll}(ii),:) '$ '];
|
plist = [plist ' $' pnames_TeX(pars{i,ll}(ii),:) '$ '];
|
||||||
end
|
end
|
||||||
fprintf(fidTeX,'$%s$ & [%s] & %7.3f \\\\ \n',...
|
fprintf(fidTeX,'$%s$ & [%s] & %7.3f \\\\ \n',...
|
||||||
pnames_TeX(i,:),...
|
pnames_TeX(i,:),...
|
||||||
plist,...
|
plist,...
|
||||||
cosnJ(i,ll));
|
cosnJ(i,ll));
|
||||||
end
|
end
|
||||||
fprintf(fidTeX,'\\hline\\hline \n');
|
fprintf(fidTeX,'\\hline\\hline \n');
|
||||||
fprintf(fidTeX,'\\end{tabular}\n ');
|
fprintf(fidTeX,'\\end{tabular}\n ');
|
||||||
fprintf(fidTeX,['\\caption{Collinearity patterns with ',int2str(ll),' parameter(s)}\n ']);
|
fprintf(fidTeX,['\\caption{Collinearity patterns with ',int2str(ll),' parameter(s)}\n ']);
|
||||||
fprintf(fidTeX,['\\label{Table:CollinearityPatterns:',int2str(ll),'}\n']);
|
fprintf(fidTeX,['\\label{Table:CollinearityPatterns:',int2str(ll),'}\n']);
|
||||||
fprintf(fidTeX,'\\end{table}\n');
|
fprintf(fidTeX,'\\end{table}\n');
|
||||||
fprintf(fidTeX,'} \n');
|
fprintf(fidTeX,'} \n');
|
||||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||||
fclose(fidTeX);
|
fclose(fidTeX);
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,345 +1,345 @@
|
||||||
function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
|
function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
|
||||||
% function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
|
% function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data,data_index,number_of_observations,no_more_missing_observations)
|
||||||
% Evaluates the posterior kernel of a dsge model.
|
% Evaluates the posterior kernel of a dsge model.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% xparam1 [double] vector of model parameters.
|
% xparam1 [double] vector of model parameters.
|
||||||
% gend [integer] scalar specifying the number of observations.
|
% gend [integer] scalar specifying the number of observations.
|
||||||
% data [double] matrix of data
|
% data [double] matrix of data
|
||||||
% data_index [cell] cell of column vectors
|
% data_index [cell] cell of column vectors
|
||||||
% number_of_observations [integer]
|
% number_of_observations [integer]
|
||||||
% no_more_missing_observations [integer]
|
% no_more_missing_observations [integer]
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% fval : value of the posterior kernel at xparam1.
|
% fval : value of the posterior kernel at xparam1.
|
||||||
% cost_flag : zero if the function returns a penalty, one otherwise.
|
% cost_flag : zero if the function returns a penalty, one otherwise.
|
||||||
% ys : steady state of original endogenous variables
|
% ys : steady state of original endogenous variables
|
||||||
% trend_coeff :
|
% trend_coeff :
|
||||||
% info : vector of informations about the penalty:
|
% info : vector of informations about the penalty:
|
||||||
% 41: one (many) parameter(s) do(es) not satisfied the lower bound
|
% 41: one (many) parameter(s) do(es) not satisfied the lower bound
|
||||||
% 42: one (many) parameter(s) do(es) not satisfied the upper bound
|
% 42: one (many) parameter(s) do(es) not satisfied the upper bound
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
%
|
%
|
||||||
|
|
||||||
% Copyright (C) 2004-2010 Dynare Team
|
% Copyright (C) 2004-2010 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
% it under the terms of the GNU General Public License as published by
|
% it under the terms of the GNU General Public License as published by
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
% (at your option) any later version.
|
% (at your option) any later version.
|
||||||
%
|
%
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
% GNU General Public License for more details.
|
% GNU General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
global bayestopt_ estim_params_ options_ trend_coeff_ M_ oo_
|
global bayestopt_ estim_params_ options_ trend_coeff_ M_ oo_
|
||||||
fval = [];
|
fval = [];
|
||||||
ys = [];
|
ys = [];
|
||||||
trend_coeff = [];
|
trend_coeff = [];
|
||||||
cost_flag = 1;
|
cost_flag = 1;
|
||||||
nobs = size(options_.varobs,1);
|
nobs = size(options_.varobs,1);
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 1. Get the structural parameters & define penalties
|
% 1. Get the structural parameters & define penalties
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb)
|
if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb)
|
||||||
k = find(xparam1 < bayestopt_.lb);
|
k = find(xparam1 < bayestopt_.lb);
|
||||||
fval = bayestopt_.penalty+sum((bayestopt_.lb(k)-xparam1(k)).^2);
|
fval = bayestopt_.penalty+sum((bayestopt_.lb(k)-xparam1(k)).^2);
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
info = 41;
|
info = 41;
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
if options_.mode_compute ~= 1 & any(xparam1 > bayestopt_.ub)
|
if options_.mode_compute ~= 1 & any(xparam1 > bayestopt_.ub)
|
||||||
k = find(xparam1 > bayestopt_.ub);
|
k = find(xparam1 > bayestopt_.ub);
|
||||||
fval = bayestopt_.penalty+sum((xparam1(k)-bayestopt_.ub(k)).^2);
|
fval = bayestopt_.penalty+sum((xparam1(k)-bayestopt_.ub(k)).^2);
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
info = 42;
|
info = 42;
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
Q = M_.Sigma_e;
|
Q = M_.Sigma_e;
|
||||||
H = M_.H;
|
H = M_.H;
|
||||||
for i=1:estim_params_.nvx
|
for i=1:estim_params_.nvx
|
||||||
k =estim_params_.var_exo(i,1);
|
k =estim_params_.var_exo(i,1);
|
||||||
Q(k,k) = xparam1(i)*xparam1(i);
|
Q(k,k) = xparam1(i)*xparam1(i);
|
||||||
end
|
end
|
||||||
offset = estim_params_.nvx;
|
offset = estim_params_.nvx;
|
||||||
if estim_params_.nvn
|
if estim_params_.nvn
|
||||||
for i=1:estim_params_.nvn
|
for i=1:estim_params_.nvn
|
||||||
k = estim_params_.var_endo(i,1);
|
k = estim_params_.var_endo(i,1);
|
||||||
H(k,k) = xparam1(i+offset)*xparam1(i+offset);
|
H(k,k) = xparam1(i+offset)*xparam1(i+offset);
|
||||||
end
|
end
|
||||||
offset = offset+estim_params_.nvn;
|
offset = offset+estim_params_.nvn;
|
||||||
end
|
end
|
||||||
if estim_params_.ncx
|
if estim_params_.ncx
|
||||||
for i=1:estim_params_.ncx
|
for i=1:estim_params_.ncx
|
||||||
k1 =estim_params_.corrx(i,1);
|
k1 =estim_params_.corrx(i,1);
|
||||||
k2 =estim_params_.corrx(i,2);
|
k2 =estim_params_.corrx(i,2);
|
||||||
Q(k1,k2) = xparam1(i+offset)*sqrt(Q(k1,k1)*Q(k2,k2));
|
Q(k1,k2) = xparam1(i+offset)*sqrt(Q(k1,k1)*Q(k2,k2));
|
||||||
Q(k2,k1) = Q(k1,k2);
|
Q(k2,k1) = Q(k1,k2);
|
||||||
end
|
end
|
||||||
[CholQ,testQ] = chol(Q);
|
[CholQ,testQ] = chol(Q);
|
||||||
if testQ %% The variance-covariance matrix of the structural innovations is not definite positive.
|
if testQ %% The variance-covariance matrix of the structural innovations is not definite positive.
|
||||||
%% We have to compute the eigenvalues of this matrix in order to build the penalty.
|
%% We have to compute the eigenvalues of this matrix in order to build the penalty.
|
||||||
a = diag(eig(Q));
|
a = diag(eig(Q));
|
||||||
k = find(a < 0);
|
k = find(a < 0);
|
||||||
if k > 0
|
if k > 0
|
||||||
fval = bayestopt_.penalty+sum(-a(k));
|
fval = bayestopt_.penalty+sum(-a(k));
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
info = 43;
|
info = 43;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
offset = offset+estim_params_.ncx;
|
offset = offset+estim_params_.ncx;
|
||||||
end
|
end
|
||||||
if estim_params_.ncn
|
if estim_params_.ncn
|
||||||
for i=1:estim_params_.ncn
|
for i=1:estim_params_.ncn
|
||||||
k1 = options_.lgyidx2varobs(estim_params_.corrn(i,1));
|
k1 = options_.lgyidx2varobs(estim_params_.corrn(i,1));
|
||||||
k2 = options_.lgyidx2varobs(estim_params_.corrn(i,2));
|
k2 = options_.lgyidx2varobs(estim_params_.corrn(i,2));
|
||||||
H(k1,k2) = xparam1(i+offset)*sqrt(H(k1,k1)*H(k2,k2));
|
H(k1,k2) = xparam1(i+offset)*sqrt(H(k1,k1)*H(k2,k2));
|
||||||
H(k2,k1) = H(k1,k2);
|
H(k2,k1) = H(k1,k2);
|
||||||
end
|
end
|
||||||
[CholH,testH] = chol(H);
|
[CholH,testH] = chol(H);
|
||||||
if testH
|
if testH
|
||||||
a = diag(eig(H));
|
a = diag(eig(H));
|
||||||
k = find(a < 0);
|
k = find(a < 0);
|
||||||
if k > 0
|
if k > 0
|
||||||
fval = bayestopt_.penalty+sum(-a(k));
|
fval = bayestopt_.penalty+sum(-a(k));
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
info = 44;
|
info = 44;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
offset = offset+estim_params_.ncn;
|
offset = offset+estim_params_.ncn;
|
||||||
end
|
end
|
||||||
if estim_params_.np > 0
|
if estim_params_.np > 0
|
||||||
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
|
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
|
||||||
end
|
end
|
||||||
M_.Sigma_e = Q;
|
M_.Sigma_e = Q;
|
||||||
M_.H = H;
|
M_.H = H;
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 2. call model setup & reduction program
|
% 2. call model setup & reduction program
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
[T,R,SteadyState,info] = dynare_resolve(bayestopt_.restrict_var_list,...
|
[T,R,SteadyState,info] = dynare_resolve(bayestopt_.restrict_var_list,...
|
||||||
bayestopt_.restrict_columns,...
|
bayestopt_.restrict_columns,...
|
||||||
bayestopt_.restrict_aux);
|
bayestopt_.restrict_aux);
|
||||||
if info(1) == 1 || info(1) == 2 || info(1) == 5
|
if info(1) == 1 || info(1) == 2 || info(1) == 5
|
||||||
fval = bayestopt_.penalty+1;
|
fval = bayestopt_.penalty+1;
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
return
|
return
|
||||||
elseif info(1) == 3 || info(1) == 4 || info(1)==6 ||info(1) == 19 || info(1) == 20 || info(1) == 21
|
elseif info(1) == 3 || info(1) == 4 || info(1)==6 ||info(1) == 19 || info(1) == 20 || info(1) == 21
|
||||||
fval = bayestopt_.penalty+info(2);
|
fval = bayestopt_.penalty+info(2);
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
bayestopt_.mf = bayestopt_.mf1;
|
bayestopt_.mf = bayestopt_.mf1;
|
||||||
if options_.noconstant
|
if options_.noconstant
|
||||||
constant = zeros(nobs,1);
|
constant = zeros(nobs,1);
|
||||||
else
|
else
|
||||||
if options_.loglinear
|
if options_.loglinear
|
||||||
constant = log(SteadyState(bayestopt_.mfys));
|
constant = log(SteadyState(bayestopt_.mfys));
|
||||||
else
|
else
|
||||||
constant = SteadyState(bayestopt_.mfys);
|
constant = SteadyState(bayestopt_.mfys);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if bayestopt_.with_trend
|
if bayestopt_.with_trend
|
||||||
trend_coeff = zeros(nobs,1);
|
trend_coeff = zeros(nobs,1);
|
||||||
t = options_.trend_coeffs;
|
t = options_.trend_coeffs;
|
||||||
for i=1:length(t)
|
for i=1:length(t)
|
||||||
if ~isempty(t{i})
|
if ~isempty(t{i})
|
||||||
trend_coeff(i) = evalin('base',t{i});
|
trend_coeff(i) = evalin('base',t{i});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
trend = repmat(constant,1,gend)+trend_coeff*[1:gend];
|
trend = repmat(constant,1,gend)+trend_coeff*[1:gend];
|
||||||
else
|
else
|
||||||
trend = repmat(constant,1,gend);
|
trend = repmat(constant,1,gend);
|
||||||
end
|
end
|
||||||
start = options_.presample+1;
|
start = options_.presample+1;
|
||||||
np = size(T,1);
|
np = size(T,1);
|
||||||
mf = bayestopt_.mf;
|
mf = bayestopt_.mf;
|
||||||
no_missing_data_flag = (number_of_observations==gend*nobs);
|
no_missing_data_flag = (number_of_observations==gend*nobs);
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 3. Initial condition of the Kalman filter
|
% 3. Initial condition of the Kalman filter
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
T
|
T
|
||||||
R
|
R
|
||||||
Q
|
Q
|
||||||
R*Q*R'
|
R*Q*R'
|
||||||
pause
|
pause
|
||||||
options_.lik_init = 1;
|
options_.lik_init = 1;
|
||||||
kalman_algo = options_.kalman_algo;
|
kalman_algo = options_.kalman_algo;
|
||||||
if options_.lik_init == 1 % Kalman filter
|
if options_.lik_init == 1 % Kalman filter
|
||||||
if kalman_algo ~= 2
|
if kalman_algo ~= 2
|
||||||
kalman_algo = 1;
|
kalman_algo = 1;
|
||||||
end
|
end
|
||||||
Pstar = lyapunov_symm(T,R*Q*R',options_.qz_criterium,options_.lyapunov_complex_threshold);
|
Pstar = lyapunov_symm(T,R*Q*R',options_.qz_criterium,options_.lyapunov_complex_threshold);
|
||||||
Pinf = [];
|
Pinf = [];
|
||||||
elseif options_.lik_init == 2 % Old Diffuse Kalman filter
|
elseif options_.lik_init == 2 % Old Diffuse Kalman filter
|
||||||
if kalman_algo ~= 2
|
if kalman_algo ~= 2
|
||||||
kalman_algo = 1;
|
kalman_algo = 1;
|
||||||
end
|
end
|
||||||
Pstar = options_.Harvey_scale_factor*eye(np);
|
Pstar = options_.Harvey_scale_factor*eye(np);
|
||||||
Pinf = [];
|
Pinf = [];
|
||||||
elseif options_.lik_init == 3 % Diffuse Kalman filter
|
elseif options_.lik_init == 3 % Diffuse Kalman filter
|
||||||
if kalman_algo ~= 4
|
if kalman_algo ~= 4
|
||||||
kalman_algo = 3;
|
kalman_algo = 3;
|
||||||
end
|
end
|
||||||
[QT,ST] = schur(T);
|
[QT,ST] = schur(T);
|
||||||
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
|
e1 = abs(ordeig(ST)) > 2-options_.qz_criterium;
|
||||||
[QT,ST] = ordschur(QT,ST,e1);
|
[QT,ST] = ordschur(QT,ST,e1);
|
||||||
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
|
k = find(abs(ordeig(ST)) > 2-options_.qz_criterium);
|
||||||
nk = length(k);
|
nk = length(k);
|
||||||
nk1 = nk+1;
|
nk1 = nk+1;
|
||||||
Pinf = zeros(np,np);
|
Pinf = zeros(np,np);
|
||||||
Pinf(1:nk,1:nk) = eye(nk);
|
Pinf(1:nk,1:nk) = eye(nk);
|
||||||
Pstar = zeros(np,np);
|
Pstar = zeros(np,np);
|
||||||
B = QT'*R*Q*R'*QT;
|
B = QT'*R*Q*R'*QT;
|
||||||
for i=np:-1:nk+2
|
for i=np:-1:nk+2
|
||||||
if ST(i,i-1) == 0
|
if ST(i,i-1) == 0
|
||||||
if i == np
|
if i == np
|
||||||
c = zeros(np-nk,1);
|
c = zeros(np-nk,1);
|
||||||
else
|
else
|
||||||
c = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i,i+1:end)')+...
|
c = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i,i+1:end)')+...
|
||||||
ST(i,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i);
|
ST(i,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i);
|
||||||
end
|
end
|
||||||
q = eye(i-nk)-ST(nk1:i,nk1:i)*ST(i,i);
|
q = eye(i-nk)-ST(nk1:i,nk1:i)*ST(i,i);
|
||||||
Pstar(nk1:i,i) = q\(B(nk1:i,i)+c);
|
Pstar(nk1:i,i) = q\(B(nk1:i,i)+c);
|
||||||
Pstar(i,nk1:i-1) = Pstar(nk1:i-1,i)';
|
Pstar(i,nk1:i-1) = Pstar(nk1:i-1,i)';
|
||||||
else
|
else
|
||||||
if i == np
|
if i == np
|
||||||
c = zeros(np-nk,1);
|
c = zeros(np-nk,1);
|
||||||
c1 = zeros(np-nk,1);
|
c1 = zeros(np-nk,1);
|
||||||
else
|
else
|
||||||
c = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i,i+1:end)')+...
|
c = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i,i+1:end)')+...
|
||||||
ST(i,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i)+...
|
ST(i,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i)+...
|
||||||
ST(i,i-1)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i-1);
|
ST(i,i-1)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i-1);
|
||||||
c1 = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i-1,i+1:end)')+...
|
c1 = ST(nk1:i,:)*(Pstar(:,i+1:end)*ST(i-1,i+1:end)')+...
|
||||||
ST(i-1,i-1)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i-1)+...
|
ST(i-1,i-1)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i-1)+...
|
||||||
ST(i-1,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i);
|
ST(i-1,i)*ST(nk1:i,i+1:end)*Pstar(i+1:end,i);
|
||||||
end
|
end
|
||||||
q = [eye(i-nk)-ST(nk1:i,nk1:i)*ST(i,i) -ST(nk1:i,nk1:i)*ST(i,i-1);...
|
q = [eye(i-nk)-ST(nk1:i,nk1:i)*ST(i,i) -ST(nk1:i,nk1:i)*ST(i,i-1);...
|
||||||
-ST(nk1:i,nk1:i)*ST(i-1,i) eye(i-nk)-ST(nk1:i,nk1:i)*ST(i-1,i-1)];
|
-ST(nk1:i,nk1:i)*ST(i-1,i) eye(i-nk)-ST(nk1:i,nk1:i)*ST(i-1,i-1)];
|
||||||
z = q\[B(nk1:i,i)+c;B(nk1:i,i-1)+c1];
|
z = q\[B(nk1:i,i)+c;B(nk1:i,i-1)+c1];
|
||||||
Pstar(nk1:i,i) = z(1:(i-nk));
|
Pstar(nk1:i,i) = z(1:(i-nk));
|
||||||
Pstar(nk1:i,i-1) = z(i-nk+1:end);
|
Pstar(nk1:i,i-1) = z(i-nk+1:end);
|
||||||
Pstar(i,nk1:i-1) = Pstar(nk1:i-1,i)';
|
Pstar(i,nk1:i-1) = Pstar(nk1:i-1,i)';
|
||||||
Pstar(i-1,nk1:i-2) = Pstar(nk1:i-2,i-1)';
|
Pstar(i-1,nk1:i-2) = Pstar(nk1:i-2,i-1)';
|
||||||
i = i - 1;
|
i = i - 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if i == nk+2
|
if i == nk+2
|
||||||
c = ST(nk+1,:)*(Pstar(:,nk+2:end)*ST(nk1,nk+2:end)')+ST(nk1,nk1)*ST(nk1,nk+2:end)*Pstar(nk+2:end,nk1);
|
c = ST(nk+1,:)*(Pstar(:,nk+2:end)*ST(nk1,nk+2:end)')+ST(nk1,nk1)*ST(nk1,nk+2:end)*Pstar(nk+2:end,nk1);
|
||||||
Pstar(nk1,nk1)=(B(nk1,nk1)+c)/(1-ST(nk1,nk1)*ST(nk1,nk1));
|
Pstar(nk1,nk1)=(B(nk1,nk1)+c)/(1-ST(nk1,nk1)*ST(nk1,nk1));
|
||||||
end
|
end
|
||||||
Z = QT(mf,:);
|
Z = QT(mf,:);
|
||||||
R1 = QT'*R;
|
R1 = QT'*R;
|
||||||
[QQ,RR,EE] = qr(Z*ST(:,1:nk),0);
|
[QQ,RR,EE] = qr(Z*ST(:,1:nk),0);
|
||||||
k = find(abs(diag([RR; zeros(nk-size(Z,1),size(RR,2))])) < 1e-8);
|
k = find(abs(diag([RR; zeros(nk-size(Z,1),size(RR,2))])) < 1e-8);
|
||||||
if length(k) > 0
|
if length(k) > 0
|
||||||
k1 = EE(:,k);
|
k1 = EE(:,k);
|
||||||
dd =ones(nk,1);
|
dd =ones(nk,1);
|
||||||
dd(k1) = zeros(length(k1),1);
|
dd(k1) = zeros(length(k1),1);
|
||||||
Pinf(1:nk,1:nk) = diag(dd);
|
Pinf(1:nk,1:nk) = diag(dd);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if kalman_algo == 2
|
if kalman_algo == 2
|
||||||
end
|
end
|
||||||
kalman_tol = options_.kalman_tol;
|
kalman_tol = options_.kalman_tol;
|
||||||
riccati_tol = options_.riccati_tol;
|
riccati_tol = options_.riccati_tol;
|
||||||
mf = bayestopt_.mf1;
|
mf = bayestopt_.mf1;
|
||||||
Y = data-trend;
|
Y = data-trend;
|
||||||
Pstar
|
Pstar
|
||||||
pause
|
pause
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 4. Likelihood evaluation
|
% 4. Likelihood evaluation
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
if (kalman_algo==1)% Multivariate Kalman Filter
|
if (kalman_algo==1)% Multivariate Kalman Filter
|
||||||
if no_missing_data_flag
|
if no_missing_data_flag
|
||||||
LIK = kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol);
|
LIK = kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol);
|
||||||
else
|
else
|
||||||
LIK = ...
|
LIK = ...
|
||||||
missing_observations_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol, ...
|
missing_observations_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol, ...
|
||||||
data_index,number_of_observations,no_more_missing_observations);
|
data_index,number_of_observations,no_more_missing_observations);
|
||||||
end
|
end
|
||||||
if isinf(LIK)
|
if isinf(LIK)
|
||||||
kalman_algo = 2;
|
kalman_algo = 2;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (kalman_algo==2)% Univariate Kalman Filter
|
if (kalman_algo==2)% Univariate Kalman Filter
|
||||||
no_correlation_flag = 1;
|
no_correlation_flag = 1;
|
||||||
if length(H)==1 & H == 0
|
if length(H)==1 & H == 0
|
||||||
H = zeros(nobs,1);
|
H = zeros(nobs,1);
|
||||||
else
|
else
|
||||||
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
||||||
H = diag(H);
|
H = diag(H);
|
||||||
else
|
else
|
||||||
no_correlation_flag = 0;
|
no_correlation_flag = 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if no_correlation_flag
|
if no_correlation_flag
|
||||||
LIK = univariate_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol,data_index,number_of_observations,no_more_missing_observations);
|
LIK = univariate_kalman_filter(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol,data_index,number_of_observations,no_more_missing_observations);
|
||||||
else
|
else
|
||||||
LIK = univariate_kalman_filter_corr(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol,data_index,number_of_observations,no_more_missing_observations);
|
LIK = univariate_kalman_filter_corr(T,R,Q,H,Pstar,Y,start,mf,kalman_tol,riccati_tol,data_index,number_of_observations,no_more_missing_observations);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (kalman_algo==3)% Multivariate Diffuse Kalman Filter
|
if (kalman_algo==3)% Multivariate Diffuse Kalman Filter
|
||||||
if no_missing_data_flag
|
if no_missing_data_flag
|
||||||
LIK = diffuse_kalman_filter(ST,R1,Q,H,Pinf,Pstar,Y,start,Z,kalman_tol, ...
|
LIK = diffuse_kalman_filter(ST,R1,Q,H,Pinf,Pstar,Y,start,Z,kalman_tol, ...
|
||||||
riccati_tol);
|
riccati_tol);
|
||||||
else
|
else
|
||||||
LIK = missing_observations_diffuse_kalman_filter(ST,R1,Q,H,Pinf, ...
|
LIK = missing_observations_diffuse_kalman_filter(ST,R1,Q,H,Pinf, ...
|
||||||
Pstar,Y,start,Z,kalman_tol,riccati_tol,...
|
Pstar,Y,start,Z,kalman_tol,riccati_tol,...
|
||||||
data_index,number_of_observations,...
|
data_index,number_of_observations,...
|
||||||
no_more_missing_observations);
|
no_more_missing_observations);
|
||||||
end
|
end
|
||||||
if isinf(LIK)
|
if isinf(LIK)
|
||||||
kalman_algo = 4;
|
kalman_algo = 4;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (kalman_algo==4)% Univariate Diffuse Kalman Filter
|
if (kalman_algo==4)% Univariate Diffuse Kalman Filter
|
||||||
no_correlation_flag = 1;
|
no_correlation_flag = 1;
|
||||||
if length(H)==1 & H == 0
|
if length(H)==1 & H == 0
|
||||||
H = zeros(nobs,1);
|
H = zeros(nobs,1);
|
||||||
else
|
else
|
||||||
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
if all(all(abs(H-diag(diag(H)))<1e-14))% ie, the covariance matrix is diagonal...
|
||||||
H = diag(H);
|
H = diag(H);
|
||||||
else
|
else
|
||||||
no_correlation_flag = 0;
|
no_correlation_flag = 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if no_correlation_flag
|
if no_correlation_flag
|
||||||
LIK = univariate_diffuse_kalman_filter(ST,R1,Q,H,Pinf,Pstar,Y, ...
|
LIK = univariate_diffuse_kalman_filter(ST,R1,Q,H,Pinf,Pstar,Y, ...
|
||||||
start,Z,kalman_tol,riccati_tol,data_index,...
|
start,Z,kalman_tol,riccati_tol,data_index,...
|
||||||
number_of_observations,no_more_missing_observations);
|
number_of_observations,no_more_missing_observations);
|
||||||
else
|
else
|
||||||
LIK = univariate_diffuse_kalman_filter_corr(ST,R1,Q,H,Pinf,Pstar, ...
|
LIK = univariate_diffuse_kalman_filter_corr(ST,R1,Q,H,Pinf,Pstar, ...
|
||||||
Y,start,Z,kalman_tol,riccati_tol,...
|
Y,start,Z,kalman_tol,riccati_tol,...
|
||||||
data_index,number_of_observations,...
|
data_index,number_of_observations,...
|
||||||
no_more_missing_observations);
|
no_more_missing_observations);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if isnan(LIK)
|
if isnan(LIK)
|
||||||
cost_flag = 0;
|
cost_flag = 0;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if imag(LIK)~=0
|
if imag(LIK)~=0
|
||||||
likelihood = bayestopt_.penalty;
|
likelihood = bayestopt_.penalty;
|
||||||
else
|
else
|
||||||
likelihood = LIK;
|
likelihood = LIK;
|
||||||
end
|
end
|
||||||
% ------------------------------------------------------------------------------
|
% ------------------------------------------------------------------------------
|
||||||
% Adds prior if necessary
|
% Adds prior if necessary
|
||||||
% ------------------------------------------------------------------------------
|
% ------------------------------------------------------------------------------
|
||||||
lnprior = priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
lnprior = priordens(xparam1,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
||||||
fval = (likelihood-lnprior);
|
fval = (likelihood-lnprior);
|
||||||
likelihood
|
likelihood
|
||||||
lnprior
|
lnprior
|
||||||
fval
|
fval
|
||||||
pause
|
pause
|
||||||
LIKDLL=logposterior(xparam1,Y,mexext)
|
LIKDLL=logposterior(xparam1,Y,mexext)
|
||||||
pause
|
pause
|
||||||
options_.kalman_algo = kalman_algo;
|
options_.kalman_algo = kalman_algo;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,184 +1,184 @@
|
||||||
//options_.usePartInfo=1;
|
//options_.usePartInfo=1;
|
||||||
|
|
||||||
var MC E EF R_KF QF CF IF YF LF PIEF WF RF R_K Q C I Y L PIE W R EE_A PIE_BAR EE_B EE_G EE_L EE_I KF K one BIGTHETA;
|
var MC E EF R_KF QF CF IF YF LF PIEF WF RF R_K Q C I Y L PIE W R EE_A PIE_BAR EE_B EE_G EE_L EE_I KF K one BIGTHETA;
|
||||||
|
|
||||||
varexo E_A E_B E_G E_L E_I ETA_R E_PIE_BAR ETA_Q ETA_P ETA_W ;
|
varexo E_A E_B E_G E_L E_I ETA_R E_PIE_BAR ETA_Q ETA_P ETA_W ;
|
||||||
|
|
||||||
parameters
|
parameters
|
||||||
xi_e lambda_w alpha czcap beta phi_i tau sig_c hab ccs cinvs phi_y gamma_w xi_w gamma_p xi_p sig_l r_dpi
|
xi_e lambda_w alpha czcap beta phi_i tau sig_c hab ccs cinvs phi_y gamma_w xi_w gamma_p xi_p sig_l r_dpi
|
||||||
r_pie r_dy r_y rho rho_a rho_pb rho_b rho_g rho_l rho_i LMP ;
|
r_pie r_dy r_y rho rho_a rho_pb rho_b rho_g rho_l rho_i LMP ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
alpha=.30;
|
alpha=.30;
|
||||||
beta=.99;
|
beta=.99;
|
||||||
tau=0.025;
|
tau=0.025;
|
||||||
ccs=0.6;
|
ccs=0.6;
|
||||||
cinvs=.22; //% alpha*(tau+ctrend)/R_K R_K=ctrend/beta-1+tau
|
cinvs=.22; //% alpha*(tau+ctrend)/R_K R_K=ctrend/beta-1+tau
|
||||||
lambda_w = 0.5;
|
lambda_w = 0.5;
|
||||||
phi_i= 6.771;
|
phi_i= 6.771;
|
||||||
sig_c= 1.353;
|
sig_c= 1.353;
|
||||||
hab= 0.573;
|
hab= 0.573;
|
||||||
xi_w= 0.737;
|
xi_w= 0.737;
|
||||||
sig_l= 2.400;
|
sig_l= 2.400;
|
||||||
xi_p= 0.908;
|
xi_p= 0.908;
|
||||||
xi_e= 0.599;
|
xi_e= 0.599;
|
||||||
gamma_w= 0.763;
|
gamma_w= 0.763;
|
||||||
gamma_p= 0.469;
|
gamma_p= 0.469;
|
||||||
czcap= 0.169;
|
czcap= 0.169;
|
||||||
phi_y= 1.408;
|
phi_y= 1.408;
|
||||||
r_pie= 1.684;
|
r_pie= 1.684;
|
||||||
r_dpi= 0.14;
|
r_dpi= 0.14;
|
||||||
rho= 0.961;
|
rho= 0.961;
|
||||||
r_y= 0.099;
|
r_y= 0.099;
|
||||||
r_dy= 0.159;
|
r_dy= 0.159;
|
||||||
rho_a= 0.823;
|
rho_a= 0.823;
|
||||||
rho_b= 0.855;
|
rho_b= 0.855;
|
||||||
rho_g= 0.949;
|
rho_g= 0.949;
|
||||||
rho_l= 0.889;
|
rho_l= 0.889;
|
||||||
rho_i= 0.927;
|
rho_i= 0.927;
|
||||||
rho_pb= 0.924;
|
rho_pb= 0.924;
|
||||||
LMP = 0.0 ; //NEW.
|
LMP = 0.0 ; //NEW.
|
||||||
|
|
||||||
model(linear, use_dll);
|
model(linear, use_dll);
|
||||||
CF = (1/(1+hab))*(CF(1)+hab*CF(-1))-((1-hab)/((1+hab)*sig_c))*(RF-PIEF(1)-EE_B) ;
|
CF = (1/(1+hab))*(CF(1)+hab*CF(-1))-((1-hab)/((1+hab)*sig_c))*(RF-PIEF(1)-EE_B) ;
|
||||||
0 = alpha*R_KF+(1-alpha)*WF -EE_A ;
|
0 = alpha*R_KF+(1-alpha)*WF -EE_A ;
|
||||||
PIEF = 0*one;
|
PIEF = 0*one;
|
||||||
IF = (1/(1+beta))* (( IF(-1) + beta*(IF(1)))+(1/phi_i)*QF)+0*ETA_Q+EE_I ;
|
IF = (1/(1+beta))* (( IF(-1) + beta*(IF(1)))+(1/phi_i)*QF)+0*ETA_Q+EE_I ;
|
||||||
QF = -(RF-PIEF(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_KF(1)+beta*(1-tau)*QF(1) +0*EE_I ;
|
QF = -(RF-PIEF(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_KF(1)+beta*(1-tau)*QF(1) +0*EE_I ;
|
||||||
KF = (1-tau)*KF(-1)+tau*IF(-1) ;
|
KF = (1-tau)*KF(-1)+tau*IF(-1) ;
|
||||||
YF = (ccs*CF+cinvs*IF)+EE_G ;
|
YF = (ccs*CF+cinvs*IF)+EE_G ;
|
||||||
|
|
||||||
YF = 1*phi_y*( alpha*KF+alpha*(1/czcap)*R_KF+(1-alpha)*LF+EE_A ) ;
|
YF = 1*phi_y*( alpha*KF+alpha*(1/czcap)*R_KF+(1-alpha)*LF+EE_A ) ;
|
||||||
WF = (sig_c/(1-hab))*(CF-hab*CF(-1)) + sig_l*LF - EE_L ;
|
WF = (sig_c/(1-hab))*(CF-hab*CF(-1)) + sig_l*LF - EE_L ;
|
||||||
LF = R_KF*((1+czcap)/czcap)-WF+KF ;
|
LF = R_KF*((1+czcap)/czcap)-WF+KF ;
|
||||||
EF = EF(-1)+EF(1)-EF+(LF-EF)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
EF = EF(-1)+EF(1)-EF+(LF-EF)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
||||||
|
|
||||||
C = (hab/(1+hab))*C(-1)+(1/(1+hab))*C(1)-((1-hab)/((1+hab)*sig_c))*(R-PIE(1)-EE_B) ;
|
C = (hab/(1+hab))*C(-1)+(1/(1+hab))*C(1)-((1-hab)/((1+hab)*sig_c))*(R-PIE(1)-EE_B) ;
|
||||||
I = (1/(1+beta))* (( I(-1) + beta*(I(1)))+(1/phi_i)*Q )+1*ETA_Q+1*EE_I ;
|
I = (1/(1+beta))* (( I(-1) + beta*(I(1)))+(1/phi_i)*Q )+1*ETA_Q+1*EE_I ;
|
||||||
Q = -(R-PIE(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_K(1)+beta*(1-tau)*Q(1) +EE_I*0+0*ETA_Q ;
|
Q = -(R-PIE(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_K(1)+beta*(1-tau)*Q(1) +EE_I*0+0*ETA_Q ;
|
||||||
K = (1-tau)*K(-1)+tau*I(-1) ;
|
K = (1-tau)*K(-1)+tau*I(-1) ;
|
||||||
Y = (ccs*C+cinvs*I)+ EE_G ;
|
Y = (ccs*C+cinvs*I)+ EE_G ;
|
||||||
Y = phi_y*( alpha*K+alpha*(1/czcap)*R_K+(1-alpha)*L ) +phi_y*EE_A ;
|
Y = phi_y*( alpha*K+alpha*(1/czcap)*R_K+(1-alpha)*L ) +phi_y*EE_A ;
|
||||||
PIE = (1/(1+beta*gamma_p))*
|
PIE = (1/(1+beta*gamma_p))*
|
||||||
(
|
(
|
||||||
(beta)*(PIE(1)) +(gamma_p)*(PIE(-1))
|
(beta)*(PIE(1)) +(gamma_p)*(PIE(-1))
|
||||||
+((1-xi_p)*(1-beta*xi_p)/(xi_p))*(MC)
|
+((1-xi_p)*(1-beta*xi_p)/(xi_p))*(MC)
|
||||||
) + ETA_P ;
|
) + ETA_P ;
|
||||||
|
|
||||||
MC = alpha*R_K+(1-alpha)*W -EE_A;
|
MC = alpha*R_K+(1-alpha)*W -EE_A;
|
||||||
W = (1/(1+beta))*(beta*W(+1)+W(-1))
|
W = (1/(1+beta))*(beta*W(+1)+W(-1))
|
||||||
+(beta/(1+beta))*(PIE(+1))
|
+(beta/(1+beta))*(PIE(+1))
|
||||||
-((1+beta*gamma_w)/(1+beta))*(PIE)
|
-((1+beta*gamma_w)/(1+beta))*(PIE)
|
||||||
+(gamma_w/(1+beta))*(PIE(-1))
|
+(gamma_w/(1+beta))*(PIE(-1))
|
||||||
-(1/(1+beta))*(((1-beta*xi_w)*(1-xi_w))/(((1+(((1+lambda_w)*sig_l)/(lambda_w))))*xi_w))*(W-sig_l*L-(sig_c/(1-hab))*(C-hab*C(-1))+EE_L)
|
-(1/(1+beta))*(((1-beta*xi_w)*(1-xi_w))/(((1+(((1+lambda_w)*sig_l)/(lambda_w))))*xi_w))*(W-sig_l*L-(sig_c/(1-hab))*(C-hab*C(-1))+EE_L)
|
||||||
+ETA_W;
|
+ETA_W;
|
||||||
L = R_K*((1+czcap)/czcap)-W+K ;
|
L = R_K*((1+czcap)/czcap)-W+K ;
|
||||||
|
|
||||||
// R = r_dpi*(PIE-PIE(-1))
|
// R = r_dpi*(PIE-PIE(-1))
|
||||||
// +(1-rho)*(r_pie*(PIE(-1)-PIE_BAR)+r_y*(Y-YF))
|
// +(1-rho)*(r_pie*(PIE(-1)-PIE_BAR)+r_y*(Y-YF))
|
||||||
// +r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
// +r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
||||||
// +rho*(R(-1)-PIE_BAR)
|
// +rho*(R(-1)-PIE_BAR)
|
||||||
// +PIE_BAR
|
// +PIE_BAR
|
||||||
// +ETA_R;
|
// +ETA_R;
|
||||||
|
|
||||||
|
|
||||||
R =
|
R =
|
||||||
|
|
||||||
r_dpi*(PIE-PIE(-1))
|
r_dpi*(PIE-PIE(-1))
|
||||||
|
|
||||||
+(1-rho)*(r_pie*(BIGTHETA)+r_y*(Y-YF))
|
+(1-rho)*(r_pie*(BIGTHETA)+r_y*(Y-YF))
|
||||||
+r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
+r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
||||||
+rho*(R(-1)-PIE_BAR)
|
+rho*(R(-1)-PIE_BAR)
|
||||||
+PIE_BAR
|
+PIE_BAR
|
||||||
+ETA_R;
|
+ETA_R;
|
||||||
|
|
||||||
|
|
||||||
E = E(-1)+E(1)-E+(L-E)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
E = E(-1)+E(1)-E+(L-E)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
||||||
|
|
||||||
|
|
||||||
EE_A = (rho_a)*EE_A(-1) + E_A;
|
EE_A = (rho_a)*EE_A(-1) + E_A;
|
||||||
PIE_BAR = rho_pb*PIE_BAR(-1)+ E_PIE_BAR ;
|
PIE_BAR = rho_pb*PIE_BAR(-1)+ E_PIE_BAR ;
|
||||||
EE_B = rho_b*EE_B(-1) + E_B ;
|
EE_B = rho_b*EE_B(-1) + E_B ;
|
||||||
EE_G = rho_g*EE_G(-1) + E_G ;
|
EE_G = rho_g*EE_G(-1) + E_G ;
|
||||||
EE_L = rho_l*EE_L(-1) + E_L ;
|
EE_L = rho_l*EE_L(-1) + E_L ;
|
||||||
EE_I = rho_i*EE_I(-1) + E_I ;
|
EE_I = rho_i*EE_I(-1) + E_I ;
|
||||||
one = 0*one(-1) ;
|
one = 0*one(-1) ;
|
||||||
|
|
||||||
LMP*BIGTHETA(1) = BIGTHETA - (PIE(-1) - PIE_BAR) ;
|
LMP*BIGTHETA(1) = BIGTHETA - (PIE(-1) - PIE_BAR) ;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var E_A; stderr 0.598;
|
var E_A; stderr 0.598;
|
||||||
var E_B; stderr 0.336;
|
var E_B; stderr 0.336;
|
||||||
var E_G; stderr 0.325;
|
var E_G; stderr 0.325;
|
||||||
var E_I; stderr 0.085;
|
var E_I; stderr 0.085;
|
||||||
var E_L; stderr 3.520;
|
var E_L; stderr 3.520;
|
||||||
var ETA_P; stderr 0.160;
|
var ETA_P; stderr 0.160;
|
||||||
var ETA_W; stderr 0.289;
|
var ETA_W; stderr 0.289;
|
||||||
var ETA_R; stderr 0.081;
|
var ETA_R; stderr 0.081;
|
||||||
var ETA_Q; stderr 0.604;
|
var ETA_Q; stderr 0.604;
|
||||||
var E_PIE_BAR; stderr 0.017;
|
var E_PIE_BAR; stderr 0.017;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//stoch_simul(irf=20) Y C PIE R W R_K L Q I K ;
|
//stoch_simul(irf=20) Y C PIE R W R_K L Q I K ;
|
||||||
|
|
||||||
// stoch_simul generates what kind of standard errors for the shocks ?
|
// stoch_simul generates what kind of standard errors for the shocks ?
|
||||||
|
|
||||||
//steady;
|
//steady;
|
||||||
//check;
|
//check;
|
||||||
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE MC R W R_K E L I ;
|
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE MC R W R_K E L I ;
|
||||||
|
|
||||||
//datatomfile('ddd',[]);
|
//datatomfile('ddd',[]);
|
||||||
|
|
||||||
// new syntax
|
// new syntax
|
||||||
|
|
||||||
estimated_params;
|
estimated_params;
|
||||||
// PARAM NAME, INITVAL, LB, UB, PRIOR_SHAPE, PRIOR_P1, PRIOR_P2, PRIOR_P3, PRIOR_P4, JSCALE
|
// PARAM NAME, INITVAL, LB, UB, PRIOR_SHAPE, PRIOR_P1, PRIOR_P2, PRIOR_P3, PRIOR_P4, JSCALE
|
||||||
// PRIOR_SHAPE: BETA_PDF, GAMMA_PDF, NORMAL_PDF, INV_GAMMA_PDF
|
// PRIOR_SHAPE: BETA_PDF, GAMMA_PDF, NORMAL_PDF, INV_GAMMA_PDF
|
||||||
stderr E_A,0.543,0.01,4,INV_GAMMA_PDF,0.4,2;
|
stderr E_A,0.543,0.01,4,INV_GAMMA_PDF,0.4,2;
|
||||||
stderr E_PIE_BAR,0.072,0.001,4,INV_GAMMA_PDF,0.02,10;
|
stderr E_PIE_BAR,0.072,0.001,4,INV_GAMMA_PDF,0.02,10;
|
||||||
stderr E_B,0.2694,0.01,4,INV_GAMMA_PDF,0.2,2;
|
stderr E_B,0.2694,0.01,4,INV_GAMMA_PDF,0.2,2;
|
||||||
stderr E_G,0.3052,0.01,4,INV_GAMMA_PDF,0.3,2;
|
stderr E_G,0.3052,0.01,4,INV_GAMMA_PDF,0.3,2;
|
||||||
stderr E_L,1.4575,0.1,6,INV_GAMMA_PDF,1,2;
|
stderr E_L,1.4575,0.1,6,INV_GAMMA_PDF,1,2;
|
||||||
stderr E_I,0.1318,0.01,4,INV_GAMMA_PDF,0.1,2;
|
stderr E_I,0.1318,0.01,4,INV_GAMMA_PDF,0.1,2;
|
||||||
stderr ETA_R,0.1363,0.01,4,INV_GAMMA_PDF,0.1,2;
|
stderr ETA_R,0.1363,0.01,4,INV_GAMMA_PDF,0.1,2;
|
||||||
stderr ETA_Q,0.4842,0.01,4,INV_GAMMA_PDF,0.4,2;
|
stderr ETA_Q,0.4842,0.01,4,INV_GAMMA_PDF,0.4,2;
|
||||||
stderr ETA_P,0.1731,0.01,4,INV_GAMMA_PDF,0.15,2;
|
stderr ETA_P,0.1731,0.01,4,INV_GAMMA_PDF,0.15,2;
|
||||||
stderr ETA_W,0.2462,0.1,4,INV_GAMMA_PDF,0.25,2;
|
stderr ETA_W,0.2462,0.1,4,INV_GAMMA_PDF,0.25,2;
|
||||||
rho_a,.9722,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_a,.9722,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_pb,.85,.1,.999,BETA_PDF,0.85,0.1;
|
rho_pb,.85,.1,.999,BETA_PDF,0.85,0.1;
|
||||||
rho_b,.7647,.1,.99,BETA_PDF,0.85,0.1;
|
rho_b,.7647,.1,.99,BETA_PDF,0.85,0.1;
|
||||||
rho_g,.9502,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_g,.9502,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_l,.9542,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_l,.9542,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_i,.6705,.1,.99,BETA_PDF,0.85,0.1;
|
rho_i,.6705,.1,.99,BETA_PDF,0.85,0.1;
|
||||||
phi_i,5.2083,1,15,NORMAL_PDF,4,1.5;
|
phi_i,5.2083,1,15,NORMAL_PDF,4,1.5;
|
||||||
sig_c,0.9817,0.25,3,NORMAL_PDF,1,0.375;
|
sig_c,0.9817,0.25,3,NORMAL_PDF,1,0.375;
|
||||||
hab,0.5612,0.3,0.95,BETA_PDF,0.7,0.1;
|
hab,0.5612,0.3,0.95,BETA_PDF,0.7,0.1;
|
||||||
xi_w,0.7661,0.3,0.9,BETA_PDF,0.75,0.05;
|
xi_w,0.7661,0.3,0.9,BETA_PDF,0.75,0.05;
|
||||||
sig_l,1.7526,0.5,5,NORMAL_PDF,2,0.75;
|
sig_l,1.7526,0.5,5,NORMAL_PDF,2,0.75;
|
||||||
xi_p,0.8684,0.3,0.95,BETA_PDF,0.75,0.05;
|
xi_p,0.8684,0.3,0.95,BETA_PDF,0.75,0.05;
|
||||||
xi_e,0.5724,0.1,0.95,BETA_PDF,0.5,0.15;
|
xi_e,0.5724,0.1,0.95,BETA_PDF,0.5,0.15;
|
||||||
gamma_w,0.6202,0.1,0.99,BETA_PDF,0.75,0.15;
|
gamma_w,0.6202,0.1,0.99,BETA_PDF,0.75,0.15;
|
||||||
gamma_p,0.6638,0.1,0.99,BETA_PDF,0.75,0.15;
|
gamma_p,0.6638,0.1,0.99,BETA_PDF,0.75,0.15;
|
||||||
czcap,0.2516,0.01,2,NORMAL_PDF,0.2,0.075;
|
czcap,0.2516,0.01,2,NORMAL_PDF,0.2,0.075;
|
||||||
phi_y,1.3011,1.001,2,NORMAL_PDF,1.45,0.125;
|
phi_y,1.3011,1.001,2,NORMAL_PDF,1.45,0.125;
|
||||||
r_pie,1.4616,1.2,2,NORMAL_PDF,1.7,0.1;
|
r_pie,1.4616,1.2,2,NORMAL_PDF,1.7,0.1;
|
||||||
r_dpi,0.1144,0.01,0.5,NORMAL_PDF,0.3,0.1;
|
r_dpi,0.1144,0.01,0.5,NORMAL_PDF,0.3,0.1;
|
||||||
rho,0.8865,0.5,0.99,BETA_PDF,0.8,0.10;
|
rho,0.8865,0.5,0.99,BETA_PDF,0.8,0.10;
|
||||||
r_y,0.0571,0.01,0.2,NORMAL_PDF,0.125,0.05;
|
r_y,0.0571,0.01,0.2,NORMAL_PDF,0.125,0.05;
|
||||||
r_dy,0.2228,0.05,0.5,NORMAL_PDF,0.0625,0.05;
|
r_dy,0.2228,0.05,0.5,NORMAL_PDF,0.0625,0.05;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
varobs Y C I E PIE W R;
|
varobs Y C I E PIE W R;
|
||||||
|
|
||||||
//estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118, lik_init=2, mode_compute=1,mh_replic=0);
|
//estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118, lik_init=2, mode_compute=1,mh_replic=0);
|
||||||
estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118,mh_jscale=0.2,mh_replic=1000
|
estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118,mh_jscale=0.2,mh_replic=1000
|
||||||
//,mode_compute=0,mode_file=sweuromodel_dll_mode
|
//,mode_compute=0,mode_file=sweuromodel_dll_mode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE R W R_K L Q I K ;
|
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE R W R_K L Q I K ;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,182 +1,182 @@
|
||||||
//options_.usePartInfo=1;
|
//options_.usePartInfo=1;
|
||||||
|
|
||||||
var MC E EF R_KF QF CF IF YF LF PIEF WF RF R_K Q C I Y L PIE W R EE_A PIE_BAR EE_B EE_G EE_L EE_I KF K one BIGTHETA;
|
var MC E EF R_KF QF CF IF YF LF PIEF WF RF R_K Q C I Y L PIE W R EE_A PIE_BAR EE_B EE_G EE_L EE_I KF K one BIGTHETA;
|
||||||
|
|
||||||
varexo E_A E_B E_G E_L E_I ETA_R E_PIE_BAR ETA_Q ETA_P ETA_W ;
|
varexo E_A E_B E_G E_L E_I ETA_R E_PIE_BAR ETA_Q ETA_P ETA_W ;
|
||||||
|
|
||||||
parameters
|
parameters
|
||||||
xi_e lambda_w alpha czcap beta phi_i tau sig_c hab ccs cinvs phi_y gamma_w xi_w gamma_p xi_p sig_l r_dpi
|
xi_e lambda_w alpha czcap beta phi_i tau sig_c hab ccs cinvs phi_y gamma_w xi_w gamma_p xi_p sig_l r_dpi
|
||||||
r_pie r_dy r_y rho rho_a rho_pb rho_b rho_g rho_l rho_i LMP ;
|
r_pie r_dy r_y rho rho_a rho_pb rho_b rho_g rho_l rho_i LMP ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
alpha=.30;
|
alpha=.30;
|
||||||
beta=.99;
|
beta=.99;
|
||||||
tau=0.025;
|
tau=0.025;
|
||||||
ccs=0.6;
|
ccs=0.6;
|
||||||
cinvs=.22; //% alpha*(tau+ctrend)/R_K R_K=ctrend/beta-1+tau
|
cinvs=.22; //% alpha*(tau+ctrend)/R_K R_K=ctrend/beta-1+tau
|
||||||
lambda_w = 0.5;
|
lambda_w = 0.5;
|
||||||
phi_i= 6.771;
|
phi_i= 6.771;
|
||||||
sig_c= 1.353;
|
sig_c= 1.353;
|
||||||
hab= 0.573;
|
hab= 0.573;
|
||||||
xi_w= 0.737;
|
xi_w= 0.737;
|
||||||
sig_l= 2.400;
|
sig_l= 2.400;
|
||||||
xi_p= 0.908;
|
xi_p= 0.908;
|
||||||
xi_e= 0.599;
|
xi_e= 0.599;
|
||||||
gamma_w= 0.763;
|
gamma_w= 0.763;
|
||||||
gamma_p= 0.469;
|
gamma_p= 0.469;
|
||||||
czcap= 0.169;
|
czcap= 0.169;
|
||||||
phi_y= 1.408;
|
phi_y= 1.408;
|
||||||
r_pie= 1.684;
|
r_pie= 1.684;
|
||||||
r_dpi= 0.14;
|
r_dpi= 0.14;
|
||||||
rho= 0.961;
|
rho= 0.961;
|
||||||
r_y= 0.099;
|
r_y= 0.099;
|
||||||
r_dy= 0.159;
|
r_dy= 0.159;
|
||||||
rho_a= 0.823;
|
rho_a= 0.823;
|
||||||
rho_b= 0.855;
|
rho_b= 0.855;
|
||||||
rho_g= 0.949;
|
rho_g= 0.949;
|
||||||
rho_l= 0.889;
|
rho_l= 0.889;
|
||||||
rho_i= 0.927;
|
rho_i= 0.927;
|
||||||
rho_pb= 0.924;
|
rho_pb= 0.924;
|
||||||
LMP = 0.0 ; //NEW.
|
LMP = 0.0 ; //NEW.
|
||||||
|
|
||||||
model(linear, use_dll);
|
model(linear, use_dll);
|
||||||
CF = (1/(1+hab))*(CF(1)+hab*CF(-1))-((1-hab)/((1+hab)*sig_c))*(RF-PIEF(1)-EE_B) ;
|
CF = (1/(1+hab))*(CF(1)+hab*CF(-1))-((1-hab)/((1+hab)*sig_c))*(RF-PIEF(1)-EE_B) ;
|
||||||
0 = alpha*R_KF+(1-alpha)*WF -EE_A ;
|
0 = alpha*R_KF+(1-alpha)*WF -EE_A ;
|
||||||
PIEF = 0*one;
|
PIEF = 0*one;
|
||||||
IF = (1/(1+beta))* (( IF(-1) + beta*(IF(1)))+(1/phi_i)*QF)+0*ETA_Q+EE_I ;
|
IF = (1/(1+beta))* (( IF(-1) + beta*(IF(1)))+(1/phi_i)*QF)+0*ETA_Q+EE_I ;
|
||||||
QF = -(RF-PIEF(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_KF(1)+beta*(1-tau)*QF(1) +0*EE_I ;
|
QF = -(RF-PIEF(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_KF(1)+beta*(1-tau)*QF(1) +0*EE_I ;
|
||||||
KF = (1-tau)*KF(-1)+tau*IF(-1) ;
|
KF = (1-tau)*KF(-1)+tau*IF(-1) ;
|
||||||
YF = (ccs*CF+cinvs*IF)+EE_G ;
|
YF = (ccs*CF+cinvs*IF)+EE_G ;
|
||||||
|
|
||||||
YF = 1*phi_y*( alpha*KF+alpha*(1/czcap)*R_KF+(1-alpha)*LF+EE_A ) ;
|
YF = 1*phi_y*( alpha*KF+alpha*(1/czcap)*R_KF+(1-alpha)*LF+EE_A ) ;
|
||||||
WF = (sig_c/(1-hab))*(CF-hab*CF(-1)) + sig_l*LF - EE_L ;
|
WF = (sig_c/(1-hab))*(CF-hab*CF(-1)) + sig_l*LF - EE_L ;
|
||||||
LF = R_KF*((1+czcap)/czcap)-WF+KF ;
|
LF = R_KF*((1+czcap)/czcap)-WF+KF ;
|
||||||
EF = EF(-1)+EF(1)-EF+(LF-EF)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
EF = EF(-1)+EF(1)-EF+(LF-EF)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
||||||
|
|
||||||
C = (hab/(1+hab))*C(-1)+(1/(1+hab))*C(1)-((1-hab)/((1+hab)*sig_c))*(R-PIE(1)-EE_B) ;
|
C = (hab/(1+hab))*C(-1)+(1/(1+hab))*C(1)-((1-hab)/((1+hab)*sig_c))*(R-PIE(1)-EE_B) ;
|
||||||
I = (1/(1+beta))* (( I(-1) + beta*(I(1)))+(1/phi_i)*Q )+1*ETA_Q+1*EE_I ;
|
I = (1/(1+beta))* (( I(-1) + beta*(I(1)))+(1/phi_i)*Q )+1*ETA_Q+1*EE_I ;
|
||||||
Q = -(R-PIE(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_K(1)+beta*(1-tau)*Q(1) +EE_I*0+0*ETA_Q ;
|
Q = -(R-PIE(1))+(1-beta*(1-tau))*((0+czcap)/czcap)*R_K(1)+beta*(1-tau)*Q(1) +EE_I*0+0*ETA_Q ;
|
||||||
K = (1-tau)*K(-1)+tau*I(-1) ;
|
K = (1-tau)*K(-1)+tau*I(-1) ;
|
||||||
Y = (ccs*C+cinvs*I)+ EE_G ;
|
Y = (ccs*C+cinvs*I)+ EE_G ;
|
||||||
Y = phi_y*( alpha*K+alpha*(1/czcap)*R_K+(1-alpha)*L ) +phi_y*EE_A ;
|
Y = phi_y*( alpha*K+alpha*(1/czcap)*R_K+(1-alpha)*L ) +phi_y*EE_A ;
|
||||||
PIE = (1/(1+beta*gamma_p))*
|
PIE = (1/(1+beta*gamma_p))*
|
||||||
(
|
(
|
||||||
(beta)*(PIE(1)) +(gamma_p)*(PIE(-1))
|
(beta)*(PIE(1)) +(gamma_p)*(PIE(-1))
|
||||||
+((1-xi_p)*(1-beta*xi_p)/(xi_p))*(MC)
|
+((1-xi_p)*(1-beta*xi_p)/(xi_p))*(MC)
|
||||||
) + ETA_P ;
|
) + ETA_P ;
|
||||||
|
|
||||||
MC = alpha*R_K+(1-alpha)*W -EE_A;
|
MC = alpha*R_K+(1-alpha)*W -EE_A;
|
||||||
W = (1/(1+beta))*(beta*W(+1)+W(-1))
|
W = (1/(1+beta))*(beta*W(+1)+W(-1))
|
||||||
+(beta/(1+beta))*(PIE(+1))
|
+(beta/(1+beta))*(PIE(+1))
|
||||||
-((1+beta*gamma_w)/(1+beta))*(PIE)
|
-((1+beta*gamma_w)/(1+beta))*(PIE)
|
||||||
+(gamma_w/(1+beta))*(PIE(-1))
|
+(gamma_w/(1+beta))*(PIE(-1))
|
||||||
-(1/(1+beta))*(((1-beta*xi_w)*(1-xi_w))/(((1+(((1+lambda_w)*sig_l)/(lambda_w))))*xi_w))*(W-sig_l*L-(sig_c/(1-hab))*(C-hab*C(-1))+EE_L)
|
-(1/(1+beta))*(((1-beta*xi_w)*(1-xi_w))/(((1+(((1+lambda_w)*sig_l)/(lambda_w))))*xi_w))*(W-sig_l*L-(sig_c/(1-hab))*(C-hab*C(-1))+EE_L)
|
||||||
+ETA_W;
|
+ETA_W;
|
||||||
L = R_K*((1+czcap)/czcap)-W+K ;
|
L = R_K*((1+czcap)/czcap)-W+K ;
|
||||||
|
|
||||||
// R = r_dpi*(PIE-PIE(-1))
|
// R = r_dpi*(PIE-PIE(-1))
|
||||||
// +(1-rho)*(r_pie*(PIE(-1)-PIE_BAR)+r_y*(Y-YF))
|
// +(1-rho)*(r_pie*(PIE(-1)-PIE_BAR)+r_y*(Y-YF))
|
||||||
// +r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
// +r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
||||||
// +rho*(R(-1)-PIE_BAR)
|
// +rho*(R(-1)-PIE_BAR)
|
||||||
// +PIE_BAR
|
// +PIE_BAR
|
||||||
// +ETA_R;
|
// +ETA_R;
|
||||||
|
|
||||||
|
|
||||||
R =
|
R =
|
||||||
|
|
||||||
r_dpi*(PIE-PIE(-1))
|
r_dpi*(PIE-PIE(-1))
|
||||||
|
|
||||||
+(1-rho)*(r_pie*(BIGTHETA)+r_y*(Y-YF))
|
+(1-rho)*(r_pie*(BIGTHETA)+r_y*(Y-YF))
|
||||||
+r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
+r_dy*(Y-YF-(Y(-1)-YF(-1)))
|
||||||
+rho*(R(-1)-PIE_BAR)
|
+rho*(R(-1)-PIE_BAR)
|
||||||
+PIE_BAR
|
+PIE_BAR
|
||||||
+ETA_R;
|
+ETA_R;
|
||||||
|
|
||||||
|
|
||||||
E = E(-1)+E(1)-E+(L-E)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
E = E(-1)+E(1)-E+(L-E)*((1-xi_e)*(1-xi_e*beta)/(xi_e));
|
||||||
|
|
||||||
|
|
||||||
EE_A = (rho_a)*EE_A(-1) + E_A;
|
EE_A = (rho_a)*EE_A(-1) + E_A;
|
||||||
PIE_BAR = rho_pb*PIE_BAR(-1)+ E_PIE_BAR ;
|
PIE_BAR = rho_pb*PIE_BAR(-1)+ E_PIE_BAR ;
|
||||||
EE_B = rho_b*EE_B(-1) + E_B ;
|
EE_B = rho_b*EE_B(-1) + E_B ;
|
||||||
EE_G = rho_g*EE_G(-1) + E_G ;
|
EE_G = rho_g*EE_G(-1) + E_G ;
|
||||||
EE_L = rho_l*EE_L(-1) + E_L ;
|
EE_L = rho_l*EE_L(-1) + E_L ;
|
||||||
EE_I = rho_i*EE_I(-1) + E_I ;
|
EE_I = rho_i*EE_I(-1) + E_I ;
|
||||||
one = 0*one(-1) ;
|
one = 0*one(-1) ;
|
||||||
|
|
||||||
LMP*BIGTHETA(1) = BIGTHETA - (PIE(-1) - PIE_BAR) ;
|
LMP*BIGTHETA(1) = BIGTHETA - (PIE(-1) - PIE_BAR) ;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var E_A; stderr 0.598;
|
var E_A; stderr 0.598;
|
||||||
var E_B; stderr 0.336;
|
var E_B; stderr 0.336;
|
||||||
var E_G; stderr 0.325;
|
var E_G; stderr 0.325;
|
||||||
var E_I; stderr 0.085;
|
var E_I; stderr 0.085;
|
||||||
var E_L; stderr 3.520;
|
var E_L; stderr 3.520;
|
||||||
var ETA_P; stderr 0.160;
|
var ETA_P; stderr 0.160;
|
||||||
var ETA_W; stderr 0.289;
|
var ETA_W; stderr 0.289;
|
||||||
var ETA_R; stderr 0.081;
|
var ETA_R; stderr 0.081;
|
||||||
var ETA_Q; stderr 0.604;
|
var ETA_Q; stderr 0.604;
|
||||||
var E_PIE_BAR; stderr 0.017;
|
var E_PIE_BAR; stderr 0.017;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//stoch_simul(irf=20) Y C PIE R W R_K L Q I K ;
|
//stoch_simul(irf=20) Y C PIE R W R_K L Q I K ;
|
||||||
|
|
||||||
// stoch_simul generates what kind of standard errors for the shocks ?
|
// stoch_simul generates what kind of standard errors for the shocks ?
|
||||||
|
|
||||||
//steady;
|
//steady;
|
||||||
//check;
|
//check;
|
||||||
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE MC R W R_K E L I ;
|
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE MC R W R_K E L I ;
|
||||||
|
|
||||||
//datatomfile('ddd',[]);
|
//datatomfile('ddd',[]);
|
||||||
|
|
||||||
// new syntax
|
// new syntax
|
||||||
|
|
||||||
estimated_params;
|
estimated_params;
|
||||||
// PARAM NAME, INITVAL, LB, UB, PRIOR_SHAPE, PRIOR_P1, PRIOR_P2, PRIOR_P3, PRIOR_P4, JSCALE
|
// PARAM NAME, INITVAL, LB, UB, PRIOR_SHAPE, PRIOR_P1, PRIOR_P2, PRIOR_P3, PRIOR_P4, JSCALE
|
||||||
// PRIOR_SHAPE: BETA_PDF, GAMMA_PDF, NORMAL_PDF, INV_GAMMA_PDF
|
// PRIOR_SHAPE: BETA_PDF, GAMMA_PDF, NORMAL_PDF, INV_GAMMA_PDF
|
||||||
stderr E_A,0.543,0.01,4,INV_GAMMA_PDF,0.4,2;
|
stderr E_A,0.543,0.01,4,INV_GAMMA_PDF,0.4,2;
|
||||||
stderr E_PIE_BAR,0.072,0.001,4,INV_GAMMA_PDF,0.02,10;
|
stderr E_PIE_BAR,0.072,0.001,4,INV_GAMMA_PDF,0.02,10;
|
||||||
stderr E_B,0.2694,0.01,4,INV_GAMMA_PDF,0.2,2;
|
stderr E_B,0.2694,0.01,4,INV_GAMMA_PDF,0.2,2;
|
||||||
stderr E_G,0.3052,0.01,4,INV_GAMMA_PDF,0.3,2;
|
stderr E_G,0.3052,0.01,4,INV_GAMMA_PDF,0.3,2;
|
||||||
stderr E_L,1.4575,0.1,6,INV_GAMMA_PDF,1,2;
|
stderr E_L,1.4575,0.1,6,INV_GAMMA_PDF,1,2;
|
||||||
stderr E_I,0.1318,0.01,4,INV_GAMMA_PDF,0.1,2;
|
stderr E_I,0.1318,0.01,4,INV_GAMMA_PDF,0.1,2;
|
||||||
stderr ETA_R,0.1363,0.01,4,INV_GAMMA_PDF,0.1,2;
|
stderr ETA_R,0.1363,0.01,4,INV_GAMMA_PDF,0.1,2;
|
||||||
stderr ETA_Q,0.4842,0.01,4,INV_GAMMA_PDF,0.4,2;
|
stderr ETA_Q,0.4842,0.01,4,INV_GAMMA_PDF,0.4,2;
|
||||||
stderr ETA_P,0.1731,0.01,4,INV_GAMMA_PDF,0.15,2;
|
stderr ETA_P,0.1731,0.01,4,INV_GAMMA_PDF,0.15,2;
|
||||||
stderr ETA_W,0.2462,0.1,4,INV_GAMMA_PDF,0.25,2;
|
stderr ETA_W,0.2462,0.1,4,INV_GAMMA_PDF,0.25,2;
|
||||||
rho_a,.9722,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_a,.9722,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_pb,.85,.1,.999,BETA_PDF,0.85,0.1;
|
rho_pb,.85,.1,.999,BETA_PDF,0.85,0.1;
|
||||||
rho_b,.7647,.1,.99,BETA_PDF,0.85,0.1;
|
rho_b,.7647,.1,.99,BETA_PDF,0.85,0.1;
|
||||||
rho_g,.9502,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_g,.9502,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_l,.9542,.1,.9999,BETA_PDF,0.85,0.1;
|
rho_l,.9542,.1,.9999,BETA_PDF,0.85,0.1;
|
||||||
rho_i,.6705,.1,.99,BETA_PDF,0.85,0.1;
|
rho_i,.6705,.1,.99,BETA_PDF,0.85,0.1;
|
||||||
phi_i,5.2083,1,15,NORMAL_PDF,4,1.5;
|
phi_i,5.2083,1,15,NORMAL_PDF,4,1.5;
|
||||||
sig_c,0.9817,0.25,3,NORMAL_PDF,1,0.375;
|
sig_c,0.9817,0.25,3,NORMAL_PDF,1,0.375;
|
||||||
hab,0.5612,0.3,0.95,BETA_PDF,0.7,0.1;
|
hab,0.5612,0.3,0.95,BETA_PDF,0.7,0.1;
|
||||||
xi_w,0.7661,0.3,0.9,BETA_PDF,0.75,0.05;
|
xi_w,0.7661,0.3,0.9,BETA_PDF,0.75,0.05;
|
||||||
sig_l,1.7526,0.5,5,NORMAL_PDF,2,0.75;
|
sig_l,1.7526,0.5,5,NORMAL_PDF,2,0.75;
|
||||||
xi_p,0.8684,0.3,0.95,BETA_PDF,0.75,0.05;
|
xi_p,0.8684,0.3,0.95,BETA_PDF,0.75,0.05;
|
||||||
xi_e,0.5724,0.1,0.95,BETA_PDF,0.5,0.15;
|
xi_e,0.5724,0.1,0.95,BETA_PDF,0.5,0.15;
|
||||||
gamma_w,0.6202,0.1,0.99,BETA_PDF,0.75,0.15;
|
gamma_w,0.6202,0.1,0.99,BETA_PDF,0.75,0.15;
|
||||||
gamma_p,0.6638,0.1,0.99,BETA_PDF,0.75,0.15;
|
gamma_p,0.6638,0.1,0.99,BETA_PDF,0.75,0.15;
|
||||||
czcap,0.2516,0.01,2,NORMAL_PDF,0.2,0.075;
|
czcap,0.2516,0.01,2,NORMAL_PDF,0.2,0.075;
|
||||||
phi_y,1.3011,1.001,2,NORMAL_PDF,1.45,0.125;
|
phi_y,1.3011,1.001,2,NORMAL_PDF,1.45,0.125;
|
||||||
r_pie,1.4616,1.2,2,NORMAL_PDF,1.7,0.1;
|
r_pie,1.4616,1.2,2,NORMAL_PDF,1.7,0.1;
|
||||||
r_dpi,0.1144,0.01,0.5,NORMAL_PDF,0.3,0.1;
|
r_dpi,0.1144,0.01,0.5,NORMAL_PDF,0.3,0.1;
|
||||||
rho,0.8865,0.5,0.99,BETA_PDF,0.8,0.10;
|
rho,0.8865,0.5,0.99,BETA_PDF,0.8,0.10;
|
||||||
r_y,0.0571,0.01,0.2,NORMAL_PDF,0.125,0.05;
|
r_y,0.0571,0.01,0.2,NORMAL_PDF,0.125,0.05;
|
||||||
r_dy,0.2228,0.05,0.5,NORMAL_PDF,0.0625,0.05;
|
r_dy,0.2228,0.05,0.5,NORMAL_PDF,0.0625,0.05;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
varobs Y C I E PIE W R;
|
varobs Y C I E PIE W R;
|
||||||
|
|
||||||
//estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118, lik_init=2, mode_compute=1,mh_replic=0);
|
//estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118, lik_init=2, mode_compute=1,mh_replic=0);
|
||||||
estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118,mh_jscale=0.2,mh_replic=150000, mode_check); //
|
estimation(datafile=rawdata_euromodel_1,presample=40, first_obs=1, nobs=118,mh_jscale=0.2,mh_replic=150000, mode_check); //
|
||||||
|
|
||||||
|
|
||||||
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE R W R_K L Q I K ;
|
//stoch_simul(periods=200,irf=20,simul_seed=3) Y C PIE R W R_K L Q I K ;
|
||||||
|
|
||||||
|
|
|
@ -1,119 +1,119 @@
|
||||||
// This file replicates the estimation of the CIA model from
|
// This file replicates the estimation of the CIA model from
|
||||||
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
|
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
|
||||||
// Journal of Applied Econometrics, 15, 645-670.
|
// Journal of Applied Econometrics, 15, 645-670.
|
||||||
// the data are the ones provided on Schorfheide's web site with the programs.
|
// the data are the ones provided on Schorfheide's web site with the programs.
|
||||||
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
|
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
|
||||||
// You need to have fsdat.m in the same directory as this file.
|
// You need to have fsdat.m in the same directory as this file.
|
||||||
// This file replicates:
|
// This file replicates:
|
||||||
// -the posterior mode as computed by Frank's Gauss programs
|
// -the posterior mode as computed by Frank's Gauss programs
|
||||||
// -the parameter mean posterior estimates reported in the paper
|
// -the parameter mean posterior estimates reported in the paper
|
||||||
// -the model probability (harmonic mean) reported in the paper
|
// -the model probability (harmonic mean) reported in the paper
|
||||||
// This file was tested with dyn_mat_test_0218.zip
|
// This file was tested with dyn_mat_test_0218.zip
|
||||||
// the smooth shocks are probably stil buggy
|
// the smooth shocks are probably stil buggy
|
||||||
//
|
//
|
||||||
// The equations are taken from J. Nason and T. Cogley (1994)
|
// The equations are taken from J. Nason and T. Cogley (1994)
|
||||||
// "Testing the implications of long-run neutrality for monetary business
|
// "Testing the implications of long-run neutrality for monetary business
|
||||||
// cycle models" Journal of Applied Econometrics, 9, S37-S70.
|
// cycle models" Journal of Applied Econometrics, 9, S37-S70.
|
||||||
// Note that there is an initial minus sign missing in equation (A1), p. S63.
|
// Note that there is an initial minus sign missing in equation (A1), p. S63.
|
||||||
//
|
//
|
||||||
// Michel Juillard, February 2004
|
// Michel Juillard, February 2004
|
||||||
// Modified for testing k_order_perturbation by GP, Jan-Feb 09
|
// Modified for testing k_order_perturbation by GP, Jan-Feb 09
|
||||||
|
|
||||||
options_.usePartInfo=0;
|
options_.usePartInfo=0;
|
||||||
options_.use_k_order=0;
|
options_.use_k_order=0;
|
||||||
|
|
||||||
//var m m_1 P P_1 c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2;
|
//var m m_1 P P_1 c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2;
|
||||||
var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA P2 c2;
|
var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA P2 c2;
|
||||||
varexo e_a e_m;
|
varexo e_a e_m;
|
||||||
|
|
||||||
parameters alp bet gam mst rho psi del;
|
parameters alp bet gam mst rho psi del;
|
||||||
|
|
||||||
alp = 0.33;
|
alp = 0.33;
|
||||||
bet = 0.99;
|
bet = 0.99;
|
||||||
gam = 0.003;
|
gam = 0.003;
|
||||||
mst = 1.011;
|
mst = 1.011;
|
||||||
rho = 0.7;
|
rho = 0.7;
|
||||||
psi = 0.787;
|
psi = 0.787;
|
||||||
del = 0.02;
|
del = 0.02;
|
||||||
|
|
||||||
model (use_dll);
|
model (use_dll);
|
||||||
dA = exp(gam+e_a);
|
dA = exp(gam+e_a);
|
||||||
log(m) = (1-rho)*log(mst) + rho*log(m_1(-1))+e_m;
|
log(m) = (1-rho)*log(mst) + rho*log(m_1(-1))+e_m;
|
||||||
-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)))))/(c2(+1)*P2(+1)*m(+1))=0;
|
-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)))))/(c2(+1)*P2(+1)*m(+1))=0;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
|
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
|
||||||
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
|
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
|
||||||
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;
|
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;
|
||||||
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
|
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
|
||||||
P*c = m;
|
P*c = m;
|
||||||
m-1+d = l;
|
m-1+d = l;
|
||||||
e = exp(e_a);
|
e = exp(e_a);
|
||||||
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
|
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
|
||||||
gy_obs = dA*y/y(-1);
|
gy_obs = dA*y/y(-1);
|
||||||
gp_obs = (P/P_1(-1))*m_1(-1)/dA;
|
gp_obs = (P/P_1(-1))*m_1(-1)/dA;
|
||||||
//Y_obs/Y_obs(-1) = gy_obs;
|
//Y_obs/Y_obs(-1) = gy_obs;
|
||||||
//P_obs/P_obs(-1) = gp_obs;
|
//P_obs/P_obs(-1) = gp_obs;
|
||||||
P2 = P(+1);
|
P2 = P(+1);
|
||||||
c2 = c(+1);
|
c2 = c(+1);
|
||||||
m_1 = m;
|
m_1 = m;
|
||||||
P_1 = P;
|
P_1 = P;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
m = mst;
|
m = mst;
|
||||||
m_1=mst;
|
m_1=mst;
|
||||||
P = 2.25;
|
P = 2.25;
|
||||||
P_1 = 2.25;
|
P_1 = 2.25;
|
||||||
c = 0.45;
|
c = 0.45;
|
||||||
e = 1;
|
e = 1;
|
||||||
W = 4;
|
W = 4;
|
||||||
R = 1.02;
|
R = 1.02;
|
||||||
k = 6;
|
k = 6;
|
||||||
d = 0.85;
|
d = 0.85;
|
||||||
n = 0.19;
|
n = 0.19;
|
||||||
l = 0.86;
|
l = 0.86;
|
||||||
y = 0.6;
|
y = 0.6;
|
||||||
gy_obs = exp(gam);
|
gy_obs = exp(gam);
|
||||||
gp_obs = exp(-gam);
|
gp_obs = exp(-gam);
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
P2=P;
|
P2=P;
|
||||||
c2=c;
|
c2=c;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e_a; stderr 0.014;
|
var e_a; stderr 0.014;
|
||||||
var e_m; stderr 0.005;
|
var e_m; stderr 0.005;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//unit_root_vars P_obs Y_obs;
|
//unit_root_vars P_obs Y_obs;
|
||||||
|
|
||||||
steady(solve_algo = 2);
|
steady(solve_algo = 2);
|
||||||
|
|
||||||
check;
|
check;
|
||||||
|
|
||||||
estimated_params;
|
estimated_params;
|
||||||
alp, beta_pdf, 0.356, 0.02;
|
alp, beta_pdf, 0.356, 0.02;
|
||||||
bet, beta_pdf, 0.993, 0.002;
|
bet, beta_pdf, 0.993, 0.002;
|
||||||
gam, normal_pdf, 0.0085, 0.003;
|
gam, normal_pdf, 0.0085, 0.003;
|
||||||
mst, normal_pdf, 1.0002, 0.007;
|
mst, normal_pdf, 1.0002, 0.007;
|
||||||
rho, beta_pdf, 0.129, 0.223;
|
rho, beta_pdf, 0.129, 0.223;
|
||||||
psi, beta_pdf, 0.65, 0.05;
|
psi, beta_pdf, 0.65, 0.05;
|
||||||
del, beta_pdf, 0.01, 0.005;
|
del, beta_pdf, 0.01, 0.005;
|
||||||
stderr e_a, inv_gamma_pdf, 0.035449, inf;
|
stderr e_a, inv_gamma_pdf, 0.035449, inf;
|
||||||
stderr e_m, inv_gamma_pdf, 0.008862, inf;
|
stderr e_m, inv_gamma_pdf, 0.008862, inf;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//varobs P_obs Y_obs;
|
//varobs P_obs Y_obs;
|
||||||
varobs gp_obs gy_obs;
|
varobs gp_obs gy_obs;
|
||||||
|
|
||||||
steady(solve_algo = 2);
|
steady(solve_algo = 2);
|
||||||
|
|
||||||
//observation_trends;
|
//observation_trends;
|
||||||
//P_obs (log(mst)-gam);
|
//P_obs (log(mst)-gam);
|
||||||
//Y_obs (gam);
|
//Y_obs (gam);
|
||||||
//end;
|
//end;
|
||||||
|
|
||||||
//options_.useAIM = 1;
|
//options_.useAIM = 1;
|
||||||
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,
|
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,
|
||||||
mode_compute=4,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.65);
|
mode_compute=4,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.65);
|
||||||
|
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
||||||
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
||||||
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
||||||
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
||||||
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
||||||
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
||||||
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
||||||
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
||||||
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
||||||
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
||||||
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
||||||
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
||||||
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
||||||
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
||||||
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
||||||
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
||||||
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
||||||
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
||||||
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
||||||
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
||||||
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
||||||
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
||||||
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
||||||
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
||||||
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
||||||
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
||||||
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
||||||
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
||||||
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
||||||
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
||||||
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
||||||
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
||||||
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
||||||
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
||||||
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
||||||
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
||||||
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
||||||
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
||||||
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
||||||
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
||||||
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
||||||
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
||||||
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
||||||
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
||||||
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
||||||
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
||||||
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
||||||
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
||||||
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
||||||
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
||||||
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
||||||
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
||||||
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
||||||
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
||||||
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
||||||
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
||||||
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
||||||
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
||||||
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
||||||
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
||||||
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
||||||
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
||||||
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
||||||
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
||||||
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
||||||
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
||||||
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
||||||
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
||||||
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
||||||
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
||||||
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
||||||
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
||||||
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
||||||
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
||||||
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
||||||
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
||||||
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
||||||
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
||||||
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
||||||
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
||||||
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
||||||
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
||||||
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
||||||
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
||||||
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
||||||
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
||||||
];
|
];
|
||||||
|
|
||||||
data = reshape(data,5,86)';
|
data = reshape(data,5,86)';
|
||||||
y_obs = data(:,1);
|
y_obs = data(:,1);
|
||||||
pie_obs = data(:,2);
|
pie_obs = data(:,2);
|
||||||
R_obs = data(:,3);
|
R_obs = data(:,3);
|
||||||
de = data(:,4);
|
de = data(:,4);
|
||||||
dq = data(:,5);
|
dq = data(:,5);
|
||||||
|
|
||||||
%Country: Canada
|
%Country: Canada
|
||||||
%Sample Range: 1981:2 to 2002:3
|
%Sample Range: 1981:2 to 2002:3
|
||||||
%Observations: 86
|
%Observations: 86
|
||||||
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
||||||
% Exchange Rate Change [%], Terms of Trade Change [%]
|
% Exchange Rate Change [%], Terms of Trade Change [%]
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
% computes the steady state of fs2000 analyticaly
|
% computes the steady state of fs2000 analyticaly
|
||||||
% largely inspired by the program of F. Schorfheide
|
% largely inspired by the program of F. Schorfheide
|
||||||
function [ys,check] = fs2000k_steadystate(ys,exe)
|
function [ys,check] = fs2000k_steadystate(ys,exe)
|
||||||
global M_
|
global M_
|
||||||
|
|
||||||
alp = M_.params(1);
|
alp = M_.params(1);
|
||||||
bet = M_.params(2);
|
bet = M_.params(2);
|
||||||
gam = M_.params(3);
|
gam = M_.params(3);
|
||||||
mst = M_.params(4);
|
mst = M_.params(4);
|
||||||
rho = M_.params(5);
|
rho = M_.params(5);
|
||||||
psi = M_.params(6);
|
psi = M_.params(6);
|
||||||
del = M_.params(7);
|
del = M_.params(7);
|
||||||
|
|
||||||
check = 0;
|
check = 0;
|
||||||
|
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
gst = 1/dA;
|
gst = 1/dA;
|
||||||
m = mst;
|
m = mst;
|
||||||
|
|
||||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||||
n = xist/(nust+xist);
|
n = xist/(nust+xist);
|
||||||
P = xist + nust;
|
P = xist + nust;
|
||||||
k = khst*n;
|
k = khst*n;
|
||||||
|
|
||||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||||
c = mst/P;
|
c = mst/P;
|
||||||
d = l - mst + 1;
|
d = l - mst + 1;
|
||||||
y = k^alp*n^(1-alp)*gst^alp;
|
y = k^alp*n^(1-alp)*gst^alp;
|
||||||
R = mst/bet;
|
R = mst/bet;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
ist = y-c;
|
ist = y-c;
|
||||||
q = 1 - d;
|
q = 1 - d;
|
||||||
|
|
||||||
e = 1;
|
e = 1;
|
||||||
|
|
||||||
gp_obs = m/dA;
|
gp_obs = m/dA;
|
||||||
gy_obs = dA;
|
gy_obs = dA;
|
||||||
|
|
||||||
P_obs = 1;
|
P_obs = 1;
|
||||||
Y_obs = 1;
|
Y_obs = 1;
|
||||||
|
|
||||||
P2=P;
|
P2=P;
|
||||||
c2=c;
|
c2=c;
|
||||||
|
|
||||||
ys =[
|
ys =[
|
||||||
m
|
m
|
||||||
P
|
P
|
||||||
c
|
c
|
||||||
e
|
e
|
||||||
W
|
W
|
||||||
R
|
R
|
||||||
k
|
k
|
||||||
d
|
d
|
||||||
n
|
n
|
||||||
l
|
l
|
||||||
gy_obs
|
gy_obs
|
||||||
gp_obs
|
gp_obs
|
||||||
Y_obs
|
Y_obs
|
||||||
P_obs
|
P_obs
|
||||||
y
|
y
|
||||||
dA
|
dA
|
||||||
P2
|
P2
|
||||||
c2 ];
|
c2 ];
|
|
@ -1,65 +1,65 @@
|
||||||
% computes the steady state of fs2000 analyticaly
|
% computes the steady state of fs2000 analyticaly
|
||||||
% largely inspired by the program of F. Schorfheide
|
% largely inspired by the program of F. Schorfheide
|
||||||
function [ys,check] = fs2000k_steadystate(ys,exe)
|
function [ys,check] = fs2000k_steadystate(ys,exe)
|
||||||
global M_
|
global M_
|
||||||
|
|
||||||
alp = M_.params(1);
|
alp = M_.params(1);
|
||||||
bet = M_.params(2);
|
bet = M_.params(2);
|
||||||
gam = M_.params(3);
|
gam = M_.params(3);
|
||||||
mst = M_.params(4);
|
mst = M_.params(4);
|
||||||
rho = M_.params(5);
|
rho = M_.params(5);
|
||||||
psi = M_.params(6);
|
psi = M_.params(6);
|
||||||
del = M_.params(7);
|
del = M_.params(7);
|
||||||
|
|
||||||
check = 0;
|
check = 0;
|
||||||
|
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
gst = 1/dA;
|
gst = 1/dA;
|
||||||
m = mst;
|
m = mst;
|
||||||
|
|
||||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||||
n = xist/(nust+xist);
|
n = xist/(nust+xist);
|
||||||
P = xist + nust;
|
P = xist + nust;
|
||||||
k = khst*n;
|
k = khst*n;
|
||||||
|
|
||||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||||
c = mst/P;
|
c = mst/P;
|
||||||
d = l - mst + 1;
|
d = l - mst + 1;
|
||||||
y = k^alp*n^(1-alp)*gst^alp;
|
y = k^alp*n^(1-alp)*gst^alp;
|
||||||
R = mst/bet;
|
R = mst/bet;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
ist = y-c;
|
ist = y-c;
|
||||||
q = 1 - d;
|
q = 1 - d;
|
||||||
|
|
||||||
e = 1;
|
e = 1;
|
||||||
|
|
||||||
gp_obs = m/dA;
|
gp_obs = m/dA;
|
||||||
gy_obs = dA;
|
gy_obs = dA;
|
||||||
|
|
||||||
P_obs = 1;
|
P_obs = 1;
|
||||||
Y_obs = 1;
|
Y_obs = 1;
|
||||||
|
|
||||||
P2=P;
|
P2=P;
|
||||||
c2=c;
|
c2=c;
|
||||||
|
|
||||||
ys =[
|
ys =[
|
||||||
m
|
m
|
||||||
P
|
P
|
||||||
c
|
c
|
||||||
e
|
e
|
||||||
W
|
W
|
||||||
R
|
R
|
||||||
k
|
k
|
||||||
d
|
d
|
||||||
n
|
n
|
||||||
l
|
l
|
||||||
gy_obs
|
gy_obs
|
||||||
gp_obs
|
gp_obs
|
||||||
Y_obs
|
Y_obs
|
||||||
P_obs
|
P_obs
|
||||||
y
|
y
|
||||||
dA
|
dA
|
||||||
P2
|
P2
|
||||||
c2 ];
|
c2 ];
|
|
@ -1,210 +1,210 @@
|
||||||
data_q = [
|
data_q = [
|
||||||
18.02 1474.5 150.2
|
18.02 1474.5 150.2
|
||||||
17.94 1538.2 150.9
|
17.94 1538.2 150.9
|
||||||
18.01 1584.5 151.4
|
18.01 1584.5 151.4
|
||||||
18.42 1644.1 152
|
18.42 1644.1 152
|
||||||
18.73 1678.6 152.7
|
18.73 1678.6 152.7
|
||||||
19.46 1693.1 153.3
|
19.46 1693.1 153.3
|
||||||
19.55 1724 153.9
|
19.55 1724 153.9
|
||||||
19.56 1758.2 154.7
|
19.56 1758.2 154.7
|
||||||
19.79 1760.6 155.4
|
19.79 1760.6 155.4
|
||||||
19.77 1779.2 156
|
19.77 1779.2 156
|
||||||
19.82 1778.8 156.6
|
19.82 1778.8 156.6
|
||||||
20.03 1790.9 157.3
|
20.03 1790.9 157.3
|
||||||
20.12 1846 158
|
20.12 1846 158
|
||||||
20.1 1882.6 158.6
|
20.1 1882.6 158.6
|
||||||
20.14 1897.3 159.2
|
20.14 1897.3 159.2
|
||||||
20.22 1887.4 160
|
20.22 1887.4 160
|
||||||
20.27 1858.2 160.7
|
20.27 1858.2 160.7
|
||||||
20.34 1849.9 161.4
|
20.34 1849.9 161.4
|
||||||
20.39 1848.5 162
|
20.39 1848.5 162
|
||||||
20.42 1868.9 162.8
|
20.42 1868.9 162.8
|
||||||
20.47 1905.6 163.6
|
20.47 1905.6 163.6
|
||||||
20.56 1959.6 164.3
|
20.56 1959.6 164.3
|
||||||
20.62 1994.4 164.9
|
20.62 1994.4 164.9
|
||||||
20.78 2020.1 165.7
|
20.78 2020.1 165.7
|
||||||
21 2030.5 166.5
|
21 2030.5 166.5
|
||||||
21.2 2023.6 167.2
|
21.2 2023.6 167.2
|
||||||
21.33 2037.7 167.9
|
21.33 2037.7 167.9
|
||||||
21.62 2033.4 168.7
|
21.62 2033.4 168.7
|
||||||
21.71 2066.2 169.5
|
21.71 2066.2 169.5
|
||||||
22.01 2077.5 170.2
|
22.01 2077.5 170.2
|
||||||
22.15 2071.9 170.9
|
22.15 2071.9 170.9
|
||||||
22.27 2094 171.7
|
22.27 2094 171.7
|
||||||
22.29 2070.8 172.5
|
22.29 2070.8 172.5
|
||||||
22.56 2012.6 173.1
|
22.56 2012.6 173.1
|
||||||
22.64 2024.7 173.8
|
22.64 2024.7 173.8
|
||||||
22.77 2072.3 174.5
|
22.77 2072.3 174.5
|
||||||
22.88 2120.6 175.3
|
22.88 2120.6 175.3
|
||||||
22.92 2165 176.045
|
22.92 2165 176.045
|
||||||
22.91 2223.3 176.727
|
22.91 2223.3 176.727
|
||||||
22.94 2221.4 177.481
|
22.94 2221.4 177.481
|
||||||
23.03 2230.95 178.268
|
23.03 2230.95 178.268
|
||||||
23.13 2279.22 179.694
|
23.13 2279.22 179.694
|
||||||
23.22 2265.48 180.335
|
23.22 2265.48 180.335
|
||||||
23.32 2268.29 181.094
|
23.32 2268.29 181.094
|
||||||
23.4 2238.57 181.915
|
23.4 2238.57 181.915
|
||||||
23.45 2251.68 182.634
|
23.45 2251.68 182.634
|
||||||
23.51 2292.02 183.337
|
23.51 2292.02 183.337
|
||||||
23.56 2332.61 184.103
|
23.56 2332.61 184.103
|
||||||
23.63 2381.01 184.894
|
23.63 2381.01 184.894
|
||||||
23.75 2422.59 185.553
|
23.75 2422.59 185.553
|
||||||
23.81 2448.01 186.203
|
23.81 2448.01 186.203
|
||||||
23.87 2471.86 186.926
|
23.87 2471.86 186.926
|
||||||
23.94 2476.67 187.68
|
23.94 2476.67 187.68
|
||||||
24 2508.7 188.299
|
24 2508.7 188.299
|
||||||
24.07 2538.05 188.906
|
24.07 2538.05 188.906
|
||||||
24.12 2586.26 189.631
|
24.12 2586.26 189.631
|
||||||
24.29 2604.62 190.362
|
24.29 2604.62 190.362
|
||||||
24.35 2666.69 190.954
|
24.35 2666.69 190.954
|
||||||
24.41 2697.54 191.56
|
24.41 2697.54 191.56
|
||||||
24.52 2729.63 192.256
|
24.52 2729.63 192.256
|
||||||
24.64 2739.75 192.938
|
24.64 2739.75 192.938
|
||||||
24.77 2808.88 193.467
|
24.77 2808.88 193.467
|
||||||
24.88 2846.34 193.994
|
24.88 2846.34 193.994
|
||||||
25.01 2898.79 194.647
|
25.01 2898.79 194.647
|
||||||
25.17 2970.48 195.279
|
25.17 2970.48 195.279
|
||||||
25.32 3042.35 195.763
|
25.32 3042.35 195.763
|
||||||
25.53 3055.53 196.277
|
25.53 3055.53 196.277
|
||||||
25.79 3076.51 196.877
|
25.79 3076.51 196.877
|
||||||
26.02 3102.36 197.481
|
26.02 3102.36 197.481
|
||||||
26.14 3127.15 197.967
|
26.14 3127.15 197.967
|
||||||
26.31 3129.53 198.455
|
26.31 3129.53 198.455
|
||||||
26.6 3154.19 199.012
|
26.6 3154.19 199.012
|
||||||
26.9 3177.98 199.572
|
26.9 3177.98 199.572
|
||||||
27.21 3236.18 199.995
|
27.21 3236.18 199.995
|
||||||
27.49 3292.07 200.452
|
27.49 3292.07 200.452
|
||||||
27.75 3316.11 200.997
|
27.75 3316.11 200.997
|
||||||
28.12 3331.22 201.538
|
28.12 3331.22 201.538
|
||||||
28.39 3381.86 201.955
|
28.39 3381.86 201.955
|
||||||
28.73 3390.23 202.419
|
28.73 3390.23 202.419
|
||||||
29.14 3409.65 202.986
|
29.14 3409.65 202.986
|
||||||
29.51 3392.6 203.584
|
29.51 3392.6 203.584
|
||||||
29.94 3386.49 204.086
|
29.94 3386.49 204.086
|
||||||
30.36 3391.61 204.721
|
30.36 3391.61 204.721
|
||||||
30.61 3422.95 205.419
|
30.61 3422.95 205.419
|
||||||
31.02 3389.36 206.13
|
31.02 3389.36 206.13
|
||||||
31.5 3481.4 206.763
|
31.5 3481.4 206.763
|
||||||
31.93 3500.95 207.362
|
31.93 3500.95 207.362
|
||||||
32.27 3523.8 208
|
32.27 3523.8 208
|
||||||
32.54 3533.79 208.642
|
32.54 3533.79 208.642
|
||||||
33.02 3604.73 209.142
|
33.02 3604.73 209.142
|
||||||
33.2 3687.9 209.637
|
33.2 3687.9 209.637
|
||||||
33.49 3726.18 210.181
|
33.49 3726.18 210.181
|
||||||
33.95 3790.44 210.737
|
33.95 3790.44 210.737
|
||||||
34.36 3892.22 211.192
|
34.36 3892.22 211.192
|
||||||
34.94 3919.01 211.663
|
34.94 3919.01 211.663
|
||||||
35.61 3907.08 212.191
|
35.61 3907.08 212.191
|
||||||
36.29 3947.11 212.708
|
36.29 3947.11 212.708
|
||||||
37.01 3908.15 213.144
|
37.01 3908.15 213.144
|
||||||
37.79 3922.57 213.602
|
37.79 3922.57 213.602
|
||||||
38.96 3879.98 214.147
|
38.96 3879.98 214.147
|
||||||
40.13 3854.13 214.7
|
40.13 3854.13 214.7
|
||||||
41.05 3800.93 215.135
|
41.05 3800.93 215.135
|
||||||
41.66 3835.21 215.652
|
41.66 3835.21 215.652
|
||||||
42.41 3907.02 216.289
|
42.41 3907.02 216.289
|
||||||
43.19 3952.48 216.848
|
43.19 3952.48 216.848
|
||||||
43.69 4044.59 217.314
|
43.69 4044.59 217.314
|
||||||
44.15 4072.19 217.776
|
44.15 4072.19 217.776
|
||||||
44.77 4088.49 218.338
|
44.77 4088.49 218.338
|
||||||
45.57 4126.39 218.917
|
45.57 4126.39 218.917
|
||||||
46.32 4176.28 219.427
|
46.32 4176.28 219.427
|
||||||
47.07 4260.08 219.956
|
47.07 4260.08 219.956
|
||||||
47.66 4329.46 220.573
|
47.66 4329.46 220.573
|
||||||
48.63 4328.33 221.201
|
48.63 4328.33 221.201
|
||||||
49.42 4345.51 221.719
|
49.42 4345.51 221.719
|
||||||
50.41 4510.73 222.281
|
50.41 4510.73 222.281
|
||||||
51.27 4552.14 222.933
|
51.27 4552.14 222.933
|
||||||
52.35 4603.65 223.583
|
52.35 4603.65 223.583
|
||||||
53.51 4605.65 224.152
|
53.51 4605.65 224.152
|
||||||
54.65 4615.64 224.737
|
54.65 4615.64 224.737
|
||||||
55.82 4644.93 225.418
|
55.82 4644.93 225.418
|
||||||
56.92 4656.23 226.117
|
56.92 4656.23 226.117
|
||||||
58.18 4678.96 226.754
|
58.18 4678.96 226.754
|
||||||
59.55 4566.62 227.389
|
59.55 4566.62 227.389
|
||||||
61.01 4562.25 228.07
|
61.01 4562.25 228.07
|
||||||
62.59 4651.86 228.689
|
62.59 4651.86 228.689
|
||||||
64.15 4739.16 229.155
|
64.15 4739.16 229.155
|
||||||
65.37 4696.82 229.674
|
65.37 4696.82 229.674
|
||||||
66.65 4753.02 230.301
|
66.65 4753.02 230.301
|
||||||
67.87 4693.76 230.903
|
67.87 4693.76 230.903
|
||||||
68.86 4615.89 231.395
|
68.86 4615.89 231.395
|
||||||
69.72 4634.88 231.906
|
69.72 4634.88 231.906
|
||||||
70.66 4612.08 232.498
|
70.66 4612.08 232.498
|
||||||
71.44 4618.26 233.074
|
71.44 4618.26 233.074
|
||||||
72.08 4662.97 233.546
|
72.08 4662.97 233.546
|
||||||
72.83 4763.57 234.028
|
72.83 4763.57 234.028
|
||||||
73.48 4849 234.603
|
73.48 4849 234.603
|
||||||
74.19 4939.23 235.153
|
74.19 4939.23 235.153
|
||||||
75.02 5053.56 235.605
|
75.02 5053.56 235.605
|
||||||
75.58 5132.87 236.082
|
75.58 5132.87 236.082
|
||||||
76.25 5170.34 236.657
|
76.25 5170.34 236.657
|
||||||
76.81 5203.68 237.232
|
76.81 5203.68 237.232
|
||||||
77.63 5257.26 237.673
|
77.63 5257.26 237.673
|
||||||
78.25 5283.73 238.176
|
78.25 5283.73 238.176
|
||||||
78.76 5359.6 238.789
|
78.76 5359.6 238.789
|
||||||
79.45 5393.57 239.387
|
79.45 5393.57 239.387
|
||||||
79.81 5460.83 239.861
|
79.81 5460.83 239.861
|
||||||
80.22 5466.95 240.368
|
80.22 5466.95 240.368
|
||||||
80.84 5496.29 240.962
|
80.84 5496.29 240.962
|
||||||
81.45 5526.77 241.539
|
81.45 5526.77 241.539
|
||||||
82.09 5561.8 242.009
|
82.09 5561.8 242.009
|
||||||
82.68 5618 242.52
|
82.68 5618 242.52
|
||||||
83.33 5667.39 243.12
|
83.33 5667.39 243.12
|
||||||
84.09 5750.57 243.721
|
84.09 5750.57 243.721
|
||||||
84.67 5785.29 244.208
|
84.67 5785.29 244.208
|
||||||
85.56 5844.05 244.716
|
85.56 5844.05 244.716
|
||||||
86.66 5878.7 245.354
|
86.66 5878.7 245.354
|
||||||
87.44 5952.83 245.966
|
87.44 5952.83 245.966
|
||||||
88.45 6010.96 246.46
|
88.45 6010.96 246.46
|
||||||
89.39 6055.61 247.017
|
89.39 6055.61 247.017
|
||||||
90.13 6087.96 247.698
|
90.13 6087.96 247.698
|
||||||
90.88 6093.51 248.374
|
90.88 6093.51 248.374
|
||||||
92 6152.59 248.928
|
92 6152.59 248.928
|
||||||
93.18 6171.57 249.564
|
93.18 6171.57 249.564
|
||||||
94.14 6142.1 250.299
|
94.14 6142.1 250.299
|
||||||
95.11 6078.96 251.031
|
95.11 6078.96 251.031
|
||||||
96.27 6047.49 251.65
|
96.27 6047.49 251.65
|
||||||
97 6074.66 252.295
|
97 6074.66 252.295
|
||||||
97.7 6090.14 253.033
|
97.7 6090.14 253.033
|
||||||
98.31 6105.25 253.743
|
98.31 6105.25 253.743
|
||||||
99.13 6175.69 254.338
|
99.13 6175.69 254.338
|
||||||
99.79 6214.22 255.032
|
99.79 6214.22 255.032
|
||||||
100.17 6260.74 255.815
|
100.17 6260.74 255.815
|
||||||
100.88 6327.12 256.543
|
100.88 6327.12 256.543
|
||||||
101.84 6327.93 257.151
|
101.84 6327.93 257.151
|
||||||
102.35 6359.9 257.785
|
102.35 6359.9 257.785
|
||||||
102.83 6393.5 258.516
|
102.83 6393.5 258.516
|
||||||
103.51 6476.86 259.191
|
103.51 6476.86 259.191
|
||||||
104.13 6524.5 259.738
|
104.13 6524.5 259.738
|
||||||
104.71 6600.31 260.351
|
104.71 6600.31 260.351
|
||||||
105.39 6629.47 261.04
|
105.39 6629.47 261.04
|
||||||
106.09 6688.61 261.692
|
106.09 6688.61 261.692
|
||||||
106.75 6717.46 262.236
|
106.75 6717.46 262.236
|
||||||
107.24 6724.2 262.847
|
107.24 6724.2 262.847
|
||||||
107.75 6779.53 263.527
|
107.75 6779.53 263.527
|
||||||
108.29 6825.8 264.169
|
108.29 6825.8 264.169
|
||||||
108.91 6882 264.681
|
108.91 6882 264.681
|
||||||
109.24 6983.91 265.258
|
109.24 6983.91 265.258
|
||||||
109.74 7020 265.887
|
109.74 7020 265.887
|
||||||
110.23 7093.12 266.491
|
110.23 7093.12 266.491
|
||||||
111 7166.68 266.987
|
111 7166.68 266.987
|
||||||
111.43 7236.5 267.545
|
111.43 7236.5 267.545
|
||||||
111.76 7311.24 268.171
|
111.76 7311.24 268.171
|
||||||
112.08 7364.63 268.815
|
112.08 7364.63 268.815
|
||||||
];
|
];
|
||||||
%GDPD GDPQ GPOP
|
%GDPD GDPQ GPOP
|
||||||
|
|
||||||
series = zeros(193,2);
|
series = zeros(193,2);
|
||||||
series(:,2) = data_q(:,1);
|
series(:,2) = data_q(:,1);
|
||||||
series(:,1) = 1000*data_q(:,2)./data_q(:,3);
|
series(:,1) = 1000*data_q(:,2)./data_q(:,3);
|
||||||
|
|
||||||
Y_obs = series(:,1);
|
Y_obs = series(:,1);
|
||||||
P_obs = series(:,2);
|
P_obs = series(:,2);
|
||||||
|
|
||||||
series = series(2:193,:)./series(1:192,:);
|
series = series(2:193,:)./series(1:192,:);
|
||||||
|
|
||||||
gy_obs = series(:,1);
|
gy_obs = series(:,1);
|
||||||
gp_obs = series(:,2);
|
gp_obs = series(:,2);
|
||||||
|
|
||||||
ti = [1950:0.25:1997.75];
|
ti = [1950:0.25:1997.75];
|
|
@ -1,58 +1,58 @@
|
||||||
// Test for varexo_det and forecast command at order 1
|
// Test for varexo_det and forecast command at order 1
|
||||||
|
|
||||||
var y, c, k, a, h, b;
|
var y, c, k, a, h, b;
|
||||||
varexo e,u;
|
varexo e,u;
|
||||||
varexo_det ahat, bhat;
|
varexo_det ahat, bhat;
|
||||||
|
|
||||||
parameters beta, rho, alpha, delta, theta, psi, tau;
|
parameters beta, rho, alpha, delta, theta, psi, tau;
|
||||||
|
|
||||||
alpha = 0.36;
|
alpha = 0.36;
|
||||||
rho = 0.95;
|
rho = 0.95;
|
||||||
tau = 0.025;
|
tau = 0.025;
|
||||||
beta = 0.99;
|
beta = 0.99;
|
||||||
delta = 0.025;
|
delta = 0.025;
|
||||||
psi = 0;
|
psi = 0;
|
||||||
theta = 2.95;
|
theta = 2.95;
|
||||||
|
|
||||||
phi = 0.1;
|
phi = 0.1;
|
||||||
|
|
||||||
//model(bytecode);
|
//model(bytecode);
|
||||||
model;
|
model;
|
||||||
c*theta*h^(1+psi)=(1-alpha)*y;
|
c*theta*h^(1+psi)=(1-alpha)*y;
|
||||||
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
|
k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1)))
|
||||||
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
|
*(exp(b(+1))*alpha*y(+1)+(1-delta)*k));
|
||||||
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
|
y = exp(a)*(k(-1)^alpha)*(h^(1-alpha));
|
||||||
k = exp(b)*(y-c)+(1-delta)*k(-1);
|
k = exp(b)*(y-c)+(1-delta)*k(-1);
|
||||||
a = ahat+ rho*a(-1)+tau*b(-1) + e;
|
a = ahat+ rho*a(-1)+tau*b(-1) + e;
|
||||||
b = bhat+ tau*a(-1)+rho*b(-1) + u;
|
b = bhat+ tau*a(-1)+rho*b(-1) + u;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
y = 1.08068253095672;
|
y = 1.08068253095672;
|
||||||
c = 0.80359242014163;
|
c = 0.80359242014163;
|
||||||
h = 0.29175631001732;
|
h = 0.29175631001732;
|
||||||
k = 5;
|
k = 5;
|
||||||
a = 0;
|
a = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
e = 0;
|
e = 0;
|
||||||
u = 0;
|
u = 0;
|
||||||
ahat = 0;
|
ahat = 0;
|
||||||
bhat = 0;
|
bhat = 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//simul(periods=20);
|
//simul(periods=20);
|
||||||
shocks;
|
shocks;
|
||||||
var e; stderr 0.009;
|
var e; stderr 0.009;
|
||||||
var u; stderr 0.009;
|
var u; stderr 0.009;
|
||||||
var e, u = phi*0.009*0.009;
|
var e, u = phi*0.009*0.009;
|
||||||
var ahat;
|
var ahat;
|
||||||
periods 1;
|
periods 1;
|
||||||
values 0.1;
|
values 0.1;
|
||||||
var bhat;
|
var bhat;
|
||||||
periods 2;
|
periods 2;
|
||||||
values 0.2;
|
values 0.2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
stoch_simul(order=1,irf=0,noprint);
|
stoch_simul(order=1,irf=0,noprint);
|
||||||
|
|
||||||
forecast(periods=20);
|
forecast(periods=20);
|
||||||
|
|
|
@ -1,79 +1,79 @@
|
||||||
//$ Declaration of the endogenous variables of the DSGE model.
|
//$ Declaration of the endogenous variables of the DSGE model.
|
||||||
var a g mc mrs n winf pie r rw y;
|
var a g mc mrs n winf pie r rw y;
|
||||||
|
|
||||||
//$ Declaration of the exogenous variables of the DSGE model.
|
//$ Declaration of the exogenous variables of the DSGE model.
|
||||||
varexo e_a e_g e_lam e_ms;
|
varexo e_a e_g e_lam e_ms;
|
||||||
|
|
||||||
//$ Declaration of the deep parameters
|
//$ Declaration of the deep parameters
|
||||||
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
||||||
thetabig omega eps ;
|
thetabig omega eps ;
|
||||||
|
|
||||||
eps=6;
|
eps=6;
|
||||||
thetabig=2;
|
thetabig=2;
|
||||||
bet=0.99;
|
bet=0.99;
|
||||||
invsig=2.5;
|
invsig=2.5;
|
||||||
gampie=1.5;
|
gampie=1.5;
|
||||||
gamy=0.125;
|
gamy=0.125;
|
||||||
gam=1;
|
gam=1;
|
||||||
delta=0.36;
|
delta=0.36;
|
||||||
omega=0.54;
|
omega=0.54;
|
||||||
rhoa=0.5;
|
rhoa=0.5;
|
||||||
rhog=0.5;
|
rhog=0.5;
|
||||||
rho=0.5;
|
rho=0.5;
|
||||||
|
|
||||||
|
|
||||||
//$ Specification of the DSGE model used as a prior of the VAR model.
|
//$ Specification of the DSGE model used as a prior of the VAR model.
|
||||||
model(linear);
|
model(linear);
|
||||||
|
|
||||||
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
||||||
y=a+(1-delta)*n;
|
y=a+(1-delta)*n;
|
||||||
mc=rw+n-y;
|
mc=rw+n-y;
|
||||||
mrs=invsig*y+gam*n-g;
|
mrs=invsig*y+gam*n-g;
|
||||||
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
||||||
rw=rw(-1)+winf-pie;
|
rw=rw(-1)+winf-pie;
|
||||||
a=rhoa*a(-1)+e_a;
|
a=rhoa*a(-1)+e_a;
|
||||||
g=rhog*g(-1)+e_g;
|
g=rhog*g(-1)+e_g;
|
||||||
rw=mrs;
|
rw=mrs;
|
||||||
|
|
||||||
//$ HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
//$ HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
||||||
// pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
// pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
||||||
// (1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
// (1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
||||||
|
|
||||||
//$ FORWARD LOOKING PHILLIPS CURVE:
|
//$ FORWARD LOOKING PHILLIPS CURVE:
|
||||||
pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$ Declaration of the prior beliefs about the deep parameters.
|
//$ Declaration of the prior beliefs about the deep parameters.
|
||||||
estimated_params;
|
estimated_params;
|
||||||
stderr e_a, uniform_pdf,,,0,2;
|
stderr e_a, uniform_pdf,,,0,2;
|
||||||
stderr e_g, uniform_pdf,,,0,2;
|
stderr e_g, uniform_pdf,,,0,2;
|
||||||
stderr e_ms, uniform_pdf,,,0,2;
|
stderr e_ms, uniform_pdf,,,0,2;
|
||||||
stderr e_lam, uniform_pdf,,,0,2;
|
stderr e_lam, uniform_pdf,,,0,2;
|
||||||
|
|
||||||
invsig, gamma_pdf, 2.5, 1.76;
|
invsig, gamma_pdf, 2.5, 1.76;
|
||||||
gam, normal_pdf, 1, 0.5;
|
gam, normal_pdf, 1, 0.5;
|
||||||
rho, uniform_pdf,,,0,1;
|
rho, uniform_pdf,,,0,1;
|
||||||
gampie, normal_pdf, 1.5, 0.25;
|
gampie, normal_pdf, 1.5, 0.25;
|
||||||
gamy, gamma_pdf, 0.125, 0.075;
|
gamy, gamma_pdf, 0.125, 0.075;
|
||||||
rhoa, uniform_pdf,,,0,1;
|
rhoa, uniform_pdf,,,0,1;
|
||||||
rhog, uniform_pdf,,,0,1;
|
rhog, uniform_pdf,,,0,1;
|
||||||
thetabig, gamma_pdf, 3, 1.42, 1, ;
|
thetabig, gamma_pdf, 3, 1.42, 1, ;
|
||||||
|
|
||||||
//$Parameter for the hybrid Phillips curve
|
//$Parameter for the hybrid Phillips curve
|
||||||
//omega, uniform_pdf,,,0,1;
|
//omega, uniform_pdf,,,0,1;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//$ Declaration of the observed endogenous variables. Note that they are the variables of the VAR (4 by default) and that we must
|
//$ Declaration of the observed endogenous variables. Note that they are the variables of the VAR (4 by default) and that we must
|
||||||
//$ have as many observed variables as exogenous variables.
|
//$ have as many observed variables as exogenous variables.
|
||||||
varobs pie r rw y;
|
varobs pie r rw y;
|
||||||
|
|
||||||
options_.gradient_method = 3;
|
options_.gradient_method = 3;
|
||||||
|
|
||||||
//$ The option bayesian_irf triggers the computation of the DSGE-VAR and DSGE posterior distribution of the IRFs.
|
//$ The option bayesian_irf triggers the computation of the DSGE-VAR and DSGE posterior distribution of the IRFs.
|
||||||
//$ The Dashed lines are the first, fifth (ie the median) and ninth posterior deciles of the DSGE-VAR's IRFs, the bold dark curve is the
|
//$ The Dashed lines are the first, fifth (ie the median) and ninth posterior deciles of the DSGE-VAR's IRFs, the bold dark curve is the
|
||||||
//$ posterior median of the DSGE's IRfs and the shaded surface covers the space between the first and ninth posterior deciles of the DSGE's IRFs.
|
//$ posterior median of the DSGE's IRfs and the shaded surface covers the space between the first and ninth posterior deciles of the DSGE's IRFs.
|
||||||
estimation(datafile=datarabanal_hybrid,first_obs=50,mh_nblocks = 1,nobs=90,dsge_var=.8,mode_compute=4,mh_replic=2000,bayesian_irf);
|
estimation(datafile=datarabanal_hybrid,first_obs=50,mh_nblocks = 1,nobs=90,dsge_var=.8,mode_compute=4,mh_replic=2000,bayesian_irf);
|
||||||
|
|
|
@ -1,80 +1,80 @@
|
||||||
//$ Declaration of the endogenous variables of the DSGE model.
|
//$ Declaration of the endogenous variables of the DSGE model.
|
||||||
var a g mc mrs n winf pie r rw y;
|
var a g mc mrs n winf pie r rw y;
|
||||||
|
|
||||||
//$ Declaration of the exogenous variables of the DSGE model.
|
//$ Declaration of the exogenous variables of the DSGE model.
|
||||||
varexo e_a e_g e_lam e_ms;
|
varexo e_a e_g e_lam e_ms;
|
||||||
|
|
||||||
//$ Declaration of the deep parameters and of dsge_prior_weight
|
//$ Declaration of the deep parameters and of dsge_prior_weight
|
||||||
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
||||||
thetabig omega eps ;
|
thetabig omega eps ;
|
||||||
|
|
||||||
eps=6;
|
eps=6;
|
||||||
thetabig=2;
|
thetabig=2;
|
||||||
bet=0.99;
|
bet=0.99;
|
||||||
invsig=2.5;
|
invsig=2.5;
|
||||||
gampie=1.5;
|
gampie=1.5;
|
||||||
gamy=0.125;
|
gamy=0.125;
|
||||||
gam=1;
|
gam=1;
|
||||||
delta=0.36;
|
delta=0.36;
|
||||||
omega=0.54;
|
omega=0.54;
|
||||||
rhoa=0.5;
|
rhoa=0.5;
|
||||||
rhog=0.5;
|
rhog=0.5;
|
||||||
rho=0.5;
|
rho=0.5;
|
||||||
|
|
||||||
|
|
||||||
//$ Specification of the DSGE model used as a prior of the VAR model.
|
//$ Specification of the DSGE model used as a prior of the VAR model.
|
||||||
model(linear);
|
model(linear);
|
||||||
|
|
||||||
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
||||||
y=a+(1-delta)*n;
|
y=a+(1-delta)*n;
|
||||||
mc=rw+n-y;
|
mc=rw+n-y;
|
||||||
mrs=invsig*y+gam*n-g;
|
mrs=invsig*y+gam*n-g;
|
||||||
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
||||||
rw=rw(-1)+winf-pie;
|
rw=rw(-1)+winf-pie;
|
||||||
a=rhoa*a(-1)+e_a;
|
a=rhoa*a(-1)+e_a;
|
||||||
g=rhog*g(-1)+e_g;
|
g=rhog*g(-1)+e_g;
|
||||||
rw=mrs;
|
rw=mrs;
|
||||||
|
|
||||||
//$ HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
//$ HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
||||||
// pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
// pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
||||||
// (1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
// (1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
||||||
|
|
||||||
//$ FORWARD LOOKING PHILLIPS CURVE:
|
//$ FORWARD LOOKING PHILLIPS CURVE:
|
||||||
pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//$ Declaration of the prior beliefs about the deep parameters and the weight of the DSGE prior.
|
//$ Declaration of the prior beliefs about the deep parameters and the weight of the DSGE prior.
|
||||||
estimated_params;
|
estimated_params;
|
||||||
stderr e_a, uniform_pdf,,,0,2;
|
stderr e_a, uniform_pdf,,,0,2;
|
||||||
stderr e_g, uniform_pdf,,,0,2;
|
stderr e_g, uniform_pdf,,,0,2;
|
||||||
stderr e_ms, uniform_pdf,,,0,2;
|
stderr e_ms, uniform_pdf,,,0,2;
|
||||||
stderr e_lam, uniform_pdf,,,0,2;
|
stderr e_lam, uniform_pdf,,,0,2;
|
||||||
|
|
||||||
invsig, gamma_pdf, 2.5, 1.76;
|
invsig, gamma_pdf, 2.5, 1.76;
|
||||||
gam, normal_pdf, 1, 0.5;
|
gam, normal_pdf, 1, 0.5;
|
||||||
rho, uniform_pdf,,,0,1;
|
rho, uniform_pdf,,,0,1;
|
||||||
gampie, normal_pdf, 1.5, 0.25;
|
gampie, normal_pdf, 1.5, 0.25;
|
||||||
gamy, gamma_pdf, 0.125, 0.075;
|
gamy, gamma_pdf, 0.125, 0.075;
|
||||||
rhoa, uniform_pdf,,,0,1;
|
rhoa, uniform_pdf,,,0,1;
|
||||||
rhog, uniform_pdf,,,0,1;
|
rhog, uniform_pdf,,,0,1;
|
||||||
thetabig, gamma_pdf, 3, 1.42, 1, ;
|
thetabig, gamma_pdf, 3, 1.42, 1, ;
|
||||||
|
|
||||||
//$Parameter for the hybrid Phillips curve
|
//$Parameter for the hybrid Phillips curve
|
||||||
//omega, uniform_pdf,,,0,1;
|
//omega, uniform_pdf,,,0,1;
|
||||||
|
|
||||||
dsge_prior_weight, uniform_pdf,,,0,1.9;
|
dsge_prior_weight, uniform_pdf,,,0,1.9;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//$ Declaration of the observed endogenous variables. Note that they are the variables of the VAR (4 by default) and that we must
|
//$ Declaration of the observed endogenous variables. Note that they are the variables of the VAR (4 by default) and that we must
|
||||||
//$ have as many observed variables as exogenous variables.
|
//$ have as many observed variables as exogenous variables.
|
||||||
varobs pie r rw y;
|
varobs pie r rw y;
|
||||||
|
|
||||||
options_.gradient_method = 3;
|
options_.gradient_method = 3;
|
||||||
|
|
||||||
//$ The option bayesian_irf triggers the computation of the DSGE-VAR and DSGE posterior distribution of the IRFs.
|
//$ The option bayesian_irf triggers the computation of the DSGE-VAR and DSGE posterior distribution of the IRFs.
|
||||||
//$ The Dashed lines are the first, fifth (ie the median) and ninth posterior deciles of the DSGE-VAR's IRFs, the bold dark curve is the
|
//$ The Dashed lines are the first, fifth (ie the median) and ninth posterior deciles of the DSGE-VAR's IRFs, the bold dark curve is the
|
||||||
//$ posterior median of the DSGE's IRfs and the shaded surface covers the space between the first and ninth posterior deciles of the DSGE's IRFs.
|
//$ posterior median of the DSGE's IRfs and the shaded surface covers the space between the first and ninth posterior deciles of the DSGE's IRFs.
|
||||||
estimation(datafile=datarabanal_hybrid,first_obs=50,mh_nblocks = 1,nobs=90,dsge_var,mode_compute=4,mh_replic=2000,bayesian_irf);
|
estimation(datafile=datarabanal_hybrid,first_obs=50,mh_nblocks = 1,nobs=90,dsge_var,mode_compute=4,mh_replic=2000,bayesian_irf);
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
var a g mc mrs n pie r rw winf y;
|
var a g mc mrs n pie r rw winf y;
|
||||||
varexo e_a e_g e_lam e_ms;
|
varexo e_a e_g e_lam e_ms;
|
||||||
|
|
||||||
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
parameters invsig delta gam rho gampie gamy rhoa rhog bet
|
||||||
thetabig omega eps;
|
thetabig omega eps;
|
||||||
|
|
||||||
eps=6;
|
eps=6;
|
||||||
thetabig=2;
|
thetabig=2;
|
||||||
bet=0.99;
|
bet=0.99;
|
||||||
invsig=2.5;
|
invsig=2.5;
|
||||||
gampie=1.5;
|
gampie=1.5;
|
||||||
gamy=0.125;
|
gamy=0.125;
|
||||||
gam=1;
|
gam=1;
|
||||||
delta=0.36;
|
delta=0.36;
|
||||||
omega=0.54;
|
omega=0.54;
|
||||||
rhoa=0.5;
|
rhoa=0.5;
|
||||||
rhog=0.5;
|
rhog=0.5;
|
||||||
rho=0.5;
|
rho=0.5;
|
||||||
|
|
||||||
|
|
||||||
model(linear);
|
model(linear);
|
||||||
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
y=y(+1)-(1/invsig)*(r-pie(+1)+g(+1)-g);
|
||||||
y=a+(1-delta)*n;
|
y=a+(1-delta)*n;
|
||||||
mc=rw+n-y;
|
mc=rw+n-y;
|
||||||
mrs=invsig*y+gam*n-g;
|
mrs=invsig*y+gam*n-g;
|
||||||
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
r=rho*r(-1)+(1-rho)*(gampie*pie+gamy*y)+e_ms;
|
||||||
rw=rw(-1)+winf-pie;
|
rw=rw(-1)+winf-pie;
|
||||||
a=rhoa*a(-1)+e_a;
|
a=rhoa*a(-1)+e_a;
|
||||||
g=rhog*g(-1)+e_g;
|
g=rhog*g(-1)+e_g;
|
||||||
rw=mrs;
|
rw=mrs;
|
||||||
|
|
||||||
// HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
// HYBRID PHILLIPS CURVED USED FOR THE SUMULATIONS:
|
||||||
pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
pie = (omega/(1+omega*bet))*pie(-1)+(bet/(1+omega*bet))*pie(1)+(1-delta)*
|
||||||
(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))/(1+omega*bet)*(mc+e_lam);
|
||||||
|
|
||||||
// FORWARD LOOKING PHILLIPS CURVE:
|
// FORWARD LOOKING PHILLIPS CURVE:
|
||||||
// pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
// pie=bet*pie(+1)+(1-delta)*(1-(1-1/thetabig)*bet)*(1-(1-1/thetabig))/((1-1/thetabig)*(1+delta*(eps-1)))*(mc+e_lam);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e_a; stderr 1;
|
var e_a; stderr 1;
|
||||||
var e_g; stderr 1;
|
var e_g; stderr 1;
|
||||||
var e_ms; stderr 1;
|
var e_ms; stderr 1;
|
||||||
var e_lam; stderr 1;
|
var e_lam; stderr 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
check;
|
check;
|
||||||
|
|
||||||
stoch_simul(periods=500,irf=0);
|
stoch_simul(periods=500,irf=0);
|
||||||
datatomfile('datarabanal_hybrid',[]);
|
datatomfile('datarabanal_hybrid',[]);
|
|
@ -1,45 +1,45 @@
|
||||||
var y pie r;
|
var y pie r;
|
||||||
varexo e_y e_pie;
|
varexo e_y e_pie;
|
||||||
|
|
||||||
parameters delta sigma alpha kappa gamma1 gamma2;
|
parameters delta sigma alpha kappa gamma1 gamma2;
|
||||||
|
|
||||||
delta = 0.44;
|
delta = 0.44;
|
||||||
kappa = 0.18;
|
kappa = 0.18;
|
||||||
alpha = 0.48;
|
alpha = 0.48;
|
||||||
sigma = -0.06;
|
sigma = -0.06;
|
||||||
|
|
||||||
gamma1 = 1.5;
|
gamma1 = 1.5;
|
||||||
gamma2 = 0.5;
|
gamma2 = 0.5;
|
||||||
|
|
||||||
model(use_dll);
|
model(use_dll);
|
||||||
y = delta * y(-1) + (1-delta)*y(+1)+sigma *(r - pie(+1)) + e_y;
|
y = delta * y(-1) + (1-delta)*y(+1)+sigma *(r - pie(+1)) + e_y;
|
||||||
pie = alpha * pie(-1) + (1-alpha) * pie(+1) + kappa*y + e_pie;
|
pie = alpha * pie(-1) + (1-alpha) * pie(+1) + kappa*y + e_pie;
|
||||||
r = gamma1*pie+gamma2*y;
|
r = gamma1*pie+gamma2*y;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e_y;
|
var e_y;
|
||||||
stderr 0.63;
|
stderr 0.63;
|
||||||
var e_pie;
|
var e_pie;
|
||||||
stderr 0.4;
|
stderr 0.4;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
options_.maxit_ = 100;
|
options_.maxit_ = 100;
|
||||||
options_.ep.verbosity = 0;
|
options_.ep.verbosity = 0;
|
||||||
options_.ep.stochastic.status = 0;
|
options_.ep.stochastic.status = 0;
|
||||||
options_.ep.order = 0;
|
options_.ep.order = 0;
|
||||||
options_.ep.nnodes = 0;
|
options_.ep.nnodes = 0;
|
||||||
options_.console_mode = 0;
|
options_.console_mode = 0;
|
||||||
|
|
||||||
ts = extended_path([],100);
|
ts = extended_path([],100);
|
||||||
|
|
||||||
options_.ep.stochastic.status = 1;
|
options_.ep.stochastic.status = 1;
|
||||||
options_.ep.order = 1;
|
options_.ep.order = 1;
|
||||||
options_.ep.nnodes = 3;
|
options_.ep.nnodes = 3;
|
||||||
sts = extended_path([],100);
|
sts = extended_path([],100);
|
||||||
|
|
||||||
if max(max(abs(ts-sts))) > 1e-12
|
if max(max(abs(ts-sts))) > 1e-12
|
||||||
error('extended path algorithm fails in ./tests/ep/linear.mod')
|
error('extended path algorithm fails in ./tests/ep/linear.mod')
|
||||||
end
|
end
|
|
@ -1,60 +1,60 @@
|
||||||
% computes the steady state of fs2000 analyticaly
|
% computes the steady state of fs2000 analyticaly
|
||||||
% largely inspired by the program of F. Schorfheide
|
% largely inspired by the program of F. Schorfheide
|
||||||
function [ys,check] = fs2000a_steadystate(ys,exe)
|
function [ys,check] = fs2000a_steadystate(ys,exe)
|
||||||
global M_
|
global M_
|
||||||
|
|
||||||
alp = M_.params(1);
|
alp = M_.params(1);
|
||||||
bet = M_.params(2);
|
bet = M_.params(2);
|
||||||
gam = M_.params(3);
|
gam = M_.params(3);
|
||||||
mst = M_.params(4);
|
mst = M_.params(4);
|
||||||
rho = M_.params(5);
|
rho = M_.params(5);
|
||||||
psi = M_.params(6);
|
psi = M_.params(6);
|
||||||
del = M_.params(7);
|
del = M_.params(7);
|
||||||
|
|
||||||
check = 0;
|
check = 0;
|
||||||
|
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
gst = 1/dA;
|
gst = 1/dA;
|
||||||
m = mst;
|
m = mst;
|
||||||
|
|
||||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||||
n = xist/(nust+xist);
|
n = xist/(nust+xist);
|
||||||
P = xist + nust;
|
P = xist + nust;
|
||||||
k = khst*n;
|
k = khst*n;
|
||||||
|
|
||||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||||
c = mst/P;
|
c = mst/P;
|
||||||
d = l - mst + 1;
|
d = l - mst + 1;
|
||||||
y = k^alp*n^(1-alp)*gst^alp;
|
y = k^alp*n^(1-alp)*gst^alp;
|
||||||
R = mst/bet;
|
R = mst/bet;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
ist = y-c;
|
ist = y-c;
|
||||||
q = 1 - d;
|
q = 1 - d;
|
||||||
|
|
||||||
e = 1;
|
e = 1;
|
||||||
|
|
||||||
gp_obs = m/dA;
|
gp_obs = m/dA;
|
||||||
gy_obs = dA;
|
gy_obs = dA;
|
||||||
|
|
||||||
P_obs = 1;
|
P_obs = 1;
|
||||||
Y_obs = 1;
|
Y_obs = 1;
|
||||||
|
|
||||||
ys =[
|
ys =[
|
||||||
m
|
m
|
||||||
P
|
P
|
||||||
c
|
c
|
||||||
e
|
e
|
||||||
W
|
W
|
||||||
R
|
R
|
||||||
k
|
k
|
||||||
d
|
d
|
||||||
n
|
n
|
||||||
l
|
l
|
||||||
gy_obs
|
gy_obs
|
||||||
gp_obs
|
gp_obs
|
||||||
Y_obs
|
Y_obs
|
||||||
P_obs
|
P_obs
|
||||||
y
|
y
|
||||||
dA ];
|
dA ];
|
|
@ -1,60 +1,60 @@
|
||||||
% computes the steady state of fs2000 analyticaly
|
% computes the steady state of fs2000 analyticaly
|
||||||
% largely inspired by the program of F. Schorfheide
|
% largely inspired by the program of F. Schorfheide
|
||||||
function [ys,check] = fs2000a_steadystate(ys,exe)
|
function [ys,check] = fs2000a_steadystate(ys,exe)
|
||||||
global M_
|
global M_
|
||||||
|
|
||||||
alp = M_.params(1);
|
alp = M_.params(1);
|
||||||
bet = M_.params(2);
|
bet = M_.params(2);
|
||||||
gam = M_.params(3);
|
gam = M_.params(3);
|
||||||
mst = M_.params(4);
|
mst = M_.params(4);
|
||||||
rho = M_.params(5);
|
rho = M_.params(5);
|
||||||
psi = M_.params(6);
|
psi = M_.params(6);
|
||||||
del = M_.params(7);
|
del = M_.params(7);
|
||||||
|
|
||||||
check = 0;
|
check = 0;
|
||||||
|
|
||||||
dA = exp(gam);
|
dA = exp(gam);
|
||||||
gst = 1/dA;
|
gst = 1/dA;
|
||||||
m = mst;
|
m = mst;
|
||||||
|
|
||||||
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
|
||||||
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
|
||||||
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
|
||||||
n = xist/(nust+xist);
|
n = xist/(nust+xist);
|
||||||
P = xist + nust;
|
P = xist + nust;
|
||||||
k = khst*n;
|
k = khst*n;
|
||||||
|
|
||||||
l = psi*mst*n/( (1-psi)*(1-n) );
|
l = psi*mst*n/( (1-psi)*(1-n) );
|
||||||
c = mst/P;
|
c = mst/P;
|
||||||
d = l - mst + 1;
|
d = l - mst + 1;
|
||||||
y = k^alp*n^(1-alp)*gst^alp;
|
y = k^alp*n^(1-alp)*gst^alp;
|
||||||
R = mst/bet;
|
R = mst/bet;
|
||||||
W = l/n;
|
W = l/n;
|
||||||
ist = y-c;
|
ist = y-c;
|
||||||
q = 1 - d;
|
q = 1 - d;
|
||||||
|
|
||||||
e = 1;
|
e = 1;
|
||||||
|
|
||||||
gp_obs = m/dA;
|
gp_obs = m/dA;
|
||||||
gy_obs = dA;
|
gy_obs = dA;
|
||||||
|
|
||||||
P_obs = 1;
|
P_obs = 1;
|
||||||
Y_obs = 1;
|
Y_obs = 1;
|
||||||
|
|
||||||
ys =[
|
ys =[
|
||||||
m
|
m
|
||||||
P
|
P
|
||||||
c
|
c
|
||||||
e
|
e
|
||||||
W
|
W
|
||||||
R
|
R
|
||||||
k
|
k
|
||||||
d
|
d
|
||||||
n
|
n
|
||||||
l
|
l
|
||||||
gy_obs
|
gy_obs
|
||||||
gp_obs
|
gp_obs
|
||||||
Y_obs
|
Y_obs
|
||||||
P_obs
|
P_obs
|
||||||
y
|
y
|
||||||
dA ];
|
dA ];
|
|
@ -1,56 +1,56 @@
|
||||||
load test
|
load test
|
||||||
% $$$ Y = Y(1:2,:);
|
% $$$ Y = Y(1:2,:);
|
||||||
% $$$ mf = mf(1:2);
|
% $$$ mf = mf(1:2);
|
||||||
% $$$ H=H(1:2,1:2);
|
% $$$ H=H(1:2,1:2);
|
||||||
% $$$ pp = pp-1;
|
% $$$ pp = pp-1;
|
||||||
% $$$ trend =trend(1:2,:);
|
% $$$ trend =trend(1:2,:);
|
||||||
Pinf1(1,1) = 1;
|
Pinf1(1,1) = 1;
|
||||||
Pstar1(1,1) = 0;
|
Pstar1(1,1) = 0;
|
||||||
Pstar1(4,1) = 0;
|
Pstar1(4,1) = 0;
|
||||||
Pstar1(1,4) = 0;
|
Pstar1(1,4) = 0;
|
||||||
[alphahat1,epsilonhat1,etahat1,a11, aK1] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
|
[alphahat1,epsilonhat1,etahat1,a11, aK1] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
|
||||||
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
||||||
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q,H, ...
|
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q,H, ...
|
||||||
Pinf1,Pstar1,Y,trend, ...
|
Pinf1,Pstar1,Y,trend, ...
|
||||||
pp,mm,smpl,mf);
|
pp,mm,smpl,mf);
|
||||||
max(max(abs(alphahat1-alphahat2)))
|
max(max(abs(alphahat1-alphahat2)))
|
||||||
max(max(abs(epsilonhat1-epsilonhat2)))
|
max(max(abs(epsilonhat1-epsilonhat2)))
|
||||||
max(max(abs(etahat1-etahat2)))
|
max(max(abs(etahat1-etahat2)))
|
||||||
max(max(abs(a11-a12)))
|
max(max(abs(a11-a12)))
|
||||||
max(max(abs(aK1-aK2)))
|
max(max(abs(aK1-aK2)))
|
||||||
|
|
||||||
return
|
return
|
||||||
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
|
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
|
||||||
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
||||||
[alphahat2,etahat2,a12, aK2] = DiffuseKalmanSmoother3(T,R,Q, ...
|
[alphahat2,etahat2,a12, aK2] = DiffuseKalmanSmoother3(T,R,Q, ...
|
||||||
Pinf1,Pstar1,Y,trend, ...
|
Pinf1,Pstar1,Y,trend, ...
|
||||||
pp,mm,smpl,mf);
|
pp,mm,smpl,mf);
|
||||||
|
|
||||||
|
|
||||||
max(max(abs(alphahat1-alphahat2)))
|
max(max(abs(alphahat1-alphahat2)))
|
||||||
max(max(abs(etahat1-etahat2)))
|
max(max(abs(etahat1-etahat2)))
|
||||||
max(max(abs(a11-a12)))
|
max(max(abs(a11-a12)))
|
||||||
%max(max(abs(aK1-aK2)))
|
%max(max(abs(aK1-aK2)))
|
||||||
|
|
||||||
|
|
||||||
H = zeros(size(H));
|
H = zeros(size(H));
|
||||||
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
|
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother1(T,R,Q, ...
|
||||||
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
||||||
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
|
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH1(T,R,Q,H, ...
|
||||||
Pinf1,Pstar1,Y,trend, ...
|
Pinf1,Pstar1,Y,trend, ...
|
||||||
pp,mm,smpl,mf);
|
pp,mm,smpl,mf);
|
||||||
max(max(abs(alphahat1-alphahat2)))
|
max(max(abs(alphahat1-alphahat2)))
|
||||||
max(max(abs(etahat1-etahat2)))
|
max(max(abs(etahat1-etahat2)))
|
||||||
max(max(abs(a11-a12)))
|
max(max(abs(a11-a12)))
|
||||||
%max(max(abs(aK1-aK2)))
|
%max(max(abs(aK1-aK2)))
|
||||||
|
|
||||||
|
|
||||||
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother3(T,R,Q, ...
|
[alphahat1,etahat1,a11, aK1] = DiffuseKalmanSmoother3(T,R,Q, ...
|
||||||
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
||||||
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q, H, ...
|
[alphahat2,epsilonhat2,etahat2,a12, aK2] = DiffuseKalmanSmootherH3(T,R,Q, H, ...
|
||||||
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf);
|
||||||
|
|
||||||
max(max(abs(alphahat1-alphahat2)))
|
max(max(abs(alphahat1-alphahat2)))
|
||||||
max(max(abs(etahat1-etahat2)))
|
max(max(abs(etahat1-etahat2)))
|
||||||
max(max(abs(a11-a12)))
|
max(max(abs(a11-a12)))
|
||||||
%max(max(abs(aK1-aK2)))
|
%max(max(abs(aK1-aK2)))
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
||||||
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
||||||
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
||||||
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
||||||
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
||||||
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
||||||
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
||||||
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
||||||
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
||||||
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
||||||
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
||||||
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
||||||
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
||||||
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
||||||
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
||||||
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
||||||
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
||||||
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
||||||
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
||||||
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
||||||
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
||||||
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
||||||
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
||||||
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
||||||
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
||||||
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
||||||
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
||||||
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
||||||
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
||||||
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
||||||
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
||||||
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
||||||
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
||||||
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
||||||
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
||||||
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
||||||
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
||||||
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
||||||
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
||||||
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
||||||
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
||||||
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
||||||
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
||||||
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
||||||
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
||||||
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
||||||
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
||||||
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
||||||
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
||||||
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
||||||
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
||||||
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
||||||
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
||||||
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
||||||
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
||||||
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
||||||
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
||||||
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
||||||
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
||||||
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
||||||
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
||||||
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
||||||
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
||||||
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
||||||
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
||||||
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
||||||
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
||||||
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
||||||
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
||||||
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
||||||
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
||||||
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
||||||
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
||||||
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
||||||
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
||||||
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
||||||
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
||||||
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
||||||
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
||||||
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
||||||
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
||||||
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
||||||
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
||||||
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
||||||
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
||||||
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
||||||
];
|
];
|
||||||
|
|
||||||
data = reshape(data,5,86)';
|
data = reshape(data,5,86)';
|
||||||
y_obs = data(:,1);
|
y_obs = data(:,1);
|
||||||
pie_obs = data(:,2);
|
pie_obs = data(:,2);
|
||||||
R_obs = data(:,3);
|
R_obs = data(:,3);
|
||||||
de = data(:,4);
|
de = data(:,4);
|
||||||
dq = data(:,5);
|
dq = data(:,5);
|
||||||
|
|
||||||
%Country: Canada
|
%Country: Canada
|
||||||
%Sample Range: 1981:2 to 2002:3
|
%Sample Range: 1981:2 to 2002:3
|
||||||
%Observations: 86
|
%Observations: 86
|
||||||
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
||||||
% Exchange Rate Change [%], Terms of Trade Change [%]
|
% Exchange Rate Change [%], Terms of Trade Change [%]
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
||||||
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
||||||
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
||||||
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
||||||
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
||||||
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
||||||
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
||||||
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
||||||
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
||||||
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
||||||
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
||||||
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
||||||
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
||||||
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
||||||
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
||||||
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
||||||
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
||||||
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
||||||
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
||||||
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
||||||
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
||||||
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
||||||
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
||||||
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
||||||
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
||||||
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
||||||
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
||||||
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
||||||
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
||||||
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
||||||
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
||||||
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
||||||
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
||||||
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
||||||
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
||||||
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
||||||
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
||||||
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
||||||
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
||||||
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
||||||
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
||||||
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
||||||
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
||||||
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
||||||
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
||||||
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
||||||
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
||||||
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
||||||
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
||||||
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
||||||
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
||||||
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
||||||
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
||||||
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
||||||
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
||||||
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
||||||
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
||||||
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
||||||
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
||||||
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
||||||
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
||||||
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
||||||
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
||||||
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
||||||
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
||||||
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
||||||
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
||||||
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
||||||
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
||||||
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
||||||
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
||||||
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
||||||
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
||||||
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
||||||
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
||||||
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
||||||
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
||||||
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
||||||
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
||||||
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
||||||
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
||||||
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
||||||
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
||||||
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
||||||
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
||||||
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
||||||
];
|
];
|
||||||
|
|
||||||
data = reshape(data,5,86)';
|
data = reshape(data,5,86)';
|
||||||
y_obs = data(:,1);
|
y_obs = data(:,1);
|
||||||
pie_obs = data(:,2);
|
pie_obs = data(:,2);
|
||||||
R_obs = data(:,3);
|
R_obs = data(:,3);
|
||||||
de = data(:,4);
|
de = data(:,4);
|
||||||
dq = data(:,5);
|
dq = data(:,5);
|
||||||
|
|
||||||
%Country: Canada
|
%Country: Canada
|
||||||
%Sample Range: 1981:2 to 2002:3
|
%Sample Range: 1981:2 to 2002:3
|
||||||
%Observations: 86
|
%Observations: 86
|
||||||
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
||||||
% Exchange Rate Change [%], Terms of Trade Change [%]
|
% Exchange Rate Change [%], Terms of Trade Change [%]
|
||||||
|
|
|
@ -1,228 +1,228 @@
|
||||||
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol3v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol3v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
||||||
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
||||||
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
||||||
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
||||||
%
|
%
|
||||||
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions
|
% Exporting orthonormal matrices for the deterministic linear restrictions
|
||||||
% (equation by equation) with time-varying A0 and D+** equations.
|
% (equation by equation) with time-varying A0 and D+** equations.
|
||||||
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
||||||
%
|
%
|
||||||
% lags: Maximum length of lag.
|
% lags: Maximum length of lag.
|
||||||
% nvar: Number of endogeous variables.
|
% nvar: Number of endogeous variables.
|
||||||
% nStates: Number of states.
|
% nStates: Number of states.
|
||||||
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
||||||
% 1st column: labels of equations [1:nvar]'.
|
% 1st column: labels of equations [1:nvar]'.
|
||||||
% 2nd column: labels of time-varying features with
|
% 2nd column: labels of time-varying features with
|
||||||
% 1: indxConst -- all coefficients are constant,
|
% 1: indxConst -- all coefficients are constant,
|
||||||
% 2: indxStv -- only shocks are time-varying,
|
% 2: indxStv -- only shocks are time-varying,
|
||||||
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
||||||
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
||||||
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
||||||
% So far this function is written to handle one exogenous variable, which is a constant term.
|
% So far this function is written to handle one exogenous variable, which is a constant term.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
||||||
% within the state and si is the number of free states.
|
% within the state and si is the number of free states.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
||||||
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters within the state and si is the number of free states.
|
% ri is the number of free parameters within the state and si is the number of free states.
|
||||||
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
||||||
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
||||||
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
||||||
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
||||||
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
||||||
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
||||||
%
|
%
|
||||||
% Tao Zha, February 2003
|
% Tao Zha, February 2003
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
||||||
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
||||||
|
|
||||||
if (nargin==3)
|
if (nargin==3)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
n = nvar*nStates;
|
n = nvar*nStates;
|
||||||
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
||||||
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
||||||
|
|
||||||
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
||||||
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
||||||
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
||||||
% 0 means no restriction.
|
% 0 means no restriction.
|
||||||
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
||||||
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
|
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
eqninx = 1;
|
eqninx = 1;
|
||||||
nreseqn = 2; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 2; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 -1 0 0
|
1 0 0 -1 0 0
|
||||||
0 1 0 0 -1 0
|
0 1 0 0 -1 0
|
||||||
0 0 1 0 0 -1
|
0 0 1 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 1 0 0 0 0
|
0 1 0 0 0 0
|
||||||
0 0 1 0 0 0
|
0 0 1 0 0 0
|
||||||
|
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_*.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_*.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
eqninx = 2;
|
eqninx = 2;
|
||||||
nreseqn = 1; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 1; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 -1 0 0
|
1 0 0 -1 0 0
|
||||||
0 1 0 0 -1 0
|
0 1 0 0 -1 0
|
||||||
0 0 1 0 0 -1
|
0 0 1 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 1 0 0 0
|
0 0 1 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
|
|
||||||
%==== For freely time-varying A+ for only the first 6 lags.
|
%==== For freely time-varying A+ for only the first 6 lags.
|
||||||
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
||||||
% nlagsno0 = 6; % Number of lags to be nonzero.
|
% nlagsno0 = 6; % Number of lags to be nonzero.
|
||||||
% for si=1:nStates
|
% for si=1:nStates
|
||||||
% for ki = 1:lags-nlagsno0
|
% for ki = 1:lags-nlagsno0
|
||||||
% for kj=1:nvar
|
% for kj=1:nvar
|
||||||
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
% for si=1:nStates-1
|
% for si=1:nStates-1
|
||||||
% for ki=[2*nvar+1:kvar-1]
|
% for ki=[2*nvar+1:kvar-1]
|
||||||
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The third equation (money demand) ===========
|
%======== The third equation (money demand) ===========
|
||||||
eqninx = 3;
|
eqninx = 3;
|
||||||
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 -1 0 0
|
1 0 0 -1 0 0
|
||||||
0 1 0 0 -1 0
|
0 1 0 0 -1 0
|
||||||
0 0 1 0 0 -1
|
0 0 1 0 0 -1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_*.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_*.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ki=1:nvar % initializing loop for each equation
|
for ki=1:nvar % initializing loop for each equation
|
||||||
Ui{ki} = null(Qi(:,:,ki));
|
Ui{ki} = null(Qi(:,:,ki));
|
||||||
Vi{ki} = null(Ri(:,:,ki));
|
Vi{ki} = null(Ri(:,:,ki));
|
||||||
n0(ki) = size(Ui{ki},2);
|
n0(ki) = size(Ui{ki},2);
|
||||||
np(ki) = size(Vi{ki},2);
|
np(ki) = size(Vi{ki},2);
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,331 +1,331 @@
|
||||||
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol4v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol4v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
||||||
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
||||||
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
||||||
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
||||||
%
|
%
|
||||||
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions
|
% Exporting orthonormal matrices for the deterministic linear restrictions
|
||||||
% (equation by equation) with time-varying A0 and D+** equations.
|
% (equation by equation) with time-varying A0 and D+** equations.
|
||||||
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
||||||
%
|
%
|
||||||
% lags: Maximum length of lag.
|
% lags: Maximum length of lag.
|
||||||
% nvar: Number of endogeous variables.
|
% nvar: Number of endogeous variables.
|
||||||
% nStates: Number of states.
|
% nStates: Number of states.
|
||||||
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
||||||
% 1st column: labels of equations [1:nvar]'.
|
% 1st column: labels of equations [1:nvar]'.
|
||||||
% 2nd column: labels of time-varying features with
|
% 2nd column: labels of time-varying features with
|
||||||
% 1: indxConst -- all coefficients are constant,
|
% 1: indxConst -- all coefficients are constant,
|
||||||
% 2: indxStv -- only shocks are time-varying,
|
% 2: indxStv -- only shocks are time-varying,
|
||||||
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
||||||
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
||||||
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
||||||
% So far this function is written to handle one exogenous variable, which is a constant term.
|
% So far this function is written to handle one exogenous variable, which is a constant term.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
||||||
% within the state and si is the number of free states.
|
% within the state and si is the number of free states.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
||||||
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters within the state and si is the number of free states.
|
% ri is the number of free parameters within the state and si is the number of free states.
|
||||||
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
||||||
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
||||||
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
||||||
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
||||||
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
||||||
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
||||||
%
|
%
|
||||||
% Tao Zha, February 2003
|
% Tao Zha, February 2003
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
||||||
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
||||||
|
|
||||||
if (nargin==3)
|
if (nargin==3)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
n = nvar*nStates;
|
n = nvar*nStates;
|
||||||
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
||||||
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
||||||
|
|
||||||
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
||||||
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
||||||
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
||||||
% 0 means no restriction.
|
% 0 means no restriction.
|
||||||
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
||||||
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
|
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
eqninx = 1;
|
eqninx = 1;
|
||||||
nreseqn = 3; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 3; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 -1 0 0 0
|
1 0 0 0 -1 0 0 0
|
||||||
0 1 0 0 0 -1 0 0
|
0 1 0 0 0 -1 0 0
|
||||||
0 0 1 0 0 0 -1 0
|
0 0 1 0 0 0 -1 0
|
||||||
0 0 0 1 0 0 0 -1
|
0 0 0 1 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 1 0 0
|
0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 1 0 0 0 0 0 0
|
0 1 0 0 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0
|
0 0 1 0 0 0 0 0
|
||||||
0 0 0 1 0 0 0 0
|
0 0 0 1 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 1 0 0
|
0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
eqninx = 2;
|
eqninx = 2;
|
||||||
nreseqn = 2; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 2; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 -1 0 0 0
|
1 0 0 0 -1 0 0 0
|
||||||
0 1 0 0 0 -1 0 0
|
0 1 0 0 0 -1 0 0
|
||||||
0 0 1 0 0 0 -1 0
|
0 0 1 0 0 0 -1 0
|
||||||
0 0 0 1 0 0 0 -1
|
0 0 0 1 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 1 0 0 0 0 0
|
0 0 1 0 0 0 0 0
|
||||||
0 0 0 1 0 0 0 0
|
0 0 0 1 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
|
|
||||||
%==== For freely time-varying A+ for only the first 6 lags.
|
%==== For freely time-varying A+ for only the first 6 lags.
|
||||||
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
||||||
% nlagsno0 = 6; % Number of lags to be nonzero.
|
% nlagsno0 = 6; % Number of lags to be nonzero.
|
||||||
% for si=1:nStates
|
% for si=1:nStates
|
||||||
% for ki = 1:lags-nlagsno0
|
% for ki = 1:lags-nlagsno0
|
||||||
% for kj=1:nvar
|
% for kj=1:nvar
|
||||||
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
% for si=1:nStates-1
|
% for si=1:nStates-1
|
||||||
% for ki=[2*nvar+1:kvar-1]
|
% for ki=[2*nvar+1:kvar-1]
|
||||||
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
eqninx = 3;
|
eqninx = 3;
|
||||||
nreseqn = 1; % Number of linear restrictions for the equation for each state.
|
nreseqn = 1; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 -1 0 0 0
|
1 0 0 0 -1 0 0 0
|
||||||
0 1 0 0 0 -1 0 0
|
0 1 0 0 0 -1 0 0
|
||||||
0 0 1 0 0 0 -1 0
|
0 0 1 0 0 0 -1 0
|
||||||
0 0 0 1 0 0 0 -1
|
0 0 0 1 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 0 1 0 0 0 0
|
0 0 0 1 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
eqninx = 4;
|
eqninx = 4;
|
||||||
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 -1 0 0 0
|
1 0 0 0 -1 0 0 0
|
||||||
0 1 0 0 0 -1 0 0
|
0 1 0 0 0 -1 0 0
|
||||||
0 0 1 0 0 0 -1 0
|
0 0 1 0 0 0 -1 0
|
||||||
0 0 0 1 0 0 0 -1
|
0 0 0 1 0 0 0 -1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ki=1:nvar % initializing loop for each equation
|
for ki=1:nvar % initializing loop for each equation
|
||||||
Ui{ki} = null(Qi(:,:,ki));
|
Ui{ki} = null(Qi(:,:,ki));
|
||||||
Vi{ki} = null(Ri(:,:,ki));
|
Vi{ki} = null(Ri(:,:,ki));
|
||||||
n0(ki) = size(Ui{ki},2);
|
n0(ki) = size(Ui{ki},2);
|
||||||
np(ki) = size(Vi{ki},2);
|
np(ki) = size(Vi{ki},2);
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,455 +1,455 @@
|
||||||
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol6v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
function [Ui,Vi,n0,np] = ftd_2s_caseall_upperchol6v(lags,nvar,nStates,indxEqnTv_m,nexo)
|
||||||
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
% Case 2&3: Policy a0j and a+j have only time-varying structural variances -- Case 2.
|
||||||
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
% All policy and nonpolicy a0j's and the corresponding constant terms are completely time-varying and only the scale
|
||||||
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
% of each variable in d+j,1** (excluding the constant term) is time-varying -- Case 3.
|
||||||
%
|
%
|
||||||
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
% Variables: Pcom, M2, FFR, y, P, U. Equations: information, policy, money demand, y, P, U.
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions
|
% Exporting orthonormal matrices for the deterministic linear restrictions
|
||||||
% (equation by equation) with time-varying A0 and D+** equations.
|
% (equation by equation) with time-varying A0 and D+** equations.
|
||||||
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
% See Model II.3 on pp.71k-71r in TVBVAR NOTES (and Waggoner and Zha's Gibbs sampling paper and TVBVAR NOTES p.58).
|
||||||
%
|
%
|
||||||
% lags: Maximum length of lag.
|
% lags: Maximum length of lag.
|
||||||
% nvar: Number of endogeous variables.
|
% nvar: Number of endogeous variables.
|
||||||
% nStates: Number of states.
|
% nStates: Number of states.
|
||||||
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
% indxEqnTv_m: nvar-by-2. Stores equation characteristics.
|
||||||
% 1st column: labels of equations [1:nvar]'.
|
% 1st column: labels of equations [1:nvar]'.
|
||||||
% 2nd column: labels of time-varying features with
|
% 2nd column: labels of time-varying features with
|
||||||
% 1: indxConst -- all coefficients are constant,
|
% 1: indxConst -- all coefficients are constant,
|
||||||
% 2: indxStv -- only shocks are time-varying,
|
% 2: indxStv -- only shocks are time-varying,
|
||||||
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
% 3: indxTva0pv -- a0 are freely time-varying and each variable i for d+ is time-varying only by the scale lambda_i(s_t).
|
||||||
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
% 4: indxTva0ps -- a0 are freely time-varying and only the scale for the whole of d+ is time-varying.
|
||||||
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
% 5: indxTv -- time-varying for all coeffficients (a0 and a+) where the lag length for a+ may be shorter.
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant.
|
||||||
% So far this function is written to handle one exogenous variable, which is a constant term.
|
% So far this function is written to handle one exogenous variable, which is a constant term.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar*nStates-by-qi*si orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
% equation contemporaneous restriction matrix where qi is the number of free parameters
|
||||||
% within the state and si is the number of free states.
|
% within the state and si is the number of free states.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
% parameter left for the ith equation in the order of [a_i for 1st state, ..., a_i for last state].
|
||||||
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k*nStates-by-ri*si orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters within the state and si is the number of free states.
|
% ri is the number of free parameters within the state and si is the number of free states.
|
||||||
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
% With this transformation, we have fi = Vi*gi or Vi'*fi = gi where fi is a vector of total original
|
||||||
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
% parameters and gi is a vector of free parameters. The ith equation is in the order of [nvar variables
|
||||||
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
% for 1st lag and 1st state, ..., nvar variables for last lag and 1st state, const for 1st state, nvar
|
||||||
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
% variables for 1st lag and 2nd state, nvar variables for last lag and 2nd state, const for 2nd state, and so on].
|
||||||
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
% n0: nvar-by-1, whose ith element represents the number of free A0 parameters in ith equation in *all states*.
|
||||||
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
% np: nvar-by-1, whose ith element represents the number of free D+ parameters in ith equation in *all states*.
|
||||||
%
|
%
|
||||||
% Tao Zha, February 2003
|
% Tao Zha, February 2003
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation in all states.
|
||||||
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
np = zeros(nvar,1); % ith element represents the number of free D+ parameters in ith equation in all states.
|
||||||
|
|
||||||
if (nargin==3)
|
if (nargin==3)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
n = nvar*nStates;
|
n = nvar*nStates;
|
||||||
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
kvar=lags*nvar+nexo; % Maximum number of lagged and exogenous variables in each equation under each state.
|
||||||
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
k = kvar*nStates; % Maximum number of lagged and exogenous variables in each equation in all states.
|
||||||
|
|
||||||
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
Qi = zeros(n,n,nvar); % 3rd dim: nvar contemporaneous equations.
|
||||||
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
Ri = zeros(k,k,nvar); % 1st and 2nd dims: lagged and exogenous equations.
|
||||||
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
% Row corresponds to equation with nvar variables for state 1, ..., nvar variables for state nState.
|
||||||
% 0 means no restriction.
|
% 0 means no restriction.
|
||||||
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
% 1 and -1 or any other number means the linear combination of the corresponding parameters is restricted to 0.
|
||||||
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
% 1 (only 1) means that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
% Beginning the manual input of the restrictions one quation at a time for A0_s.
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
|
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
eqninx = 1;
|
eqninx = 1;
|
||||||
nreseqn = 5; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 5; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 1 0 0 0 0
|
0 0 0 0 0 0 0 1 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 1 0 0 0
|
0 0 0 0 0 0 0 0 1 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 1 0 0 0 0 0 0 0 0 0 0
|
0 1 0 0 0 0 0 0 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 0 0 0 0
|
0 0 1 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 0 0 0
|
0 0 0 1 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 0 0
|
0 0 0 0 1 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 0
|
0 0 0 0 0 1 0 0 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 1 0 0 0 0
|
0 0 0 0 0 0 0 1 0 0 0 0
|
||||||
0 0 0 0 0 0 0 0 1 0 0 0
|
0 0 0 0 0 0 0 0 1 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
eqninx = 2;
|
eqninx = 2;
|
||||||
nreseqn = 4; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 4; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 1 0 0 0
|
0 0 0 0 0 0 0 0 1 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 1 0 0 0 0 0 0 0 0 0
|
0 0 1 0 0 0 0 0 0 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 0 0 0
|
0 0 0 1 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 0 0
|
0 0 0 0 1 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 0
|
0 0 0 0 0 1 0 0 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 1 0 0 0
|
0 0 0 0 0 0 0 0 1 0 0 0
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
eqninx = 3;
|
eqninx = 3;
|
||||||
nreseqn = 3; % Number of linear restrictions for A0(:,eqninx) for each state.
|
nreseqn = 3; % Number of linear restrictions for A0(:,eqninx) for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 0 1 0 0 0 0 0 0 0 0
|
0 0 0 1 0 0 0 0 0 0 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 0 0
|
0 0 0 0 1 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 0
|
0 0 0 0 0 1 0 0 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 1 0 0
|
0 0 0 0 0 0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_3s_case3a.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
|
|
||||||
%==== For freely time-varying A+ for only the first 6 lags.
|
%==== For freely time-varying A+ for only the first 6 lags.
|
||||||
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
%==== Lagged restrictions: zeros on all lags except the first 6 lags in the MS equation.
|
||||||
% nlagsno0 = 6; % Number of lags to be nonzero.
|
% nlagsno0 = 6; % Number of lags to be nonzero.
|
||||||
% for si=1:nStates
|
% for si=1:nStates
|
||||||
% for ki = 1:lags-nlagsno0
|
% for ki = 1:lags-nlagsno0
|
||||||
% for kj=1:nvar
|
% for kj=1:nvar
|
||||||
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
% Ri(kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,kvar*(si-1)+nlagsno0*nvar+nvar*(ki-1)+kj,2) = 1;
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s except the first two lags and the constant term. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
% for si=1:nStates-1
|
% for si=1:nStates-1
|
||||||
% for ki=[2*nvar+1:kvar-1]
|
% for ki=[2*nvar+1:kvar-1]
|
||||||
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
% Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
eqninx = 4;
|
eqninx = 4;
|
||||||
nreseqn = 2; % Number of linear restrictions for the equation for each state.
|
nreseqn = 2; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 0 0 1 0 0 0 0 0 0 0
|
0 0 0 0 1 0 0 0 0 0 0 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 0
|
0 0 0 0 0 1 0 0 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 0 1 0
|
0 0 0 0 0 0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The fifth equation ===========
|
%======== The fifth equation ===========
|
||||||
eqninx = 5;
|
eqninx = 5;
|
||||||
nreseqn = 1; % Number of linear restrictions for the equation for each state.
|
nreseqn = 1; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For time-varying A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:nreseqn*nStates,:,eqninx) = [
|
Qi(1:nreseqn*nStates,:,eqninx) = [
|
||||||
0 0 0 0 0 1 0 0 0 0 0 0
|
0 0 0 0 0 1 0 0 0 0 0 0
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0 0 0 0 1
|
0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%======== The sixth equation ===========
|
%======== The sixth equation ===========
|
||||||
eqninx = 6;
|
eqninx = 6;
|
||||||
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
nreseqn = 0; % Number of linear restrictions for the equation for each state.
|
||||||
if (indxEqnTv_m(eqninx, 2)<=2)
|
if (indxEqnTv_m(eqninx, 2)<=2)
|
||||||
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
%**** For constant A0_s. In the order of [a0j(1),...,a0j(nStates)] for the 2nd dim of Qi.
|
||||||
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
Qi(1:(nStates-1)*nvar+nreseqn,:,eqninx) = [
|
||||||
1 0 0 0 0 0 -1 0 0 0 0 0
|
1 0 0 0 0 0 -1 0 0 0 0 0
|
||||||
0 1 0 0 0 0 0 -1 0 0 0 0
|
0 1 0 0 0 0 0 -1 0 0 0 0
|
||||||
0 0 1 0 0 0 0 0 -1 0 0 0
|
0 0 1 0 0 0 0 0 -1 0 0 0
|
||||||
0 0 0 1 0 0 0 0 0 -1 0 0
|
0 0 0 1 0 0 0 0 0 -1 0 0
|
||||||
0 0 0 0 1 0 0 0 0 0 -1 0
|
0 0 0 0 1 0 0 0 0 0 -1 0
|
||||||
0 0 0 0 0 1 0 0 0 0 0 -1
|
0 0 0 0 0 1 0 0 0 0 0 -1
|
||||||
];
|
];
|
||||||
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For constant D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
else % Time-varying equations at least for A0_s. For D+_s, constant-parameter equations in general.
|
||||||
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
%**** For D+_s. In the order of [aj+(1),...,aj+(nStates)] for the 2nd dim of Ri.
|
||||||
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
if (indxEqnTv_m(eqninx, 2)==3) % For constant D+** except the constant term. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
for ki=1:kvar-1 % -1: no restrictions on the constant term, which is freely time-varying.
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
elseif (indxEqnTv_m(eqninx, 2)==4) % For constant D+**. In the order of [dj**(1),...,dj**(nStates)] for the 2nd dim of Ri.
|
||||||
for si=1:nStates-1
|
for si=1:nStates-1
|
||||||
for ki=1:kvar
|
for ki=1:kvar
|
||||||
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
Ri(kvar*(si-1)+ki,[kvar*(si-1)+ki si*kvar+ki],eqninx) = [1 -1];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
error('.../ftd_2s_caseall_simszha5v.m: Have not got time to deal with the simple case indxEqnTv_m(eqninx, 2)=5.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ki=1:nvar % initializing loop for each equation
|
for ki=1:nvar % initializing loop for each equation
|
||||||
Ui{ki} = null(Qi(:,:,ki));
|
Ui{ki} = null(Qi(:,:,ki));
|
||||||
Vi{ki} = null(Ri(:,:,ki));
|
Vi{ki} = null(Ri(:,:,ki));
|
||||||
n0(ki) = size(Ui{ki},2);
|
n0(ki) = size(Ui{ki},2);
|
||||||
np(ki) = size(Vi{ki},2);
|
np(ki) = size(Vi{ki},2);
|
||||||
end
|
end
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,188 +1,188 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_reac_function_4v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_reac_function_4v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [ff+ch fh dpgdp ffr)
|
% vlist = [ff+ch fh dpgdp ffr)
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% HERE FIRTS 3 EQUATIONS ARE AR2 AND THE LAST EQUATION IS AN UNRESTRICTED
|
% HERE FIRTS 3 EQUATIONS ARE AR2 AND THE LAST EQUATION IS AN UNRESTRICTED
|
||||||
% REACTION FUNCTION 2 lags
|
% REACTION FUNCTION 2 lags
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
% BN
|
% BN
|
||||||
|
|
||||||
nvar=4;
|
nvar=4;
|
||||||
lags=4;
|
lags=4;
|
||||||
nexo=1;
|
nexo=1;
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:3,:,1) = [
|
Qi(1:3,:,1) = [
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:2,:,2) = [
|
Qi(1:2,:,2) = [
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation =========== NOTE THAT WE FORBID A
|
%======== The third equation =========== NOTE THAT WE FORBID A
|
||||||
%CONTEMPORANEOUS IMPACT OF OUTPUTON PRICES TO AVOID A CONSTRAINT THAT
|
%CONTEMPORANEOUS IMPACT OF OUTPUTON PRICES TO AVOID A CONSTRAINT THAT
|
||||||
%INVOLVE A0 and Aplus
|
%INVOLVE A0 and Aplus
|
||||||
Qi(1:3,:,3) = [
|
Qi(1:3,:,3) = [
|
||||||
1 0 0 0
|
1 0 0 0
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
|
|
||||||
|
|
||||||
% Restrictions on the A+ in order to focus strictly on the reaction fucntion
|
% Restrictions on the A+ in order to focus strictly on the reaction fucntion
|
||||||
|
|
||||||
% indicates free parameterers X i
|
% indicates free parameterers X i
|
||||||
% Ap = [
|
% Ap = [
|
||||||
% X X X X
|
% X X X X
|
||||||
% X X X X
|
% X X X X
|
||||||
% -a1 -b1 X X
|
% -a1 -b1 X X
|
||||||
% a1 b1 0 X (1st lag)
|
% a1 b1 0 X (1st lag)
|
||||||
% X X X X
|
% X X X X
|
||||||
% X X X X
|
% X X X X
|
||||||
% -a2 -b2 X X
|
% -a2 -b2 X X
|
||||||
% b2 b2 0 X (2nd lag)
|
% b2 b2 0 X (2nd lag)
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% X X X X
|
% X X X X
|
||||||
% -a3 -b3 X X
|
% -a3 -b3 X X
|
||||||
% a3 a3 0 X (3rd lag)
|
% a3 a3 0 X (3rd lag)
|
||||||
% X X X X
|
% X X X X
|
||||||
% X X X X
|
% X X X X
|
||||||
% -a4 -b4 X X
|
% -a4 -b4 X X
|
||||||
% a4 b4 0 X (4th lag)
|
% a4 b4 0 X (4th lag)
|
||||||
% X X X X (constant terms)
|
% X X X X (constant terms)
|
||||||
% ];
|
% ];
|
||||||
|
|
||||||
k=nvar*lags+nexo;
|
k=nvar*lags+nexo;
|
||||||
Ri = zeros(k,k,nvar);
|
Ri = zeros(k,k,nvar);
|
||||||
% constraints on IS curve /conso+corporate investment
|
% constraints on IS curve /conso+corporate investment
|
||||||
for nv=1:2
|
for nv=1:2
|
||||||
for ll=1:lags
|
for ll=1:lags
|
||||||
Ri(ll,3+lags*(ll-1),nv)=1;
|
Ri(ll,3+lags*(ll-1),nv)=1;
|
||||||
Ri(ll,4+lags*(ll-1),nv)=1;
|
Ri(ll,4+lags*(ll-1),nv)=1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% constraints on IS curve /conso+corporate investment only on the long run
|
% constraints on IS curve /conso+corporate investment only on the long run
|
||||||
% impact
|
% impact
|
||||||
% for nv=1:2
|
% for nv=1:2
|
||||||
% for ll=1:lags
|
% for ll=1:lags
|
||||||
% Ri(1,3+lags*(ll-1),nv)=1;
|
% Ri(1,3+lags*(ll-1),nv)=1;
|
||||||
% Ri(1,4+lags*(ll-1),nv)=1;
|
% Ri(1,4+lags*(ll-1),nv)=1;
|
||||||
% end
|
% end
|
||||||
% end
|
% end
|
||||||
|
|
||||||
|
|
||||||
% constraints on Ph curve / inflation does not react to interest rates
|
% constraints on Ph curve / inflation does not react to interest rates
|
||||||
for ll=1:lags
|
for ll=1:lags
|
||||||
Ri(ll,4+lags*(ll-1),3)=1;
|
Ri(ll,4+lags*(ll-1),3)=1;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,251 +1,251 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_cholesky(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_cholesky(lags,nvar,nexo,indxC0Pres)
|
||||||
%vlist = [1:4]; % regarding "xdd", % 1: p; 2: id; 3: ik; 4: y.
|
%vlist = [1:4]; % regarding "xdd", % 1: p; 2: id; 3: ik; 4: y.
|
||||||
%For restricted VARs in the form: y_t'*A0 = x_t'*Ap + e_t', where y_t is a vector of endogenous variables
|
%For restricted VARs in the form: y_t'*A0 = x_t'*Ap + e_t', where y_t is a vector of endogenous variables
|
||||||
% and x_t is a vector of lagged endogenous variables and the constant term (last term).
|
% and x_t is a vector of lagged endogenous variables and the constant term (last term).
|
||||||
% Note that the columns of A0 and Ap correspnd to equations.
|
% Note that the columns of A0 and Ap correspnd to equations.
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%The restrictions considered here are in the following form where X means unrestricted:
|
%The restrictions considered here are in the following form where X means unrestricted:
|
||||||
% A0 = [
|
% A0 = [
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% 0 X X X
|
% 0 X X X
|
||||||
% 0 0 X X
|
% 0 0 X X
|
||||||
% 0 0 0 X
|
% 0 0 0 X
|
||||||
% ];
|
% ];
|
||||||
% Ap = [
|
% Ap = [
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% 0 X X X
|
% 0 X X X
|
||||||
% 0 0 X X
|
% 0 0 X X
|
||||||
% 0 0 X X (1st lag)
|
% 0 0 X X (1st lag)
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% 0 X X X
|
% 0 X X X
|
||||||
% 0 0 X X
|
% 0 0 X X
|
||||||
% 0 0 X X (2nd lag)
|
% 0 0 X X (2nd lag)
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% 0 X X X
|
% 0 X X X
|
||||||
% 0 0 X X
|
% 0 0 X X
|
||||||
% 0 0 X X (3rd lag)
|
% 0 0 X X (3rd lag)
|
||||||
% X 0 X X
|
% X 0 X X
|
||||||
% 0 X X X
|
% 0 X X X
|
||||||
% 0 0 X X
|
% 0 0 X X
|
||||||
% 0 0 X X (4th lag)
|
% 0 0 X X (4th lag)
|
||||||
% 0 X 0 0 (constant terms)
|
% 0 X 0 0 (constant terms)
|
||||||
% ];
|
% ];
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
%------------------------ Lower triangular A0 ------------------------------
|
%------------------------ Lower triangular A0 ------------------------------
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
|
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:1,:,2) = [
|
Qi(1:1,:,2) = [
|
||||||
1 0 0 0
|
1 0 0 0
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:2,:,3) = [
|
Qi(1:2,:,3) = [
|
||||||
1 0 0 0
|
1 0 0 0
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
Qi(1:3,:,4) = [
|
Qi(1:3,:,4) = [
|
||||||
1 0 0 0
|
1 0 0 0
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
];
|
];
|
||||||
else
|
else
|
||||||
%------------------------ Upper triangular A0 ------------------------------
|
%------------------------ Upper triangular A0 ------------------------------
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(2:4,:,1) = [
|
Qi(2:4,:,1) = [
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi([1 3:4],:,2) = [
|
Qi([1 3:4],:,2) = [
|
||||||
1 0 0 0
|
1 0 0 0
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(4:4,:,3) = [
|
Qi(4:4,:,3) = [
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
%-------------------------- Lag restrictions. ------------------------------------------
|
%-------------------------- Lag restrictions. ------------------------------------------
|
||||||
if (1)
|
if (1)
|
||||||
%--- Lag restrictions.
|
%--- Lag restrictions.
|
||||||
indxeqn = 1; %Which equation.
|
indxeqn = 1; %Which equation.
|
||||||
nrestrs = (nvar-1)*lags+1; %Number of restrictions.
|
nrestrs = (nvar-1)*lags+1; %Number of restrictions.
|
||||||
vars_restr = [2:nvar]; %Variables that are restricted: id, ik, and y.
|
vars_restr = [2:nvar]; %Variables that are restricted: id, ik, and y.
|
||||||
blags = zeros(nrestrs,k); %k=nvar*lags+1
|
blags = zeros(nrestrs,k); %k=nvar*lags+1
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
for ki = 1:lags
|
for ki = 1:lags
|
||||||
for kj=vars_restr
|
for kj=vars_restr
|
||||||
cnt = cnt+1;
|
cnt = cnt+1;
|
||||||
blags(cnt,nvar*(ki-1)+kj) = 1;
|
blags(cnt,nvar*(ki-1)+kj) = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%--- Keep constant zero.
|
%--- Keep constant zero.
|
||||||
cnt = cnt+1;
|
cnt = cnt+1;
|
||||||
blags(cnt,end) = 1; %Constant = 0.
|
blags(cnt,end) = 1; %Constant = 0.
|
||||||
if cnt~=nrestrs
|
if cnt~=nrestrs
|
||||||
error('Check lagged restrictions in 1st equation!')
|
error('Check lagged restrictions in 1st equation!')
|
||||||
end
|
end
|
||||||
Ri(1:nrestrs,:,indxeqn) = blags;
|
Ri(1:nrestrs,:,indxeqn) = blags;
|
||||||
|
|
||||||
%--- Lag restrictions.
|
%--- Lag restrictions.
|
||||||
indxeqn = 2; %Which equation.
|
indxeqn = 2; %Which equation.
|
||||||
nrestrs = (nvar-1)*lags; %Number of restrictions.
|
nrestrs = (nvar-1)*lags; %Number of restrictions.
|
||||||
vars_restr = [1 3:nvar]; %Variables that are restricted: id, ik, and y.
|
vars_restr = [1 3:nvar]; %Variables that are restricted: id, ik, and y.
|
||||||
blags = zeros(nrestrs,k); %k=nvar*lags+1
|
blags = zeros(nrestrs,k); %k=nvar*lags+1
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
for ki = 1:lags
|
for ki = 1:lags
|
||||||
for kj=vars_restr
|
for kj=vars_restr
|
||||||
cnt = cnt+1;
|
cnt = cnt+1;
|
||||||
blags(cnt,nvar*(ki-1)+kj) = 1;
|
blags(cnt,nvar*(ki-1)+kj) = 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Ri(1:nrestrs,:,indxeqn) = blags;
|
Ri(1:nrestrs,:,indxeqn) = blags;
|
||||||
|
|
||||||
%--- Lag restrictions.
|
%--- Lag restrictions.
|
||||||
indxeqn = 3; %Which equation.
|
indxeqn = 3; %Which equation.
|
||||||
nrestrs = 1; %Number of restrictions.
|
nrestrs = 1; %Number of restrictions.
|
||||||
blags = zeros(nrestrs,k);
|
blags = zeros(nrestrs,k);
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
%--- Keep constant zero.
|
%--- Keep constant zero.
|
||||||
cnt = cnt+1;
|
cnt = cnt+1;
|
||||||
blags(cnt,end) = 1; %Constant = 0.
|
blags(cnt,end) = 1; %Constant = 0.
|
||||||
if cnt~=nrestrs
|
if cnt~=nrestrs
|
||||||
error('Check lagged restrictions in 1st equation!')
|
error('Check lagged restrictions in 1st equation!')
|
||||||
end
|
end
|
||||||
Ri(1:nrestrs,:,indxeqn) = blags;
|
Ri(1:nrestrs,:,indxeqn) = blags;
|
||||||
|
|
||||||
%--- Lag restrictions.
|
%--- Lag restrictions.
|
||||||
indxeqn = 4; %Which equation.
|
indxeqn = 4; %Which equation.
|
||||||
nrestrs = 1; %Number of restrictions.
|
nrestrs = 1; %Number of restrictions.
|
||||||
blags = zeros(nrestrs,k);
|
blags = zeros(nrestrs,k);
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
%--- Keep constant zero.
|
%--- Keep constant zero.
|
||||||
cnt = cnt+1;
|
cnt = cnt+1;
|
||||||
blags(cnt,end) = 1; %Constant = 0.
|
blags(cnt,end) = 1; %Constant = 0.
|
||||||
if cnt~=nrestrs
|
if cnt~=nrestrs
|
||||||
error('Check lagged restrictions in 1st equation!')
|
error('Check lagged restrictions in 1st equation!')
|
||||||
end
|
end
|
||||||
Ri(1:nrestrs,:,indxeqn) = blags;
|
Ri(1:nrestrs,:,indxeqn) = blags;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
% This type of restriction is used for the New-Keysian model studied by Leeper and Zha
|
% This type of restriction is used for the New-Keysian model studied by Leeper and Zha
|
||||||
% "Assessing Simple Policy Rules: A View from a Complete Macroeconomic Model" published
|
% "Assessing Simple Policy Rules: A View from a Complete Macroeconomic Model" published
|
||||||
% by St. Louis Fed Review.
|
% by St. Louis Fed Review.
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,192 +1,192 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol5v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol5v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
||||||
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:4,:,1) = [
|
Qi(1:4,:,1) = [
|
||||||
0 1 0 0 0
|
0 1 0 0 0
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:3,:,2) = [
|
Qi(1:3,:,2) = [
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:2,:,3) = [
|
Qi(1:2,:,3) = [
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
%Qi(1:1,:,4) = [
|
%Qi(1:1,:,4) = [
|
||||||
% 0 0 0 0 1
|
% 0 0 0 0 1
|
||||||
% ];
|
% ];
|
||||||
|
|
||||||
|
|
||||||
%======== The fifth equation ===========
|
%======== The fifth equation ===========
|
||||||
|
|
||||||
Qi(1:3,:,5) = [
|
Qi(1:3,:,5) = [
|
||||||
1 0 0 0 0
|
1 0 0 0 0
|
||||||
0 1 0 0 0
|
0 1 0 0 0
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,190 +1,190 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_simszha5v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_simszha5v(lags,nvar,nexo,indxC0Pres)
|
||||||
%vlist = [21 141 93 127 124]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
%vlist = [21 141 93 127 124]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
||||||
%varlist={'Ex', 'M3', 'R', 'y','P'};
|
%varlist={'Ex', 'M3', 'R', 'y','P'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
|
|
||||||
%======== The first equation: information sector ===========
|
%======== The first equation: information sector ===========
|
||||||
|
|
||||||
|
|
||||||
%======== The second equation: monetary policy ===========
|
%======== The second equation: monetary policy ===========
|
||||||
%Qi(1:2,:,2) = [
|
%Qi(1:2,:,2) = [
|
||||||
% 0 0 0 1 0
|
% 0 0 0 1 0
|
||||||
% 0 0 0 0 1
|
% 0 0 0 0 1
|
||||||
% ]; % Respond to Pcom.
|
% ]; % Respond to Pcom.
|
||||||
Qi(1:3,:,2) = [
|
Qi(1:3,:,2) = [
|
||||||
1 0 0 0 0
|
1 0 0 0 0
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
]; % Not respond to Pcom.
|
]; % Not respond to Pcom.
|
||||||
|
|
||||||
%======== The third equation: money demand ===========
|
%======== The third equation: money demand ===========
|
||||||
Qi(1,:,3) = [
|
Qi(1,:,3) = [
|
||||||
1 0 0 0 0
|
1 0 0 0 0
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fourth equation: y equation ===========
|
%======== The fourth equation: y equation ===========
|
||||||
Qi(1:4,:,4) = [
|
Qi(1:4,:,4) = [
|
||||||
1 0 0 0 0
|
1 0 0 0 0
|
||||||
0 1 0 0 0
|
0 1 0 0 0
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fifth equation: p equation ===========
|
%======== The fifth equation: p equation ===========
|
||||||
Qi(1:3,:,5) = [
|
Qi(1:3,:,5) = [
|
||||||
1 0 0 0 0
|
1 0 0 0 0
|
||||||
0 1 0 0 0
|
0 1 0 0 0
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,170 +1,170 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol3v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol3v(lags,nvar,nexo,indxC0Pres)
|
||||||
%vlist = [20 6 3 44 1 10]; % regarding "xdd", Pcom (Poil or imfcom), M2, FFR, GDP, CPI (or PCE), and U.
|
%vlist = [20 6 3 44 1 10]; % regarding "xdd", Pcom (Poil or imfcom), M2, FFR, GDP, CPI (or PCE), and U.
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
|
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:2,:,1) = [
|
Qi(1:2,:,1) = [
|
||||||
0 1 0
|
0 1 0
|
||||||
0 0 1
|
0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:1,:,2) = [
|
Qi(1:1,:,2) = [
|
||||||
0 0 1
|
0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,178 +1,178 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol4v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol4v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
||||||
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:3,:,1) = [
|
Qi(1:3,:,1) = [
|
||||||
0 1 0 0
|
0 1 0 0
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:2,:,2) = [
|
Qi(1:2,:,2) = [
|
||||||
0 0 1 0
|
0 0 1 0
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:1,:,3) = [
|
Qi(1:1,:,3) = [
|
||||||
0 0 0 1
|
0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,187 +1,187 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol5v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol5v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
% vlist = [127 124 93 141 21]; % 1: GDP; 2: GDP deflator 124 (consumption deflator 79); 3: R; 4: M3 141 (M2 140); 5: exchange rate 21.
|
||||||
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
% varlist={'y', 'P', 'R', 'M3', 'Ex'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:4,:,1) = [
|
Qi(1:4,:,1) = [
|
||||||
0 1 0 0 0
|
0 1 0 0 0
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:3,:,2) = [
|
Qi(1:3,:,2) = [
|
||||||
0 0 1 0 0
|
0 0 1 0 0
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:2,:,3) = [
|
Qi(1:2,:,3) = [
|
||||||
0 0 0 1 0
|
0 0 0 1 0
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
Qi(1:1,:,4) = [
|
Qi(1:1,:,4) = [
|
||||||
0 0 0 0 1
|
0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fifth equation ===========
|
%======== The fifth equation ===========
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,194 +1,194 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol6v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol6v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [127 124 2 93 141 21]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
% vlist = [127 124 2 93 141 21]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
||||||
% varlist={'y', 'P', 'Pcom', 'R', 'M3', 'Ex'};
|
% varlist={'y', 'P', 'Pcom', 'R', 'M3', 'Ex'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:5,:,1) = [
|
Qi(1:5,:,1) = [
|
||||||
0 1 0 0 0 0
|
0 1 0 0 0 0
|
||||||
0 0 1 0 0 0
|
0 0 1 0 0 0
|
||||||
0 0 0 1 0 0
|
0 0 0 1 0 0
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:4,:,2) = [
|
Qi(1:4,:,2) = [
|
||||||
0 0 1 0 0 0
|
0 0 1 0 0 0
|
||||||
0 0 0 1 0 0
|
0 0 0 1 0 0
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:3,:,3) = [
|
Qi(1:3,:,3) = [
|
||||||
0 0 0 1 0 0
|
0 0 0 1 0 0
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
Qi(1:2,:,4) = [
|
Qi(1:2,:,4) = [
|
||||||
0 0 0 0 1 0
|
0 0 0 0 1 0
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fifth equation ===========
|
%======== The fifth equation ===========
|
||||||
Qi(1:1,:,5) = [
|
Qi(1:1,:,5) = [
|
||||||
0 0 0 0 0 1
|
0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The sixth equation ===========
|
%======== The sixth equation ===========
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,204 +1,204 @@
|
||||||
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol7v(lags,nvar,nexo,indxC0Pres)
|
function [Ui,Vi,n0,np,ixmC0Pres] = ftd_upperchol7v(lags,nvar,nexo,indxC0Pres)
|
||||||
% vlist = [127 124 2 93 141 21]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
% vlist = [127 124 2 93 141 21]; % 1: Pcom 2 (exchange rate 21); 2: M3 141 (M2 140); 3: R; 4: GDP; 5: GDP deflator 124 (consumption deflator 79).
|
||||||
% varlist={'y', 'P', 'Pcom', 'R', 'M3', 'Ex'};
|
% varlist={'y', 'P', 'Pcom', 'R', 'M3', 'Ex'};
|
||||||
%
|
%
|
||||||
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
% Exporting orthonormal matrices for the deterministic linear restrictions (equation by equation)
|
||||||
% See Waggoner and Zha's Gibbs sampling paper.
|
% See Waggoner and Zha's Gibbs sampling paper.
|
||||||
%
|
%
|
||||||
% q_m: quarter or month
|
% q_m: quarter or month
|
||||||
% lags: the maximum length of lag
|
% lags: the maximum length of lag
|
||||||
% nvar: number of endogeous variables
|
% nvar: number of endogeous variables
|
||||||
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
% nexo: number of exogenous variables. If nexo is not supplied, nexo=1 as default for a constant
|
||||||
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
% indxC0Pres: index for cross-A0-A+ restrictions. if 1: cross-A0-and-A+ restrictions; 0: idfile is all we have
|
||||||
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
% Example for indxOres==1: restrictions of the form P(t) = P(t-1).
|
||||||
% These restrictions have to be manually and carefully keyed in.
|
% These restrictions have to be manually and carefully keyed in.
|
||||||
%-----------------
|
%-----------------
|
||||||
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith
|
||||||
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
% equation contemporaneous restriction matrix where qi is the number of free parameters.
|
||||||
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector
|
||||||
% of total original parameters and bi is a vector of free parameters. When no
|
% of total original parameters and bi is a vector of free parameters. When no
|
||||||
% restrictions are imposed, we have Ui = I. There must be at least one free
|
% restrictions are imposed, we have Ui = I. There must be at least one free
|
||||||
% parameter left for the ith equation.
|
% parameter left for the ith equation.
|
||||||
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
|
||||||
% equation lagged restriction matrix where k is a total of exogenous variables and
|
% equation lagged restriction matrix where k is a total of exogenous variables and
|
||||||
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi
|
||||||
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
|
||||||
% vector of free parameters. There must be at least one free parameter left for
|
% vector of free parameters. There must be at least one free parameter left for
|
||||||
% the ith equation.
|
% the ith equation.
|
||||||
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
% n0: nvar-by-1, ith element represents the number of free A0 parameters in ith equation
|
||||||
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
% np: nvar-by-1, ith element represents the number of free A+ parameters in ith equation
|
||||||
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
% ixmC0Pres: neq_cres-by-1 cell. Effective only if indxC0Pres=1, otherwise equals NaN.
|
||||||
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
% neq_cres is the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
% In the jth cell representing equation, we have 4 columns:
|
% In the jth cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%
|
%
|
||||||
% Tao Zha, May 2000
|
% Tao Zha, May 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
Ui = cell(nvar,1); % initializing for contemporaneous endogenous variables
|
||||||
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
Vi = cell(nvar,1); % initializing for lagged and exogenous variables
|
||||||
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
n0 = zeros(nvar,1); % ith element represents the number of free A0 parameters in ith equation
|
||||||
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
np = zeros(nvar,1); % ith element represents the number of free A+ parameters in ith equation
|
||||||
|
|
||||||
if (nargin==2)
|
if (nargin==2)
|
||||||
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
nexo = 1; % 1: constant as default where nexo must be a nonnegative integer
|
||||||
elseif (nargin==3)
|
elseif (nargin==3)
|
||||||
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
indxC0Pres = 0; % default is no cross-A0-and-A+ restrictions.
|
||||||
end
|
end
|
||||||
|
|
||||||
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
k = lags*nvar+nexo; % maximum number of lagged and exogenous variables in each equation
|
||||||
|
|
||||||
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
Qi = zeros(nvar,nvar,nvar); % for nvar contemporaneous equations
|
||||||
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
Ri = zeros(k,k,nvar); % for nvar lagged and exogenous equations
|
||||||
% Row corresponds to equation. 0 means no restriction.
|
% Row corresponds to equation. 0 means no restriction.
|
||||||
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
% 1 means exclusion restriction such that the corresponding parameter is restricted to 0.
|
||||||
|
|
||||||
%nfvar = 6; % number of foreign (Granger causing) variables
|
%nfvar = 6; % number of foreign (Granger causing) variables
|
||||||
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
%nhvar = nvar-nfvar; % number of home (affected) variables.
|
||||||
|
|
||||||
|
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
% Beginning the manual input of the restrictions one quation at a time
|
% Beginning the manual input of the restrictions one quation at a time
|
||||||
%-------------------------------------------------------------
|
%-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
%======== The first equation ===========
|
%======== The first equation ===========
|
||||||
Qi(1:6,:,1) = [
|
Qi(1:6,:,1) = [
|
||||||
0 1 0 0 0 0 0
|
0 1 0 0 0 0 0
|
||||||
0 0 1 0 0 0 0
|
0 0 1 0 0 0 0
|
||||||
0 0 0 1 0 0 0
|
0 0 0 1 0 0 0
|
||||||
0 0 0 0 1 0 0
|
0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 1 0
|
0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The second equation ===========
|
%======== The second equation ===========
|
||||||
Qi(1:5,:,2) = [
|
Qi(1:5,:,2) = [
|
||||||
0 0 1 0 0 0 0
|
0 0 1 0 0 0 0
|
||||||
0 0 0 1 0 0 0
|
0 0 0 1 0 0 0
|
||||||
0 0 0 0 1 0 0
|
0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 1 0
|
0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The third equation ===========
|
%======== The third equation ===========
|
||||||
Qi(1:4,:,3) = [
|
Qi(1:4,:,3) = [
|
||||||
0 0 0 1 0 0 0
|
0 0 0 1 0 0 0
|
||||||
0 0 0 0 1 0 0
|
0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 1 0
|
0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
%======== The fourth equation ===========
|
%======== The fourth equation ===========
|
||||||
Qi(1:3,:,4) = [
|
Qi(1:3,:,4) = [
|
||||||
0 0 0 0 1 0 0
|
0 0 0 0 1 0 0
|
||||||
0 0 0 0 0 1 0
|
0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The fifth equation ===========
|
%======== The fifth equation ===========
|
||||||
Qi(1:2,:,5) = [
|
Qi(1:2,:,5) = [
|
||||||
0 0 0 0 0 1 0
|
0 0 0 0 0 1 0
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The sixth equation ===========
|
%======== The sixth equation ===========
|
||||||
Qi(1:1,:,6) = [
|
Qi(1:1,:,6) = [
|
||||||
0 0 0 0 0 0 1
|
0 0 0 0 0 0 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
%======== The seventh equation ===========
|
%======== The seventh equation ===========
|
||||||
|
|
||||||
%===== Lagged restrictions in foreign (Granger causing) block
|
%===== Lagged restrictions in foreign (Granger causing) block
|
||||||
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
%nfbres = lags*(nvar-nfvar); % number of block restrictions in each foreign equation
|
||||||
%bfor = zeros(nfbres,k); % each foreign equation
|
%bfor = zeros(nfbres,k); % each foreign equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:nvar-nfvar
|
% for kj=1:nvar-nfvar
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
% bfor(cnt,nvar*(ki-1)+nfvar+kj) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nfbres
|
%if cnt~=nfbres
|
||||||
% error('Check lagged restrictions in foreign equations!')
|
% error('Check lagged restrictions in foreign equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=1:nfvar
|
%for kj=1:nfvar
|
||||||
% Ri(1:nfbres,:,kj) = bfor;
|
% Ri(1:nfbres,:,kj) = bfor;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
%===== Lagged restrictions in home (affected) block
|
%===== Lagged restrictions in home (affected) block
|
||||||
%
|
%
|
||||||
%~~~~~ selected domestic equations
|
%~~~~~ selected domestic equations
|
||||||
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
%dlrindx = nfvar+1; %[nfvar+1 nfvar+2]; % index for relevant home equations
|
||||||
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
%rfvindx = []; %[6]; %[1 2 3 5]; % index for restricted foreign variables (e.g., Poil, M2, FFR, P).
|
||||||
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
%%nf2hvar = nfvar-length(rfvindx); % number of free parameters -- foreign variables entering the home sector
|
||||||
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
%nhbres = lags*length(rfvindx); % number of block restrictions in each home equation
|
||||||
%bhom = zeros(nhbres,k); % each home equation
|
%bhom = zeros(nhbres,k); % each home equation
|
||||||
%cnt=0;
|
%cnt=0;
|
||||||
%for ki = 1:lags
|
%for ki = 1:lags
|
||||||
% for kj=1:length(rfvindx)
|
% for kj=1:length(rfvindx)
|
||||||
% cnt=cnt+1;
|
% cnt=cnt+1;
|
||||||
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
% bhom(cnt,nvar*(ki-1)+rfvindx(kj)) = 1;
|
||||||
% end
|
% end
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%if cnt~=nhbres
|
%if cnt~=nhbres
|
||||||
% error('Check lagged restrictions in domestic equations!')
|
% error('Check lagged restrictions in domestic equations!')
|
||||||
%end
|
%end
|
||||||
%%
|
%%
|
||||||
%for kj=dlrindx
|
%for kj=dlrindx
|
||||||
% Ri(1:nhbres,:,kj) = bhom;
|
% Ri(1:nhbres,:,kj) = bhom;
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
for n=1:nvar % initializing loop for each equation
|
for n=1:nvar % initializing loop for each equation
|
||||||
Ui{n} = null(Qi(:,:,n));
|
Ui{n} = null(Qi(:,:,n));
|
||||||
Vi{n} = null(Ri(:,:,n));
|
Vi{n} = null(Ri(:,:,n));
|
||||||
n0(n) = size(Ui{n},2);
|
n0(n) = size(Ui{n},2);
|
||||||
np(n) = size(Vi{n},2);
|
np(n) = size(Vi{n},2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
% Cross-A0-and-A+ rerestrictions one quation at a time
|
% Cross-A0-and-A+ rerestrictions one quation at a time
|
||||||
% i.e., the first, second, ..., kjth, ..., equation
|
% i.e., the first, second, ..., kjth, ..., equation
|
||||||
%(2)-------------------------------------------------------------
|
%(2)-------------------------------------------------------------
|
||||||
%
|
%
|
||||||
if indxC0Pres
|
if indxC0Pres
|
||||||
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
neq_cres = 3; % the number of equations in which cross-A0-A+ restrictions occur.
|
||||||
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
ixmC0Pres = cell(neq_cres,1); % in each cell representing equation, we have 4 columns:
|
||||||
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
%** 1st equation
|
%** 1st equation
|
||||||
ixmC0Pres{1} = [1 2 2 1
|
ixmC0Pres{1} = [1 2 2 1
|
||||||
1 7 1 1];
|
1 7 1 1];
|
||||||
%** 2nd equation
|
%** 2nd equation
|
||||||
ixmC0Pres{2} = [2 2 2 2];
|
ixmC0Pres{2} = [2 2 2 2];
|
||||||
%** 3rd equation
|
%** 3rd equation
|
||||||
ixmC0Pres{3} = [3 7 1 1
|
ixmC0Pres{3} = [3 7 1 1
|
||||||
3 2 2 1];
|
3 2 2 1];
|
||||||
|
|
||||||
|
|
||||||
% % 4 columns.
|
% % 4 columns.
|
||||||
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
% ncres = 5; % manually key in the number of cross-A0-A+ restrictions
|
||||||
|
|
||||||
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
% % 1st: the jth column (equation) of A+ or A0: f_j or a_j
|
||||||
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
% % 2nd: the ith element f_j(i) -- the ith element in the jth column of A+
|
||||||
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
% % 3rd: the hth element a_j(h) -- the hth element in the jth column of A0
|
||||||
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
% % 4th: the number s such that f_j(i) = s * a_j(h) holds.
|
||||||
else
|
else
|
||||||
ixmC0Pres = NaN;
|
ixmC0Pres = NaN;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,90 +1,90 @@
|
||||||
//MODEL:
|
//MODEL:
|
||||||
//test on Dynare to find the lagrangean multipliers.
|
//test on Dynare to find the lagrangean multipliers.
|
||||||
//We consider a standard NK model. We use the FOCS of the competitive economy and we aim at calculating the Ramsey optimal problem.
|
//We consider a standard NK model. We use the FOCS of the competitive economy and we aim at calculating the Ramsey optimal problem.
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
//1. Variable declaration
|
//1. Variable declaration
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
var pai, c, n, r, a;
|
var pai, c, n, r, a;
|
||||||
|
|
||||||
//4 variables + 1 shock
|
//4 variables + 1 shock
|
||||||
|
|
||||||
varexo u;
|
varexo u;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
// 2. Parameter declaration and calibration
|
// 2. Parameter declaration and calibration
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
parameters beta, rho, epsilon, omega, phi, gamma;
|
parameters beta, rho, epsilon, omega, phi, gamma;
|
||||||
|
|
||||||
beta=0.99;
|
beta=0.99;
|
||||||
gamma=3; //Frish elasticity
|
gamma=3; //Frish elasticity
|
||||||
omega=17; //price stickyness
|
omega=17; //price stickyness
|
||||||
epsilon=8; //elasticity for each variety of consumption
|
epsilon=8; //elasticity for each variety of consumption
|
||||||
phi=1; //coefficient associated to labor effort disutility
|
phi=1; //coefficient associated to labor effort disutility
|
||||||
|
|
||||||
rho=0.95; //coefficient associated to productivity shock
|
rho=0.95; //coefficient associated to productivity shock
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
// 3. The model
|
// 3. The model
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
|
|
||||||
a=rho*(a(-1))+u;
|
a=rho*(a(-1))+u;
|
||||||
|
|
||||||
1/c=beta*(1/(c(+1)))*(r/(pai(+1))); //euler
|
1/c=beta*(1/(c(+1)))*(r/(pai(+1))); //euler
|
||||||
|
|
||||||
|
|
||||||
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
||||||
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
||||||
|
|
||||||
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 4. Steady state
|
// 4. Steady state
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
|
|
||||||
pai=1;
|
pai=1;
|
||||||
r=1/beta;
|
r=1/beta;
|
||||||
c=0.9671684882;
|
c=0.9671684882;
|
||||||
n=0.9671684882;
|
n=0.9671684882;
|
||||||
a=0;
|
a=0;
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
// 5. shocks
|
// 5. shocks
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var u; stderr 0.008;
|
var u; stderr 0.008;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 6. Ramsey problem
|
// 6. Ramsey problem
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
||||||
|
|
||||||
write_latex_static_model;
|
write_latex_static_model;
|
||||||
|
|
||||||
ramsey_policy(planner_discount=0.99);
|
ramsey_policy(planner_discount=0.99);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
//MODEL:
|
//MODEL:
|
||||||
// test for using expectation operator with Ramsey policy
|
// test for using expectation operator with Ramsey policy
|
||||||
// The results is validated by comparing with replacing manually the expectation with an
|
// The results is validated by comparing with replacing manually the expectation with an
|
||||||
// auxiliary variable in nk_ramsey_expectation_a.mod
|
// auxiliary variable in nk_ramsey_expectation_a.mod
|
||||||
// Note that the example doesn't make any sense from an economic point of view.
|
// Note that the example doesn't make any sense from an economic point of view.
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
//1. Variable declaration
|
//1. Variable declaration
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
var pai, c, n, r, a;
|
var pai, c, n, r, a;
|
||||||
|
|
||||||
//4 variables + 1 shock
|
//4 variables + 1 shock
|
||||||
|
|
||||||
varexo u;
|
varexo u;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
// 2. Parameter declaration and calibration
|
// 2. Parameter declaration and calibration
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
parameters beta, rho, epsilon, omega, phi, gamma;
|
parameters beta, rho, epsilon, omega, phi, gamma;
|
||||||
|
|
||||||
beta=0.99;
|
beta=0.99;
|
||||||
gamma=3; //Frish elasticity
|
gamma=3; //Frish elasticity
|
||||||
omega=17; //price stickyness
|
omega=17; //price stickyness
|
||||||
epsilon=8; //elasticity for each variety of consumption
|
epsilon=8; //elasticity for each variety of consumption
|
||||||
phi=1; //coefficient associated to labor effort disutility
|
phi=1; //coefficient associated to labor effort disutility
|
||||||
|
|
||||||
rho=0.95; //coefficient associated to productivity shock
|
rho=0.95; //coefficient associated to productivity shock
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
// 3. The model
|
// 3. The model
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
|
|
||||||
a=rho*(a(-1))+u;
|
a=rho*(a(-1))+u;
|
||||||
|
|
||||||
1/c=beta*(1/(c(+1)))*(r/expectation(0)(pai(+1))); //euler
|
1/c=beta*(1/(c(+1)))*(r/expectation(0)(pai(+1))); //euler
|
||||||
|
|
||||||
|
|
||||||
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
||||||
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
||||||
|
|
||||||
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 4. Steady state
|
// 4. Steady state
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
% this is the exact steady state under optimal policy
|
% this is the exact steady state under optimal policy
|
||||||
%important for the comparison
|
%important for the comparison
|
||||||
|
|
||||||
pai=1;
|
pai=1;
|
||||||
r=1/beta;
|
r=1/beta;
|
||||||
c=((epsilon-1)/(epsilon*phi))^(1/(1+gamma));
|
c=((epsilon-1)/(epsilon*phi))^(1/(1+gamma));
|
||||||
n=c;
|
n=c;
|
||||||
a=0;
|
a=0;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
// 5. shocks
|
// 5. shocks
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var u; stderr 0.008;
|
var u; stderr 0.008;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 6. Ramsey problem
|
// 6. Ramsey problem
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
||||||
|
|
||||||
write_latex_static_model;
|
write_latex_static_model;
|
||||||
write_latex_dynamic_model;
|
write_latex_dynamic_model;
|
||||||
|
|
||||||
options_.solve_tolf=1e-12;
|
options_.solve_tolf=1e-12;
|
||||||
ramsey_policy(planner_discount=0.99);
|
ramsey_policy(planner_discount=0.99);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,104 +1,104 @@
|
||||||
//MODEL:
|
//MODEL:
|
||||||
// test for using expectation operator with Ramsey policy
|
// test for using expectation operator with Ramsey policy
|
||||||
// Here, the expected variable is replaced manually with an auxiliary variable (epai)
|
// Here, the expected variable is replaced manually with an auxiliary variable (epai)
|
||||||
// We check that the result is the same as with an explicit expectation operator in nk_ramsey_expectation.mod
|
// We check that the result is the same as with an explicit expectation operator in nk_ramsey_expectation.mod
|
||||||
// Note that the example doesn't make any sense from an economic point of view.
|
// Note that the example doesn't make any sense from an economic point of view.
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
//1. Variable declaration
|
//1. Variable declaration
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
var pai, c, n, r, a, epai;
|
var pai, c, n, r, a, epai;
|
||||||
|
|
||||||
//4 variables + 1 shock
|
//4 variables + 1 shock
|
||||||
|
|
||||||
varexo u;
|
varexo u;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
// 2. Parameter declaration and calibration
|
// 2. Parameter declaration and calibration
|
||||||
//-------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
parameters beta, rho, epsilon, omega, phi, gamma;
|
parameters beta, rho, epsilon, omega, phi, gamma;
|
||||||
|
|
||||||
beta=0.99;
|
beta=0.99;
|
||||||
gamma=3; //Frish elasticity
|
gamma=3; //Frish elasticity
|
||||||
omega=17; //price stickyness
|
omega=17; //price stickyness
|
||||||
epsilon=8; //elasticity for each variety of consumption
|
epsilon=8; //elasticity for each variety of consumption
|
||||||
phi=1; //coefficient associated to labor effort disutility
|
phi=1; //coefficient associated to labor effort disutility
|
||||||
|
|
||||||
rho=0.95; //coefficient associated to productivity shock
|
rho=0.95; //coefficient associated to productivity shock
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
// 3. The model
|
// 3. The model
|
||||||
//-----------------------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
|
|
||||||
a=rho*(a(-1))+u;
|
a=rho*(a(-1))+u;
|
||||||
|
|
||||||
1/c=beta*(1/(c(+1)))*(r/epai); //euler
|
1/c=beta*(1/(c(+1)))*(r/epai); //euler
|
||||||
|
|
||||||
|
|
||||||
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
omega*pai*(pai-1)=beta*omega*(c/(c(+1)))*(pai(+1))*(pai(+1)-1)+epsilon*exp(a)*n*(c/exp(a)*phi*n^gamma-(epsilon-1)/epsilon); //NK pc
|
||||||
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
//pai*(pai-1)/c = beta*pai(+1)*(pai(+1)-1)/c(+1)+epsilon*phi*n^(gamma+1)/omega-exp(a)*n*(epsilon-1)/(omega*c); //NK pc
|
||||||
|
|
||||||
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
(exp(a))*n=c+(omega/2)*((pai-1)^2);
|
||||||
|
|
||||||
epai = pai(+1);
|
epai = pai(+1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 4. Steady state
|
// 4. Steady state
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
% this is the exact steady state under optimal policy
|
% this is the exact steady state under optimal policy
|
||||||
%important for the comparison
|
%important for the comparison
|
||||||
|
|
||||||
pai=1;
|
pai=1;
|
||||||
epai=1;
|
epai=1;
|
||||||
r=1/beta;
|
r=1/beta;
|
||||||
c=((epsilon-1)/(epsilon*phi))^(1/(1+gamma));
|
c=((epsilon-1)/(epsilon*phi))^(1/(1+gamma));
|
||||||
n=c;
|
n=c;
|
||||||
a=0;
|
a=0;
|
||||||
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
// 5. shocks
|
// 5. shocks
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var u; stderr 0.008;
|
var u; stderr 0.008;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// 6. Ramsey problem
|
// 6. Ramsey problem
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
planner_objective(ln(c)-phi*((n^(1+gamma))/(1+gamma)));
|
||||||
|
|
||||||
options_.solve_tolf=1e-12;
|
options_.solve_tolf=1e-12;
|
||||||
ramsey_policy(planner_discount=0.99);
|
ramsey_policy(planner_discount=0.99);
|
||||||
|
|
||||||
o1=load('nk_ramsey_expectation_results');
|
o1=load('nk_ramsey_expectation_results');
|
||||||
if (norm(o1.oo_.dr.ghx-oo_.dr.ghx,inf) > 1e-12)
|
if (norm(o1.oo_.dr.ghx-oo_.dr.ghx,inf) > 1e-12)
|
||||||
error('ghx doesn''t match')
|
error('ghx doesn''t match')
|
||||||
end
|
end
|
||||||
if (norm(o1.oo_.dr.ghu-oo_.dr.ghu,inf) > 1e-12)
|
if (norm(o1.oo_.dr.ghu-oo_.dr.ghu,inf) > 1e-12)
|
||||||
error('ghu doesn''t match')
|
error('ghu doesn''t match')
|
||||||
end
|
end
|
||||||
if (abs(o1.oo_.planner_objective_value(1)-oo_.planner_objective_value(1)) > 1e-12)
|
if (abs(o1.oo_.planner_objective_value(1)-oo_.planner_objective_value(1)) > 1e-12)
|
||||||
error('planner objective value doesn''t match')
|
error('planner objective value doesn''t match')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
load ych.dat;
|
load ych.dat;
|
||||||
data = log(ych);
|
data = log(ych);
|
||||||
oy = data(:,1);
|
oy = data(:,1);
|
||||||
oc = data(:,2);
|
oc = data(:,2);
|
||||||
oh = data(:,3);
|
oh = data(:,3);
|
|
@ -1,58 +1,58 @@
|
||||||
function datasaver (s,var_list)
|
function datasaver (s,var_list)
|
||||||
% datasaver saves variables simulated by Dynare
|
% datasaver saves variables simulated by Dynare
|
||||||
% INPUT
|
% INPUT
|
||||||
% s: a string containing the name of the destination *.m file
|
% s: a string containing the name of the destination *.m file
|
||||||
% var_list: a character matrix containting the name of the variables
|
% var_list: a character matrix containting the name of the variables
|
||||||
% to be saved (optional, default: all endogenous variables)
|
% to be saved (optional, default: all endogenous variables)
|
||||||
% OUTPUT
|
% OUTPUT
|
||||||
% none
|
% none
|
||||||
% This is part of the examples included in F. Barillas, R. Colacito,
|
% This is part of the examples included in F. Barillas, R. Colacito,
|
||||||
% S. Kitao, C. Matthes, T. Sargent and Y. Shin (2007) "Practicing
|
% S. Kitao, C. Matthes, T. Sargent and Y. Shin (2007) "Practicing
|
||||||
% Dynare".
|
% Dynare".
|
||||||
|
|
||||||
% Modified by M. Juillard to make it also compatible with Dynare
|
% Modified by M. Juillard to make it also compatible with Dynare
|
||||||
% version 4 (12/4/07)
|
% version 4 (12/4/07)
|
||||||
|
|
||||||
|
|
||||||
global lgy_ lgx_ y_ endo_nbr M_ oo_
|
global lgy_ lgx_ y_ endo_nbr M_ oo_
|
||||||
|
|
||||||
% test and adapt for Dynare version 4
|
% test and adapt for Dynare version 4
|
||||||
if isempty(lgy_)
|
if isempty(lgy_)
|
||||||
lgy_ = M_.endo_names;
|
lgy_ = M_.endo_names;
|
||||||
lgx_ + M_.exo_names;
|
lgx_ + M_.exo_names;
|
||||||
y_ = oo_.endo_simul;
|
y_ = oo_.endo_simul;
|
||||||
endo_nbr = M_.endo_nbr;
|
endo_nbr = M_.endo_nbr;
|
||||||
end
|
end
|
||||||
|
|
||||||
sm=[s,'.m'];
|
sm=[s,'.m'];
|
||||||
fid=fopen(sm,'w') ;
|
fid=fopen(sm,'w') ;
|
||||||
|
|
||||||
n = size(var_list,1);
|
n = size(var_list,1);
|
||||||
if n == 0
|
if n == 0
|
||||||
n = endo_nbr;
|
n = endo_nbr;
|
||||||
ivar = [1:n]';
|
ivar = [1:n]';
|
||||||
var_list = lgy_;
|
var_list = lgy_;
|
||||||
else
|
else
|
||||||
ivar=zeros(n,1);
|
ivar=zeros(n,1);
|
||||||
for i=1:n
|
for i=1:n
|
||||||
i_tmp = strmatch(var_list(i,:),lgy_,'exact');
|
i_tmp = strmatch(var_list(i,:),lgy_,'exact');
|
||||||
if isempty(i_tmp)
|
if isempty(i_tmp)
|
||||||
error (['One of the specified variables does not exist']) ;
|
error (['One of the specified variables does not exist']) ;
|
||||||
else
|
else
|
||||||
ivar(i) = i_tmp;
|
ivar(i) = i_tmp;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for i = 1:n
|
for i = 1:n
|
||||||
fprintf(fid,[lgy_(ivar(i),:), '=['],'\n') ;
|
fprintf(fid,[lgy_(ivar(i),:), '=['],'\n') ;
|
||||||
fprintf(fid,'\n') ;
|
fprintf(fid,'\n') ;
|
||||||
fprintf(fid,'%15.8g\n',y_(ivar(i),:)') ;
|
fprintf(fid,'%15.8g\n',y_(ivar(i),:)') ;
|
||||||
fprintf(fid,'\n') ;
|
fprintf(fid,'\n') ;
|
||||||
fprintf(fid,'];\n') ;
|
fprintf(fid,'];\n') ;
|
||||||
fprintf(fid,'\n') ;
|
fprintf(fid,'\n') ;
|
||||||
end
|
end
|
||||||
fclose(fid) ;
|
fclose(fid) ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
data = [0.928467646476 11.8716889412 20 0.418037507392 0.227382377518 ...
|
||||||
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
-0.705994063083 11.7522582094 21.25 1.09254424511 -1.29488274994 ...
|
||||||
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
-0.511895351926 9.68144025625 17.25 -1.66150408407 0.331508393098 ...
|
||||||
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
-0.990955971267 10.0890781236 17 1.43016275252 -2.43589670141 ...
|
||||||
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
-0.981233061806 12.1094840679 18.25 2.91293288733 -0.790246576864 ...
|
||||||
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
-0.882182844512 8.54559460406 15 0.419579139481 0.358729719566 ...
|
||||||
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
-0.930893002836 6.19238374422 12.5 -1.48847457959 0.739779938797 ...
|
||||||
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
1.53158206947 2.76544271886 11.5 -0.336216769682 0.455559918769 ...
|
||||||
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
2.2659052834 5.47418162513 11 0.306436789767 -0.0707985731221 ...
|
||||||
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
1.05419803797 6.35698426189 11 0.140700250477 0.620401487202 ...
|
||||||
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
1.20161076793 3.4253301593 11 0.461296492351 0.14354323987 ...
|
||||||
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
1.73934077971 4.70926070322 11.5 1.35798282982 0.38564694435 ...
|
||||||
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
1.71735262584 3.54232079749 12.5 2.9097529155 -0.804308583301 ...
|
||||||
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
0.426343657844 3.32719108897 13 1.64214862652 -1.18214664701 ...
|
||||||
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
1.67751812324 2.93444727338 11.25 0.344434910651 -1.6529373719 ...
|
||||||
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
1.37013301099 4.72303361923 11.75 2.61511526582 0.327684243041 ...
|
||||||
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
0.281231073781 4.4893853071 10.5 1.17043449257 1.12855106649 ...
|
||||||
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
1.53638992834 3.7325309699 10.25 -0.683947046728 0.11943538737 ...
|
||||||
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
1.68081431462 3.34729969129 10 1.41159342106 -1.59065680853 ...
|
||||||
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
-0.343321601133 5.05563513564 12 1.75117366498 -2.40127764642 ...
|
||||||
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
0.873415608666 3.2779996255 10.25 -1.39895866711 0.0971444398216 ...
|
||||||
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
0.26399696544 4.78229419828 9.75 0.0914692438124 0.299310457612 ...
|
||||||
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
-0.562233624818 3.88598638237 9.75 -0.0505384765105 0.332826708151 ...
|
||||||
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
2.15161914936 3.84859710132 8.75 -3.44811080489 0.789138678784 ...
|
||||||
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
1.2345093726 5.62225030942 9.5 -0.366945407434 2.32974981198 ...
|
||||||
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
1.62554967459 4.24667132831 10 -0.800958371402 0.0293183770935 ...
|
||||||
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
1.33035402527 2.75248979249 9.75 -0.855723113225 0.852493939813 ...
|
||||||
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
1.52078814077 3.53415985826 9.75 -3.37963469203 -1.05133958119 ...
|
||||||
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
1.16704983697 4.92754079464 10.75 -3.0142303324 0.459907431978 ...
|
||||||
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
0.277213572101 4.55532133037 11.75 -0.851995599415 2.03242034852 ...
|
||||||
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
0.842215068977 3.11164509647 12.25 -1.08290421696 0.014323281961 ...
|
||||||
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
1.05325028606 4.92882647578 13.5 -1.1953883867 0.706764750654 ...
|
||||||
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
0.453051253568 6.82998950103 13.5 0.111803656462 0.088462593153 ...
|
||||||
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
0.199885995525 5.82643354662 13.5 -0.920501518421 -0.26504958666 ...
|
||||||
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
0.137907999624 2.66076369132 13.5 -1.17122929812 -0.995642430514 ...
|
||||||
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
0.721949686709 5.70497876823 14.25 1.19378169018 -1.10644839651 ...
|
||||||
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
-0.418465249225 3.75861110232 14.75 -1.03131674824 0.188507675831 ...
|
||||||
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
-0.644028342116 4.15104788154 13.75 -1.48911756546 0.204560913792 ...
|
||||||
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
-0.848213852668 5.65580324027 12.75 0.677011703877 -0.849628054542 ...
|
||||||
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
-1.51954076928 11.4866911266 11.25 -0.446024680774 -0.456342350765 ...
|
||||||
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
0.265275055215 2.85472749592 9.75 -0.598778202436 -0.907311640831 ...
|
||||||
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
0.356162529063 2.29614015658 9.5 -0.46820788432 -1.22130883441 ...
|
||||||
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
0.368308864363 -0.539083504685 8 -0.781333991956 0.374007246518 ...
|
||||||
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
-0.145751412732 1.61507621789 8.25 3.68291932628 1.32438399845 ...
|
||||||
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
0.285457283664 2.14334055993 7 1.42819405379 -0.00818660844123 ...
|
||||||
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
0.372390129412 1.60000213334 6.25 0.626106424052 -0.10136772765 ...
|
||||||
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
0.382720203063 1.72614243263 7.25 4.89631941021 -1.10060711916 ...
|
||||||
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
0.737957515573 2.90430582851 6 -0.0422721010314 0.4178952497 ...
|
||||||
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
0.649532581668 0.657135682543 6 0.692066153971 0.422299120276 ...
|
||||||
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
0.627159201987 1.70352689913 5.75 2.62066711305 -1.29237304034 ...
|
||||||
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
0.905441299817 1.95663197267 5.5 1.5949697565 -0.27115830703 ...
|
||||||
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
1.49322577898 -2.08741765309 6.25 1.23027694802 0.418336889527 ...
|
||||||
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
1.48750731567 -1.57274121871 8 3.01660550994 -0.893958254365 ...
|
||||||
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
1.39783858087 2.22623066426 7 -0.80842319214 1.47625453886 ...
|
||||||
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
0.89274836317 1.30378081742 8 -0.249485058661 0.159871204185 ...
|
||||||
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
0.920652246088 4.1437741965 9.75 2.8204453623 0.178149239655 ...
|
||||||
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
-0.00264276644799 3.07989972052 8.75 -2.56342461535 2.105998353 ...
|
||||||
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
0.0198190461681 0.766283759256 8 -1.15838865989 1.56888883418 ...
|
||||||
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
0.440050515311 0.127570085801 7.5 0.0400753569995 0.028914333532 ...
|
||||||
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
0.129536637901 1.78174141526 6.75 0.959943962785 0.307781224401 ...
|
||||||
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
0.398549827172 3.03606770667 6.5 -0.340209794742 0.100979469478 ...
|
||||||
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
1.17174775425 0.629625188037 5.75 0.403003686814 0.902394579377 ...
|
||||||
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
0.991163981251 2.50862910684 4.75 -1.44963996982 1.16150986945 ...
|
||||||
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
0.967603566096 2.12003739013 4.75 0.610846030775 -0.889994896068 ...
|
||||||
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
1.14689383604 1.24185011459 4.75 2.01098091308 -1.73846431001 ...
|
||||||
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
1.32593824054 0.990713820685 4.75 -0.0955142989332 -0.0369257308362 ...
|
||||||
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
0.861135002644 -0.24744943605 6 1.72793107135 -0.691506789639 ...
|
||||||
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
1.26870850151 2.09844764887 6.5 1.50720217572 -1.31399187077 ...
|
||||||
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
0.260364987715 1.10650139716 6.5 1.13659047496 0.0720441664643 ...
|
||||||
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
1.09731242214 0.490796381346 7.25 4.59123894147 -2.14073070763 ...
|
||||||
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
1.63792841781 0.612652594286 6.75 1.79604605035 -0.644363995357 ...
|
||||||
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
1.48465576034 0.978295808687 6.75 -2.00753620902 1.39437534964 ...
|
||||||
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
1.0987608663 4.25212569087 6.25 -2.58901196498 2.56054320803 ...
|
||||||
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
1.42592178132 2.76984518311 6.25 0.888195752358 1.03114549274 ...
|
||||||
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
1.52958239462 1.31795955491 6.5 -0.902907564082 -0.0952198893776 ...
|
||||||
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
1.0170168994 2.14733589918 7 -1.3054866978 2.68803738466 ...
|
||||||
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
0.723253652257 3.43552889347 7.5 1.8213700853 0.592593586195 ...
|
||||||
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
1.24720806008 3.87383806577 7.5 0.0522300654168 0.988871238698 ...
|
||||||
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
0.482531471239 2.67793287032 7.5 2.9693944293 -0.108591166081 ...
|
||||||
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
0.154056100439 0.927269031704 6.75 0.119222057561 3.30489209451 ...
|
||||||
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
0.0694865769274 6.65916526788 6.25 0.889014476084 -2.83976849035 ...
|
||||||
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
-0.121267434867 0.341442615696 5.25 0.323053239216 -3.49289229012 ...
|
||||||
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
0.726473690375 -3.5423730964 4 2.19149290449 -3.20855054004 ...
|
||||||
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
1.39271709108 2.63121085718 3.75 0.88406577736 0.75622580197 ...
|
||||||
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
1.07502077727 5.88578836799 4.25 -2.55088273352 2.89018116374 ...
|
||||||
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
0.759049251607 4.24703604223 4.5 0.575687665685 -0.388292506167 ...
|
||||||
];
|
];
|
||||||
|
|
||||||
data = reshape(data,5,86)';
|
data = reshape(data,5,86)';
|
||||||
y_obs = data(:,1);
|
y_obs = data(:,1);
|
||||||
pie_obs = data(:,2);
|
pie_obs = data(:,2);
|
||||||
R_obs = data(:,3);
|
R_obs = data(:,3);
|
||||||
de = data(:,4);
|
de = data(:,4);
|
||||||
dq = data(:,5);
|
dq = data(:,5);
|
||||||
|
|
||||||
%Country: Canada
|
%Country: Canada
|
||||||
%Sample Range: 1981:2 to 2002:3
|
%Sample Range: 1981:2 to 2002:3
|
||||||
%Observations: 86
|
%Observations: 86
|
||||||
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
%Variables: Real GDP Growth [%], Inflation [annualized %], Nom Rate [%],
|
||||||
% Exchange Rate Change [%], Terms of Trade Change [%]
|
% Exchange Rate Change [%], Terms of Trade Change [%]
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
@#define N = 4
|
@#define N = 4
|
||||||
var A B;
|
var A B;
|
||||||
varexo eB;
|
varexo eB;
|
||||||
parameters Bss rho;
|
parameters Bss rho;
|
||||||
|
|
||||||
Bss=1;
|
Bss=1;
|
||||||
rho=0.9;
|
rho=0.9;
|
||||||
|
|
||||||
model;
|
model;
|
||||||
A = B(@{N});
|
A = B(@{N});
|
||||||
B = (1-rho)*Bss +rho*B(-1) +eB;
|
B = (1-rho)*Bss +rho*B(-1) +eB;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady_state_model;
|
steady_state_model;
|
||||||
A = Bss;
|
A = Bss;
|
||||||
B = Bss;
|
B = Bss;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
resid;
|
resid;
|
||||||
steady;
|
steady;
|
||||||
check;
|
check;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var eB ; stderr 1 ;
|
var eB ; stderr 1 ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
stoch_simul(order=1,irf=0) ;
|
stoch_simul(order=1,irf=0) ;
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
var y c k m n R pi z u;
|
var y c k m n R pi z u;
|
||||||
varexo e sigma;
|
varexo e sigma;
|
||||||
// sigma stands for phi in the eq 2.37 p.69
|
// sigma stands for phi in the eq 2.37 p.69
|
||||||
|
|
||||||
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
||||||
//phi1 stands for capital phi in eq.2.68 and 2.69
|
//phi1 stands for capital phi in eq.2.68 and 2.69
|
||||||
//phi2 stands for lowercase phi in eq. 2.66
|
//phi2 stands for lowercase phi in eq. 2.66
|
||||||
|
|
||||||
change_type(var) Psi;
|
change_type(var) Psi;
|
||||||
change_type(parameters) n;
|
change_type(parameters) n;
|
||||||
|
|
||||||
alpha = 0.36;
|
alpha = 0.36;
|
||||||
beta = 0.989;
|
beta = 0.989;
|
||||||
gamm = 0.5;
|
gamm = 0.5;
|
||||||
delta = 0.019;
|
delta = 0.019;
|
||||||
phi1 = 2;
|
phi1 = 2;
|
||||||
phi2 = 0;
|
phi2 = 0;
|
||||||
eta = 1;
|
eta = 1;
|
||||||
a = 0.95;
|
a = 0.95;
|
||||||
b = 2.56;
|
b = 2.56;
|
||||||
rho = 0.95;
|
rho = 0.95;
|
||||||
//Psi = 1.47630583;
|
//Psi = 1.47630583;
|
||||||
thetass = 1.0125;
|
thetass = 1.0125;
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
||||||
|
|
||||||
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
||||||
|
|
||||||
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
||||||
|
|
||||||
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
||||||
|
|
||||||
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
||||||
|
|
||||||
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
||||||
|
|
||||||
z = rho*z(-1) + e;
|
z = rho*z(-1) + e;
|
||||||
|
|
||||||
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e; stderr 0.007;
|
var e; stderr 0.007;
|
||||||
var sigma;stderr 0.0089;
|
var sigma;stderr 0.0089;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
n=log(1/3);
|
n=log(1/3);
|
||||||
|
|
||||||
initval;
|
initval;
|
||||||
y = 0.2;
|
y = 0.2;
|
||||||
c = 0.03;
|
c = 0.03;
|
||||||
k = 2.7;
|
k = 2.7;
|
||||||
m = 0.3;
|
m = 0.3;
|
||||||
Psi = 1.5;
|
Psi = 1.5;
|
||||||
R = 0.01;
|
R = 0.01;
|
||||||
pi = 0.01;
|
pi = 0.01;
|
||||||
z = 0;
|
z = 0;
|
||||||
u = 0;
|
u = 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
var y c k m n R pi z u;
|
var y c k m n R pi z u;
|
||||||
varexo e sigma;
|
varexo e sigma;
|
||||||
// sigma stands for phi in the eq 2.37 p.69
|
// sigma stands for phi in the eq 2.37 p.69
|
||||||
|
|
||||||
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
||||||
//phi1 stands for capital phi in eq.2.68 and 2.69
|
//phi1 stands for capital phi in eq.2.68 and 2.69
|
||||||
//phi2 stands for lowercase phi in eq. 2.66
|
//phi2 stands for lowercase phi in eq. 2.66
|
||||||
|
|
||||||
alpha = 0.36;
|
alpha = 0.36;
|
||||||
beta = 0.989;
|
beta = 0.989;
|
||||||
gamm = 0.5;
|
gamm = 0.5;
|
||||||
delta = 0.019;
|
delta = 0.019;
|
||||||
phi1 = 2;
|
phi1 = 2;
|
||||||
phi2 = 0;
|
phi2 = 0;
|
||||||
eta = 1;
|
eta = 1;
|
||||||
a = 0.95;
|
a = 0.95;
|
||||||
b = 2.56;
|
b = 2.56;
|
||||||
rho = 0.95;
|
rho = 0.95;
|
||||||
Psi = 1.47630583;
|
Psi = 1.47630583;
|
||||||
thetass = 1.0125;
|
thetass = 1.0125;
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
||||||
|
|
||||||
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
||||||
|
|
||||||
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
||||||
|
|
||||||
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
||||||
|
|
||||||
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
||||||
|
|
||||||
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
||||||
|
|
||||||
z = rho*z(-1) + e;
|
z = rho*z(-1) + e;
|
||||||
|
|
||||||
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e; stderr 0.007;
|
var e; stderr 0.007;
|
||||||
var sigma;stderr 0.0089;
|
var sigma;stderr 0.0089;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
var y c k m n R pi z u;
|
var y c k m n R pi z u;
|
||||||
varexo e sigma;
|
varexo e sigma;
|
||||||
// sigma stands for phi in the eq 2.37 p.69
|
// sigma stands for phi in the eq 2.37 p.69
|
||||||
|
|
||||||
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
||||||
//phi1 stands for capital phi in eq.2.68 and 2.69
|
//phi1 stands for capital phi in eq.2.68 and 2.69
|
||||||
//phi2 stands for lowercase phi in eq. 2.66
|
//phi2 stands for lowercase phi in eq. 2.66
|
||||||
|
|
||||||
alpha = 0.36;
|
alpha = 0.36;
|
||||||
beta = 0.989;
|
beta = 0.989;
|
||||||
gamm = 0.5;
|
gamm = 0.5;
|
||||||
delta = 0.019;
|
delta = 0.019;
|
||||||
phi1 = 2;
|
phi1 = 2;
|
||||||
phi2 = 0;
|
phi2 = 0;
|
||||||
eta = 1;
|
eta = 1;
|
||||||
a = 0.95;
|
a = 0.95;
|
||||||
b = 2.56;
|
b = 2.56;
|
||||||
rho = 0.95;
|
rho = 0.95;
|
||||||
Psi = 1.47630583;
|
Psi = 1.47630583;
|
||||||
thetass = 1.0125;
|
thetass = 1.0125;
|
||||||
|
|
||||||
model;
|
model;
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
||||||
|
|
||||||
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
||||||
|
|
||||||
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
||||||
|
|
||||||
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
||||||
|
|
||||||
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
||||||
|
|
||||||
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
||||||
|
|
||||||
z = rho*z(-1) + e;
|
z = rho*z(-1) + e;
|
||||||
|
|
||||||
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e; stderr 0.007;
|
var e; stderr 0.007;
|
||||||
var sigma;stderr 0.0089;
|
var sigma;stderr 0.0089;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady_state_model;
|
steady_state_model;
|
||||||
// solving in levels
|
// solving in levels
|
||||||
// calibrating n = 1/3 and recovering the value of Psi
|
// calibrating n = 1/3 and recovering the value of Psi
|
||||||
// adapting solution Walsh (2003) p. 84
|
// adapting solution Walsh (2003) p. 84
|
||||||
pi = thetass-1;
|
pi = thetass-1;
|
||||||
en = 1/3;
|
en = 1/3;
|
||||||
eR = 1/beta;
|
eR = 1/beta;
|
||||||
y_k = (1/alpha)*(1/beta-1+delta);
|
y_k = (1/alpha)*(1/beta-1+delta);
|
||||||
ek = en*y_k^(-1/(1-alpha));
|
ek = en*y_k^(-1/(1-alpha));
|
||||||
ec = ek*(y_k-delta);
|
ec = ek*(y_k-delta);
|
||||||
em = ec*(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^(-1/b);
|
em = ec*(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^(-1/b);
|
||||||
ey = ek*y_k;
|
ey = ek*y_k;
|
||||||
Xss = a*ec^(1-b)*(1+(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^((b-1)/b));
|
Xss = a*ec^(1-b)*(1+(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^((b-1)/b));
|
||||||
Psi = (1-alpha)*(ey/en)*Xss^((b-phi1)/(1-b))*a*ec^(-b)*(1-en)^eta;
|
Psi = (1-alpha)*(ey/en)*Xss^((b-phi1)/(1-b))*a*ec^(-b)*(1-en)^eta;
|
||||||
n = log(en);
|
n = log(en);
|
||||||
k = log(ek);
|
k = log(ek);
|
||||||
m = log(em);
|
m = log(em);
|
||||||
c = log(ec);
|
c = log(ec);
|
||||||
y = log(ey);
|
y = log(ey);
|
||||||
R = log(eR);
|
R = log(eR);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
var y c k m n R pi z u;
|
var y c k m n R pi z u;
|
||||||
varexo e sigma;
|
varexo e sigma;
|
||||||
// sigma stands for phi in the eq 2.37 p.69
|
// sigma stands for phi in the eq 2.37 p.69
|
||||||
|
|
||||||
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
parameters alpha beta delta gamm phi1 eta a b rho phi2 Psi thetass;
|
||||||
//phi1 stands for capital phi in eq.2.68 and 2.69
|
//phi1 stands for capital phi in eq.2.68 and 2.69
|
||||||
//phi2 stands for lowercase phi in eq. 2.66
|
//phi2 stands for lowercase phi in eq. 2.66
|
||||||
|
|
||||||
alpha = 0.36;
|
alpha = 0.36;
|
||||||
beta = 0.989;
|
beta = 0.989;
|
||||||
gamm = 0.5;
|
gamm = 0.5;
|
||||||
delta = 0.019;
|
delta = 0.019;
|
||||||
phi1 = 2;
|
phi1 = 2;
|
||||||
phi2 = 0;
|
phi2 = 0;
|
||||||
eta = 1;
|
eta = 1;
|
||||||
a = 0.95;
|
a = 0.95;
|
||||||
b = 2.56;
|
b = 2.56;
|
||||||
rho = 0.95;
|
rho = 0.95;
|
||||||
Psi = 1.47630583;
|
Psi = 1.47630583;
|
||||||
thetass = 1.0125;
|
thetass = 1.0125;
|
||||||
|
|
||||||
model(block);
|
model(block);
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = (a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*(1-a)*exp(m)^(-b)+beta*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b)/(1+pi(+1));
|
||||||
|
|
||||||
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
Psi*(1-exp(n))^(-eta)/(a*exp(c)^(-b)*(a*exp(c)^(1-b) + (1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))) = (1-alpha)*exp(y)/exp(n);
|
||||||
|
|
||||||
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
(a*exp(c)^(1-b)+(1-a)*exp(m)^(1-b))^((b-phi1)/(1-b))*a*exp(c)^(-b) = beta*exp(R(+1))*(a*exp(c(+1))^(1-b)+(1-a)*exp(m(+1))^(1-b))^((b-phi1)/(1-b))*a*exp(c(+1))^(-b);
|
||||||
|
|
||||||
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
exp(R) = alpha*exp(y)/exp(k(-1)) + 1-delta;
|
||||||
|
|
||||||
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
exp(k) = (1-delta)*exp(k(-1))+exp(y)-exp(c);
|
||||||
|
|
||||||
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
exp(y) = exp(z)*exp(k(-1))^alpha*exp(n)^(1-alpha);
|
||||||
|
|
||||||
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
exp(m) = exp(m(-1))*(u+thetass)/(1+pi);
|
||||||
|
|
||||||
z = rho*z(-1) + e;
|
z = rho*z(-1) + e;
|
||||||
|
|
||||||
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
u = gamm*u(-1) + phi2*z(-1) + sigma;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
shocks;
|
shocks;
|
||||||
var e; stderr 0.007;
|
var e; stderr 0.007;
|
||||||
var sigma;stderr 0.0089;
|
var sigma;stderr 0.0089;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady_state_model;
|
steady_state_model;
|
||||||
// solving in levels
|
// solving in levels
|
||||||
// calibrating n = 1/3 and recovering the value of Psi
|
// calibrating n = 1/3 and recovering the value of Psi
|
||||||
// adapting solution Walsh (2003) p. 84
|
// adapting solution Walsh (2003) p. 84
|
||||||
pi = thetass-1;
|
pi = thetass-1;
|
||||||
en = 1/3;
|
en = 1/3;
|
||||||
eR = 1/beta;
|
eR = 1/beta;
|
||||||
y_k = (1/alpha)*(1/beta-1+delta);
|
y_k = (1/alpha)*(1/beta-1+delta);
|
||||||
ek = en*y_k^(-1/(1-alpha));
|
ek = en*y_k^(-1/(1-alpha));
|
||||||
ec = ek*(y_k-delta);
|
ec = ek*(y_k-delta);
|
||||||
em = ec*(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^(-1/b);
|
em = ec*(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^(-1/b);
|
||||||
ey = ek*y_k;
|
ey = ek*y_k;
|
||||||
Xss = a*ec^(1-b)*(1+(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^((b-1)/b));
|
Xss = a*ec^(1-b)*(1+(a/(1-a))^(-1/b)*((thetass-beta)/thetass)^((b-1)/b));
|
||||||
Psi = (1-alpha)*(ey/en)*Xss^((b-phi1)/(1-b))*a*ec^(-b)*(1-en)^eta;
|
Psi = (1-alpha)*(ey/en)*Xss^((b-phi1)/(1-b))*a*ec^(-b)*(1-en)^eta;
|
||||||
n = log(en);
|
n = log(en);
|
||||||
k = log(ek);
|
k = log(ek);
|
||||||
m = log(em);
|
m = log(em);
|
||||||
c = log(ec);
|
c = log(ec);
|
||||||
y = log(ey);
|
y = log(ey);
|
||||||
R = log(eR);
|
R = log(eR);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
steady;
|
steady;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function test(a,b,n)
|
function test(a,b,n)
|
||||||
if max(max(abs(a)-abs(b))) > 1e-5
|
if max(max(abs(a)-abs(b))) > 1e-5
|
||||||
error(['Test error in test ' int2str(n)])
|
error(['Test error in test ' int2str(n)])
|
||||||
end
|
end
|
Loading…
Reference in New Issue