#### HW2 R output #### Problem 1 > setwd("C:/Users/rst/teaching/mts/sp2017") > da <- read.table("m-unrate-MIILIN.txt",header=T) > fix(da) > rate <- da[,-1] > require(MTS) > VARorder(rate) selected order: aic = 7 selected order: bic = 3 selected order: hq = 4 Summary table: p AIC BIC HQ M(p) p-value [1,] 0 0.4582 0.4582 0.4582 0.0000 0.0000 [2,] 1 -11.9638 -11.8870 -11.9337 5911.6252 0.0000 [3,] 2 -13.9601 -13.8065 -13.8998 958.5123 0.0000 [4,] 3 -14.1299 -13.8995 -14.0395 96.6951 0.0000 [5,] 4 -14.1913 -13.8841 -14.0706 45.5715 0.0000 [6,] 5 -14.2067 -13.8227 -14.0559 24.0556 0.0042 [7,] 6 -14.2241 -13.7633 -14.0432 24.8286 0.0032 [8,] 7 -14.2681 -13.7304 -14.0570 36.7523 0.0000 [9,] 8 -14.2579 -13.6435 -14.0166 11.9740 0.2148 [10,] 9 -14.2376 -13.5464 -13.9662 7.3705 0.5986 [11,] 10 -14.2342 -13.4662 -13.9327 14.8468 0.0952 [12,] 11 -14.2337 -13.3889 -13.9020 16.0191 0.0665 [13,] 12 -14.2088 -13.2871 -13.8469 5.1453 0.8215 [14,] 13 -14.1970 -13.1986 -13.8050 10.8888 0.2834 > m1 <- VAR(rate,7) Constant term: Estimates: 0.08589616 0.04518543 0.03625387 Std.Error: 0.02387927 0.01485285 0.02095675 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [,3] [1,] 1.409 0.319 0.2053 [2,] 0.117 1.511 0.0882 [3,] 0.283 0.240 1.5221 standard error [,1] [,2] [,3] [1,] 0.0485 0.0739 0.0554 [2,] 0.0301 0.0460 0.0344 [3,] 0.0425 0.0649 0.0486 AR( 2 )-matrix [,1] [,2] [,3] [1,] -0.0436 -0.392 -0.169 [2,] -0.0967 -0.131 -0.106 [3,] -0.2962 -0.347 -0.476 standard error [,1] [,2] [,3] [1,] 0.0814 0.1331 0.0986 [2,] 0.0506 0.0828 0.0613 [3,] 0.0714 0.1168 0.0865 AR( 3 )-matrix [,1] [,2] [,3] [1,] -0.4056 -0.1471 -0.1337 [2,] -0.0491 -0.3956 -0.0114 [3,] -0.0829 0.0465 -0.0275 standard error [,1] [,2] [,3] [1,] 0.0828 0.1347 0.1016 [2,] 0.0515 0.0838 0.0632 [3,] 0.0726 0.1182 0.0892 AR( 4 )-matrix [,1] [,2] [,3] [1,] -0.0528 0.26771 0.0813 [2,] -0.0345 -0.26136 0.0347 [3,] 0.0388 -0.00946 -0.0570 standard error [,1] [,2] [,3] [1,] 0.0843 0.1372 0.1017 [2,] 0.0524 0.0853 0.0633 [3,] 0.0740 0.1204 0.0893 AR( 5 )-matrix [,1] [,2] [,3] [1,] -0.0502 -0.0501 0.0932 [2,] 0.0941 0.1203 -0.0449 [3,] 0.0608 0.0676 -0.0718 standard error [,1] [,2] [,3] [1,] 0.0822 0.1361 0.1017 [2,] 0.0511 0.0847 0.0633 [3,] 0.0721 0.1194 0.0893 AR( 6 )-matrix [,1] [,2] [,3] [1,] 0.0909 0.0627 0.0321 [2,] 0.0258 0.2926 0.1516 [3,] 0.0851 0.1084 0.1201 standard error [,1] [,2] [,3] [1,] 0.0817 0.1354 0.0974 [2,] 0.0508 0.0842 0.0606 [3,] 0.0717 0.1188 0.0855 AR( 7 )-matrix [,1] [,2] [,3] [1,] 0.0417 -0.0855 -0.0821 [2,] -0.0558 -0.1581 -0.0964 [3,] -0.0683 -0.1140 -0.0320 standard error [,1] [,2] [,3] [1,] 0.0490 0.0739 0.0554 [2,] 0.0305 0.0460 0.0345 [3,] 0.0430 0.0649 0.0486 Residuals cov-mtx: [,1] [,2] [,3] [1,] 0.012285384 0.001131262 0.002964367 [2,] 0.001131262 0.004752981 0.001133803 [3,] 0.002964367 0.001133803 0.009462255 det(SSE) = 4.904572e-07 AIC = -14.27183 BIC = -13.73422 HQ = -14.06073 > m1a <- refVAR(m1,thres=1.645) Constant term: Estimates: 0.08436305 0.04529145 0.0384588 Std.Error: 0.02365156 0.0147954 0.02067775 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [,3] [1,] 1.411 0.326 0.226 [2,] 0.126 1.513 0.102 [3,] 0.270 0.245 1.533 standard error [,1] [,2] [,3] [1,] 0.0271 0.0718 0.0519 [2,] 0.0289 0.0451 0.0312 [3,] 0.0394 0.0613 0.0456 AR( 2 )-matrix [,1] [,2] [,3] [1,] 0.000 -0.467 -0.253 [2,] -0.151 -0.148 -0.124 [3,] -0.311 -0.337 -0.503 standard error [,1] [,2] [,3] [1,] 0.0000 0.1086 0.0644 [2,] 0.0380 0.0819 0.0367 [3,] 0.0478 0.0822 0.0642 AR( 3 )-matrix [,1] [,2] [,3] [1,] -0.521 0.000 0 [2,] 0.000 -0.374 0 [3,] 0.000 0.000 0 standard error [,1] [,2] [,3] [1,] 0.0389 0.0000 0 [2,] 0.0000 0.0828 0 [3,] 0.0000 0.0000 0 AR( 4 )-matrix [,1] [,2] [,3] [1,] 0 0.163 0.0000 [2,] 0 -0.207 0.0000 [3,] 0 0.000 -0.0976 standard error [,1] [,2] [,3] [1,] 0 0.0642 0.0000 [2,] 0 0.0736 0.0000 [3,] 0 0.0000 0.0465 AR( 5 )-matrix [,1] [,2] [,3] [1,] 0.0000 0.000 0.106 [2,] 0.0598 0.000 0.000 [3,] 0.0000 0.163 0.000 standard error [,1] [,2] [,3] [1,] 0.0000 0.0000 0.0412 [2,] 0.0269 0.0000 0.0000 [3,] 0.0000 0.0538 0.0000 AR( 6 )-matrix [,1] [,2] [,3] [1,] 0.0987 0.000 0.0000 [2,] 0.0000 0.363 0.1343 [3,] 0.1363 0.000 0.0469 standard error [,1] [,2] [,3] [1,] 0.020 0.0000 0.0000 [2,] 0.000 0.0702 0.0372 [3,] 0.047 0.0000 0.0271 AR( 7 )-matrix [,1] [,2] [,3] [1,] 0.0000 -0.0454 -0.0512 [2,] -0.0352 -0.1673 -0.0958 [3,] -0.0755 -0.0806 0.0000 standard error [,1] [,2] [,3] [1,] 0.0000 0.0246 0.0288 [2,] 0.0173 0.0453 0.0320 [3,] 0.0385 0.0314 0.0000 Residuals cov-mtx: [,1] [,2] [,3] [1,] 0.012460232 0.001106436 0.002931774 [2,] 0.001106436 0.004805403 0.001138936 [3,] 0.002931774 0.001138936 0.009553435 det(SSE) = 5.102523e-07 AIC = -14.33795 BIC = -14.02221 HQ = -14.21397 > MTSdiag(m1a) [1] "Covariance matrix:" MI IL IN MI 0.01249 0.00111 0.00294 IL 0.00111 0.00482 0.00114 IN 0.00294 0.00114 0.00957 CCM at lag: 0 [,1] [,2] [,3] [1,] 1.000 0.143 0.269 [2,] 0.143 1.000 0.168 [3,] 0.269 0.168 1.000 Simplified matrix: CCM at lag: 1 . . . . . . . . . CCM at lag: 2 . . . . . . . . . CCM at lag: 3 . . . . . . . . . CCM at lag: 4 . . . . . . . . . CCM at lag: 5 . . . . . . . . . CCM at lag: 6 - . . . . . . . . CCM at lag: 7 . . . . . . . . . CCM at lag: 8 . . . . + . . . . CCM at lag: 9 . . . . . . . . . CCM at lag: 10 . . . . . . . . . CCM at lag: 11 . . . . . . . . . CCM at lag: 12 . . . . . . . . . CCM at lag: 13 . . . . . . . . . CCM at lag: 14 . . . . . . . . . CCM at lag: 15 . . . . . . . - . CCM at lag: 16 . . . . . . . . . CCM at lag: 17 . . . . . . . . . CCM at lag: 18 . . . . . . . . . CCM at lag: 19 . . . . . - . . . CCM at lag: 20 . . . . . - . . . CCM at lag: 21 . . . . . . . . . CCM at lag: 22 . . . . . . . . . CCM at lag: 23 . . . . . . . . . CCM at lag: 24 . . . . . . . . . Hit Enter for p-value plot of individual ccm: Hit Enter to compute MQ-statistics: Ljung-Box Statistics: m Q(m) df p-value [1,] 1.000 0.788 9.000 1.00 [2,] 2.000 5.846 18.000 1.00 [3,] 3.000 11.997 27.000 0.99 [4,] 4.000 15.242 36.000 1.00 [5,] 5.000 20.077 45.000 1.00 [6,] 6.000 31.549 54.000 0.99 [7,] 7.000 37.497 63.000 1.00 [8,] 8.000 47.350 72.000 0.99 [9,] 9.000 54.309 81.000 0.99 [10,] 10.000 57.400 90.000 1.00 [11,] 11.000 63.775 99.000 1.00 [12,] 12.000 70.978 108.000 1.00 [13,] 13.000 76.552 117.000 1.00 [14,] 14.000 80.905 126.000 1.00 [15,] 15.000 97.954 135.000 0.99 [16,] 16.000 104.327 144.000 0.99 [17,] 17.000 109.608 153.000 1.00 [18,] 18.000 116.645 162.000 1.00 [19,] 19.000 135.109 171.000 0.98 [20,] 20.000 142.307 180.000 0.98 [21,] 21.000 150.563 189.000 0.98 [22,] 22.000 156.275 198.000 0.99 [23,] 23.000 158.624 207.000 0.99 [24,] 24.000 169.657 216.000 0.99 Hit Enter to obtain residual plots: > names(m1a) [1] "data" "order" "cnst" "coef" "aic" "bic" [7] "hq" "residuals" "secoef" "Sigma" "Phi" "Ph0" > Sig <- m1a$Sigma > U <- chol(Sig) > names(U) NULL > U [,1] [,2] [,3] [1,] 0.1116254 0.009912048 0.02626439 [2,] 0.0000000 0.068608702 0.01280599 [3,] 0.0000000 0.000000000 0.09327177 > Phi <- m1a$Phi > VARirf(Phi,Sig) Press return to continue > VARirf(Phi,Sig,orth=F) Press return to continue ##### Problem 2 > da <- read.table("d-exjpuseu.txt") > zt <- log(da) > colnames(zt) <- c("jpus","useu") > MTSplot(zt) > VARorder(zt) selected order: aic = 1 selected order: bic = 1 selected order: hq = 1 Summary table: p AIC BIC HQ M(p) p-value [1,] 0 -8.7260 -8.7260 -8.7260 0.0000 0.0000 [2,] 1 -20.2101 -20.2021 -20.2072 34282.3592 0.0000 [3,] 2 -20.2079 -20.1919 -20.2021 1.2673 0.8669 [4,] 3 -20.2060 -20.1820 -20.1974 2.3075 0.6794 [5,] 4 -20.2055 -20.1735 -20.1940 6.6069 0.1582 [6,] 5 -20.2045 -20.1644 -20.1901 4.7634 0.3124 [7,] 6 -20.2059 -20.1579 -20.1886 12.1755 0.0161 [8,] 7 -20.2035 -20.1475 -20.1834 0.9265 0.9207 [9,] 8 -20.2016 -20.1375 -20.1786 2.1001 0.7174 [10,] 9 -20.2016 -20.1295 -20.1757 7.8882 0.0958 [11,] 10 -20.1992 -20.1192 -20.1704 0.9360 0.9193 [12,] 11 -20.1983 -20.1102 -20.1666 5.0622 0.2810 [13,] 12 -20.1959 -20.0998 -20.1614 0.9302 0.9202 [14,] 13 -20.1960 -20.0919 -20.1585 8.0544 0.0896 > m2 <- VAR(zt,1) Constant term: Estimates: 0.006101693 0.001191275 Std.Error: 0.004449697 0.004160642 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [1,] 0.998731 -0.000906 [2,] -0.000183 0.998383 standard error [,1] [,2] [1,] 0.000929 0.00140 [2,] 0.000869 0.00131 Residuals cov-mtx: [,1] [,2] [1,] 4.509373e-05 -1.089528e-05 [2,] -1.089528e-05 3.942539e-05 det(SSE) = 1.659131e-09 AIC = -20.21431 BIC = -20.2063 HQ = -20.21143 > m2a <- refVAR(m2,thres=1.645) Constant term: Estimates: 0 0 Std.Error: 0 0 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [1,] 1 0 [2,] 0 1 standard error [,1] [,2] [1,] 2.66e-05 0.00000 [2,] 0.00e+00 0.00042 Residuals cov-mtx: [,1] [,2] [1,] 4.512202e-05 -1.088993e-05 [2,] -1.088993e-05 3.943841e-05 det(SSE) = 1.66095e-09 AIC = -20.21454 BIC = -20.21054 HQ = -20.2131 > MTSdiag(m2a) [1] "Covariance matrix:" jpus useu jpus 4.51e-05 -1.09e-05 useu -1.09e-05 3.95e-05 CCM at lag: 0 [,1] [,2] [1,] 1.000 -0.258 [2,] -0.258 1.000 Simplified matrix: CCM at lag: 1 . . . . CCM at lag: 2 . . . . CCM at lag: 3 . . - . CCM at lag: 4 . . . . CCM at lag: 5 - . . . CCM at lag: 6 . . . . CCM at lag: 7 . . . . CCM at lag: 8 . - . . CCM at lag: 9 . . . . CCM at lag: 10 . . . . CCM at lag: 11 . . . . CCM at lag: 12 . . . . CCM at lag: 13 . . . . CCM at lag: 14 . . . . CCM at lag: 15 . + + . CCM at lag: 16 . . . . CCM at lag: 17 . . . . CCM at lag: 18 . . . . CCM at lag: 19 . . . . CCM at lag: 20 . . . . CCM at lag: 21 . . . . CCM at lag: 22 . . . . CCM at lag: 23 . . . - CCM at lag: 24 . . . . Hit Enter for p-value plot of individual ccm: Hit Enter to compute MQ-statistics: Ljung-Box Statistics: m Q(m) df p-value [1,] 1.00 1.37 4.00 0.85 [2,] 2.00 3.81 8.00 0.87 [3,] 3.00 10.54 12.00 0.57 [4,] 4.00 15.22 16.00 0.51 [5,] 5.00 27.96 20.00 0.11 [6,] 6.00 28.83 24.00 0.23 [7,] 7.00 30.72 28.00 0.33 [8,] 8.00 37.95 32.00 0.22 [9,] 9.00 39.20 36.00 0.33 [10,] 10.00 44.27 40.00 0.30 [11,] 11.00 45.18 44.00 0.42 [12,] 12.00 52.52 48.00 0.30 [13,] 13.00 57.13 52.00 0.29 [14,] 14.00 58.47 56.00 0.38 [15,] 15.00 69.62 60.00 0.19 [16,] 16.00 73.24 64.00 0.20 [17,] 17.00 75.60 68.00 0.25 [18,] 18.00 77.17 72.00 0.32 [19,] 19.00 85.20 76.00 0.22 [20,] 20.00 91.47 80.00 0.18 [21,] 21.00 94.70 84.00 0.20 [22,] 22.00 97.19 88.00 0.24 [23,] 23.00 106.06 92.00 0.15 [24,] 24.00 106.66 96.00 0.21 Hit Enter to obtain residual plots: #### Problem 3 > da <- read.table("m-m1cnwti.txt") > colnames(da) <- c("m1","wti") > MTSplot(da) > VARorder(da) selected order: aic = 13 selected order: bic = 3 selected order: hq = 3 Summary table: p AIC BIC HQ M(p) p-value [1,] 0 -4.6600 -4.6600 -4.6600 0.0000 0.0000 [2,] 1 -4.9979 -4.9485 -4.9781 103.3453 0.0000 [3,] 2 -5.0163 -4.9175 -4.9768 12.6928 0.0129 [4,] 3 -5.1555 -5.0073 -5.0962 46.3600 0.0000 [5,] 4 -5.1507 -4.9532 -5.0717 6.0751 0.1936 [6,] 5 -5.1371 -4.8902 -5.0383 3.5990 0.4630 [7,] 6 -5.1348 -4.8385 -5.0162 6.6570 0.1552 [8,] 7 -5.1516 -4.8059 -5.0132 11.7915 0.0190 [9,] 8 -5.1278 -4.7327 -4.9696 0.7736 0.9420 [10,] 9 -5.1665 -4.7220 -4.9886 17.4902 0.0016 [11,] 10 -5.1692 -4.6753 -4.9715 7.7943 0.0994 [12,] 11 -5.1484 -4.6051 -4.9310 1.5447 0.8187 [13,] 12 -5.1491 -4.5565 -4.9119 7.1662 0.1274 [14,] 13 -5.1824 -4.5404 -4.9255 15.5661 0.0037 > m3 <- VAR(da,3) Constant term: Estimates: 0.4973633 -0.002715112 Std.Error: 0.1030757 0.008624222 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [1,] 0.66841 0.701 [2,] 0.00347 0.297 standard error [,1] [,2] [1,] 0.05465 0.7026 [2,] 0.00457 0.0588 AR( 2 )-matrix [,1] [,2] [1,] -0.4045 -1.0184 [2,] 0.0075 0.0298 standard error [,1] [,2] [1,] 0.06295 0.7365 [2,] 0.00527 0.0616 AR( 3 )-matrix [,1] [,2] [1,] 0.37999 -0.4399 [2,] -0.00712 -0.0572 standard error [,1] [,2] [1,] 0.05474 0.7154 [2,] 0.00458 0.0599 Residuals cov-mtx: [,1] [,2] [1,] 0.906072927 0.007912593 [2,] 0.007912593 0.006342935 det(SSE) = 0.005684552 AIC = -5.090003 BIC = -4.941852 HQ = -5.030713 > m3a <- refVAR(m3,thres=1.645) Constant term: Estimates: 0.5039224 0 Std.Error: 0.1021361 0 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [1,] 0.671 0.000 [2,] 0.000 0.303 standard error [,1] [,2] [1,] 0.0543 0.0000 [2,] 0.0000 0.0554 AR( 2 )-matrix [,1] [,2] [1,] -0.40934 0 [2,] 0.00964 0 standard error [,1] [,2] [1,] 0.0628 0 [2,] 0.0041 0 AR( 3 )-matrix [,1] [,2] [1,] 0.37498 0 [2,] -0.00794 0 standard error [,1] [,2] [1,] 0.0544 0 [2,] 0.0041 0 Residuals cov-mtx: [,1] [,2] [1,] 0.916215348 0.007959896 [2,] 0.007959896 0.006379513 det(SSE) = 0.005781648 AIC = -5.113067 BIC = -5.038991 HQ = -5.083421 > > MTSdiag(m3a) [1] "Covariance matrix:" m1cn wti m1cn 0.91931 0.00799 wti 0.00799 0.00640 CCM at lag: 0 [,1] [,2] [1,] 1.000 0.104 [2,] 0.104 1.000 Simplified matrix: CCM at lag: 1 . . . . CCM at lag: 2 . . . . CCM at lag: 3 . . . . CCM at lag: 4 - . . . CCM at lag: 5 . . . . CCM at lag: 6 . . . . CCM at lag: 7 . . . . CCM at lag: 8 . . . . CCM at lag: 9 + . . . CCM at lag: 10 . . . . CCM at lag: 11 . . . . CCM at lag: 12 . . . . CCM at lag: 13 . . . . CCM at lag: 14 . . . . CCM at lag: 15 . . . . CCM at lag: 16 . . . . CCM at lag: 17 . . . . CCM at lag: 18 . . . . CCM at lag: 19 . . . . CCM at lag: 20 . . . . CCM at lag: 21 . . . . CCM at lag: 22 . . . . CCM at lag: 23 . . . . CCM at lag: 24 . . . . Hit Enter for p-value plot of individual ccm: Hit Enter to compute MQ-statistics: Ljung-Box Statistics: m Q(m) df p-value [1,] 1.00 1.27 4.00 0.87 [2,] 2.00 2.90 8.00 0.94 [3,] 3.00 6.15 12.00 0.91 [4,] 4.00 16.50 16.00 0.42 [5,] 5.00 18.02 20.00 0.59 [6,] 6.00 27.39 24.00 0.29 [7,] 7.00 31.22 28.00 0.31 [8,] 8.00 32.78 32.00 0.43 [9,] 9.00 38.46 36.00 0.36 [10,] 10.00 45.92 40.00 0.24 [11,] 11.00 48.71 44.00 0.29 [12,] 12.00 54.53 48.00 0.24 [13,] 13.00 60.76 52.00 0.19 [14,] 14.00 64.38 56.00 0.21 [15,] 15.00 66.28 60.00 0.27 [16,] 16.00 71.26 64.00 0.25 [17,] 17.00 73.59 68.00 0.30 [18,] 18.00 75.95 72.00 0.35 [19,] 19.00 79.15 76.00 0.38 [20,] 20.00 81.72 80.00 0.43 [21,] 21.00 82.41 84.00 0.53 [22,] 22.00 83.20 88.00 0.62 [23,] 23.00 85.35 92.00 0.67 [24,] 24.00 88.49 96.00 0.69 Hit Enter to obtain residual plots: > > VARchi(da,p=3,thres=1.645) Number of targeted parameters: 9 Chi-square test and p-value: 10.43494 0.3164348 > VARchi(da,p=3,thres=1.96) Number of targeted parameters: 9 Chi-square test and p-value: 10.43494 0.3164348 > m3b <- refVAR(m3,thres=1.96) Constant term: Estimates: 0.5039224 0 Std.Error: 0.1021361 0 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [1,] 0.671 0.000 [2,] 0.000 0.308 standard error [,1] [,2] [1,] 0.0543 0.0000 [2,] 0.0000 0.0554 AR( 2 )-matrix [,1] [,2] [1,] -0.409 0 [2,] 0.000 0 standard error [,1] [,2] [1,] 0.0628 0 [2,] 0.0000 0 AR( 3 )-matrix [,1] [,2] [1,] 0.375 0 [2,] 0.000 0 standard error [,1] [,2] [1,] 0.0544 0 [2,] 0.0000 0 Residuals cov-mtx: [,1] [,2] [1,] 0.916215348 0.007946284 [2,] 0.007946284 0.006499810 det(SSE) = 0.005892082 AIC = -5.107479 BIC = -5.058095 HQ = -5.087716 > > pm3 <- VARpred(m3a,6) orig 300 Forecasts at origin: 300 m1cn wti 0.4136 0.0343342 1.3494 -0.0009906 1.4891 -0.0015823 1.1061 0.0092457 1.1427 0.0064370 1.3765 0.0007841 Standard Errors of predictions: [,1] [,2] [1,] 0.9572 0.07987 [2,] 1.1528 0.08345 [3,] 1.1535 0.08437 [4,] 1.1599 0.08441 [5,] 1.1999 0.08452 [6,] 1.2119 0.08452 Root mean square errors of predictions: [,1] [,2] [1,] 0.9683 0.08080 [2,] 3.9884 0.16623 [3,] 1.1770 0.11189 [4,] 1.3691 0.08596 [5,] 2.1833 0.08828 [6,] 1.5804 0.08456 > > FEVdec(Phi,Theta=NULL,Sig) Order of the ARMA mdoel: [1] 3 0 Standard deviation of forecast error: [,1] [,2] [,3] [,4] [,5] [1,] 0.95719139 1.15280282 1.15347519 1.15994850 1.19986667 [2,] 0.07987185 0.08345442 0.08436563 0.08440995 0.08451875 Forecast-Error-Variance Decomposition Forecast horizon: 1 [,1] [,2] [1,] 1.00000000 0.00000 [2,] 0.01084001 0.98916 Forecast horizon: 2 [,1] [,2] [1,] 1.00000000 0.00000 [2,] 0.01084001 0.98916 Forecast horizon: 3 [,1] [,2] [1,] 1.00000000 0.0000000 [2,] 0.02463338 0.9753666 Forecast horizon: 4 [,1] [,2] [1,] 1.00000000 0.000000 [2,] 0.02497402 0.975026 Forecast horizon: 5 [,1] [,2] [1,] 1.00000000 0.0000000 [2,] 0.02742021 0.9725798 > ###### Problem 4 > C <- 0.1*diag(7) > V0 <- diag(2) > mm <- BVAR(zt,3,C,V0) Bayesian estimate: Est s.e. t-ratio [1,] 0.497157730 0.101652327 4.8907659 [2,] 0.668375890 0.053915974 12.3966208 [3,] 0.651003893 0.674406032 0.9652996 [4,] -0.404270217 0.062118347 -6.5080646 [5,] -0.958864831 0.704055777 -1.3619160 [6,] 0.379749272 0.054005351 7.0316972 [7,] -0.430367313 0.686120141 -0.6272477 [8,] -0.002919797 0.010514486 -0.2776928 [9,] 0.003571609 0.005576840 0.6404359 [10,] 0.282132455 0.069757700 4.0444632 [11,] 0.007508970 0.006425258 1.1686642 [12,] 0.031590857 0.072824544 0.4337941 [13,] -0.007064755 0.005586084 -1.2647061 [14,] -0.053368618 0.070969358 -0.7519952 Covariance matrix: m1cn wti m1cn 0.904234425 0.007921344 wti 0.007921344 0.009674365 > #### Problem 5 > getSymbols("IPDCONGD",src="FRED") As of 0.4-0, ‘getSymbols’ uses env=parent.frame() and auto.assign=TRUE by default. This behavior will be phased out in 0.5-0 when the call will default to use auto.assign=FALSE. getOption("getSymbols.env") and getOptions("getSymbols.auto.assign") are now checked for alternate defaults This message is shown once per session and may be disabled by setting options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details. [1] "IPDCONGD" > dim(IPDCONGD) [1] 843 1 > getSymbols("IPNCONGD",src="FRED") [1] "IPNCONGD" > getSymbols("IPBUSEQ",src="FRED") [1] "IPBUSEQ" > getSymbols("IPMAT",src="FRED") [1] "IPMAT" > head(IPMAT) IPMAT 1939-01-01 6.5226 1939-02-01 6.6262 1939-03-01 6.6262 1939-04-01 6.4191 1939-05-01 6.3932 1939-06-01 6.7038 > IPMAT[96,] IPMAT 1946-12-01 13.1229 > IPMAT[97,] IPMAT 1947-01-01 13.1229 > tail(IPMAT) IPMAT 2016-10-01 104.7531 2016-11-01 104.7470 2016-12-01 105.2692 2017-01-01 105.2633 2017-02-01 105.6336 2017-03-01 106.0439 > IP <- cbind(as.numeric(IPDCONGD),as.numeric(IPNCONGD),as.numeric(IPBUSEQ),as.numeric(IPMAT[-c(1:96)])) > dim(IP) [1] 843 4 > IP <- IP[-843,] > colnames(IP) <- c("IPD","IPN","IPB","IPM") > zt <- diffM(log(IP)) > dim(zt) [1] 841 4 > tdx <- c(2:842)/12+1947 > MTSplot(zt,tdx) > VARorder(zt) selected order: aic = 6 selected order: bic = 2 selected order: hq = 3 Summary table: p AIC BIC HQ M(p) p-value [1,] 0 -34.7649 -34.7649 -34.7649 0.0000 0.0000 [2,] 1 -35.0417 -34.9516 -35.0072 258.9238 0.0000 [3,] 2 -35.1771 -34.9970 -35.1081 141.9942 0.0000 [4,] 3 -35.2344 -34.9642 -35.1308 77.6365 0.0000 [5,] 4 -35.2321 -34.8718 -35.0940 28.9940 0.0240 [6,] 5 -35.2762 -34.8258 -35.1036 66.2516 0.0000 [7,] 6 -35.2976 -34.7572 -35.0905 47.7129 0.0001 [8,] 7 -35.2736 -34.6431 -35.0319 11.1980 0.7971 [9,] 8 -35.2524 -34.5318 -34.9762 13.3868 0.6443 [10,] 9 -35.2417 -34.4310 -34.9310 21.6101 0.1562 [11,] 10 -35.2403 -34.3395 -34.8951 28.8546 0.0249 [12,] 11 -35.2292 -34.2384 -34.8495 21.1066 0.1745 [13,] 12 -35.2544 -34.1735 -34.8402 49.2340 0.0000 [14,] 13 -35.2512 -34.0802 -34.8024 26.9722 0.0418 > m5 <- VAR(zt,6) Constant term: Estimates: 0.001490624 0.001582 0.0005583526 0.0008871447 Std.Error: 0.00099642 0.0003103936 0.0004558711 0.0005856182 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [,3] [,4] [1,] -0.023204 0.2021 -0.14852 0.489 [2,] 0.028908 -0.1649 0.00171 0.012 [3,] -0.011488 0.0461 -0.02312 0.272 [4,] 0.000826 0.1285 0.02474 0.212 standard error [,1] [,2] [,3] [,4] [1,] 0.0415 0.1170 0.0925 0.0678 [2,] 0.0129 0.0365 0.0288 0.0211 [3,] 0.0190 0.0535 0.0423 0.0310 [4,] 0.0244 0.0688 0.0543 0.0398 AR( 2 )-matrix [,1] [,2] [,3] [,4] [1,] -0.0564 0.3081 -0.0356 0.1514 [2,] 0.0255 -0.0331 -0.0043 -0.0141 [3,] -0.0320 0.1275 0.1189 0.1061 [4,] 0.0658 0.1705 0.1373 -0.1166 standard error [,1] [,2] [,3] [,4] [1,] 0.0413 0.1194 0.0916 0.0698 [2,] 0.0129 0.0372 0.0285 0.0217 [3,] 0.0189 0.0546 0.0419 0.0319 [4,] 0.0243 0.0702 0.0539 0.0410 AR( 3 )-matrix [,1] [,2] [,3] [,4] [1,] -0.000499 0.0316 -0.00975 0.05086 [2,] 0.030596 0.0143 -0.04021 -0.00593 [3,] -0.033841 0.0164 0.12792 0.09189 [4,] 0.032528 0.1344 0.02991 -0.04544 standard error [,1] [,2] [,3] [,4] [1,] 0.0417 0.1199 0.0920 0.0710 [2,] 0.0130 0.0374 0.0287 0.0221 [3,] 0.0191 0.0549 0.0421 0.0325 [4,] 0.0245 0.0705 0.0541 0.0417 AR( 4 )-matrix [,1] [,2] [,3] [,4] [1,] -0.05613 0.1192 0.01130 0.1000 [2,] 0.00925 0.0663 0.00236 -0.0116 [3,] -0.02906 0.0628 0.05131 0.0583 [4,] 0.05739 0.0541 0.03433 -0.0322 standard error [,1] [,2] [,3] [,4] [1,] 0.0418 0.1198 0.0904 0.0705 [2,] 0.0130 0.0373 0.0282 0.0220 [3,] 0.0191 0.0548 0.0414 0.0323 [4,] 0.0246 0.0704 0.0531 0.0414 AR( 5 )-matrix [,1] [,2] [,3] [,4] [1,] -0.01920 0.0904 -0.17273 -0.0328 [2,] -0.00651 0.0425 -0.01866 0.0361 [3,] -0.01597 0.0185 0.02855 0.0477 [4,] 0.07263 0.0143 -0.00429 -0.2150 standard error [,1] [,2] [,3] [,4] [1,] 0.0416 0.1196 0.0882 0.0690 [2,] 0.0130 0.0373 0.0275 0.0215 [3,] 0.0190 0.0547 0.0404 0.0316 [4,] 0.0245 0.0703 0.0518 0.0405 AR( 6 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0619 0.0235 -0.2535 0.04843 [2,] 0.0121 0.0325 0.0567 -0.02442 [3,] -0.0127 -0.0424 0.1062 -0.00819 [4,] 0.0446 -0.0121 -0.0310 -0.04264 standard error [,1] [,2] [,3] [,4] [1,] 0.0411 0.1170 0.0873 0.0705 [2,] 0.0128 0.0365 0.0272 0.0220 [3,] 0.0188 0.0535 0.0399 0.0323 [4,] 0.0242 0.0688 0.0513 0.0414 Residuals cov-mtx: [,1] [,2] [,3] [,4] [1,] 5.621052e-04 4.349859e-05 1.302483e-04 1.258815e-04 [2,] 4.349859e-05 5.454543e-05 1.862442e-05 1.975902e-05 [3,] 1.302483e-04 1.862442e-05 1.176567e-04 6.522420e-05 [4,] 1.258815e-04 1.975902e-05 6.522420e-05 1.941609e-04 det(SSE) = 3.719934e-16 AIC = -35.29936 BIC = -34.7589 HQ = -35.09223 > VARchi(zt,6,thres=1.645) Number of targeted parameters: 65 Chi-square test and p-value: 58.36281 0.706841 > VARchi(zt,6,thres=1.96) Number of targeted parameters: 75 Chi-square test and p-value: 109.1046 0.006196542 > m5a <- refVAR(m5,thres=1.645) Constant term: Estimates: 0.002180497 0.001627507 0.000811527 0.0009364766 Std.Error: 0.0008985697 0.0002831724 0.0004122807 0.0005414143 AR coefficient matrix AR( 1 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0000 0.000 0 0.467 [2,] 0.0321 -0.156 0 0.000 [3,] 0.0000 0.000 0 0.263 [4,] 0.0000 0.130 0 0.241 standard error [,1] [,2] [,3] [,4] [1,] 0.0000 0.0000 0 0.0551 [2,] 0.0106 0.0350 0 0.0000 [3,] 0.0000 0.0000 0 0.0264 [4,] 0.0000 0.0664 0 0.0344 AR( 2 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0000 0.258 0.000 0.0000 [2,] 0.0187 0.000 0.000 0.0000 [3,] -0.0352 0.103 0.155 0.0926 [4,] 0.0613 0.180 0.129 -0.1067 standard error [,1] [,2] [,3] [,4] [1,] 0.0000 0.1101 0.0000 0.0000 [2,] 0.0104 0.0000 0.0000 0.0000 [3,] 0.0184 0.0522 0.0391 0.0300 [4,] 0.0231 0.0690 0.0468 0.0386 AR( 3 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0000 0.000 0.000 0.000 [2,] 0.0341 0.000 -0.042 0.000 [3,] -0.0339 0.000 0.154 0.075 [4,] 0.0000 0.154 0.000 0.000 standard error [,1] [,2] [,3] [,4] [1,] 0.0000 0.0000 0.0000 0.000 [2,] 0.0119 0.0000 0.0244 0.000 [3,] 0.0183 0.0000 0.0392 0.031 [4,] 0.0000 0.0663 0.0000 0.000 AR( 4 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0000 0.0000 0 0.0000 [2,] 0.0000 0.0633 0 0.0000 [3,] 0.0000 0.0000 0 0.0576 [4,] 0.0605 0.0000 0 0.0000 standard error [,1] [,2] [,3] [,4] [1,] 0.0000 0.0000 0 0.0000 [2,] 0.0000 0.0344 0 0.0000 [3,] 0.0000 0.0000 0 0.0278 [4,] 0.0204 0.0000 0 0.0000 AR( 5 )-matrix [,1] [,2] [,3] [,4] [1,] 0.000 0 -0.186 0.000 [2,] 0.000 0 0.000 0.000 [3,] 0.000 0 0.000 0.000 [4,] 0.065 0 0.000 -0.201 standard error [,1] [,2] [,3] [,4] [1,] 0.0000 0 0.0672 0.0000 [2,] 0.0000 0 0.0000 0.0000 [3,] 0.0000 0 0.0000 0.0000 [4,] 0.0213 0 0.0000 0.0374 AR( 6 )-matrix [,1] [,2] [,3] [,4] [1,] 0.0865 0 -0.2466 0 [2,] 0.0000 0 0.0568 0 [3,] 0.0000 0 0.1020 0 [4,] 0.0000 0 0.0000 0 standard error [,1] [,2] [,3] [,4] [1,] 0.0375 0 0.0760 0 [2,] 0.0000 0 0.0215 0 [3,] 0.0000 0 0.0322 0 [4,] 0.0000 0 0.0000 0 Residuals cov-mtx: [,1] [,2] [,3] [,4] [1,] 5.717863e-04 4.273569e-05 1.314637e-04 1.256718e-04 [2,] 4.273569e-05 5.526466e-05 1.870234e-05 2.002090e-05 [3,] 1.314637e-04 1.870234e-05 1.191592e-04 6.524236e-05 [4,] 1.256718e-04 2.002090e-05 6.524236e-05 1.959994e-04 det(SSE) = 3.970927e-16 AIC = -35.38626 BIC = -35.20611 HQ = -35.31722 > MTSdiag(m5a) [1] "Covariance matrix:" IPD IPN IPB IPM IPD 5.72e-04 4.28e-05 1.32e-04 1.26e-04 IPN 4.28e-05 5.53e-05 1.87e-05 2.00e-05 IPB 1.32e-04 1.87e-05 1.19e-04 6.53e-05 IPM 1.26e-04 2.00e-05 6.53e-05 1.96e-04 CCM at lag: 0 [,1] [,2] [,3] [,4] [1,] 1.000 0.240 0.504 0.375 [2,] 0.240 1.000 0.230 0.192 [3,] 0.504 0.230 1.000 0.427 [4,] 0.375 0.192 0.427 1.000 Simplified matrix: CCM at lag: 1 . . . . . . . . . . . . . . . . CCM at lag: 2 . . . . . . . . . . . . . . . . CCM at lag: 3 . . . . . . . . . . . . . . . . CCM at lag: 4 . . . . . . . . . . . . . . . . CCM at lag: 5 . . . . . . . . . . . . . . . . CCM at lag: 6 . . . . . . . . . . . . . . . . CCM at lag: 7 . . . . . . . . . . . . . . . . CCM at lag: 8 . . . . . . . . . . . . . . . . CCM at lag: 9 . . . . . + . . . . . . . . . . CCM at lag: 10 . . . . . . . . . + . . + + . . CCM at lag: 11 . . . . . . . . . . . + + . . . CCM at lag: 12 . . - - . . . . . . - . . . - - CCM at lag: 13 - . . . . . . . . . . . . . . . CCM at lag: 14 . . . . . . . . . . . . - . - - CCM at lag: 15 . . . . . . . . . . . . - . . . CCM at lag: 16 - . . . . . . . . . . . - . . . CCM at lag: 17 . . . . . + . . . . . . . . . . CCM at lag: 18 . . . . . . . . + . . . . . . + CCM at lag: 19 . . . . . . . . . . . . . . . . CCM at lag: 20 . . . . . . . . . . . . . . . . CCM at lag: 21 . . . . . . . . . . . . . . . . CCM at lag: 22 . . . . . + . + . . . . . . . . CCM at lag: 23 . . . . . + . . . . . . . . . . CCM at lag: 24 - . . . . - . - . - - . - . - - Hit Enter for p-value plot of individual ccm: Hit Enter to compute MQ-statistics: Ljung-Box Statistics: m Q(m) df p-value [1,] 1.00 9.51 16.00 0.89 [2,] 2.00 16.55 32.00 0.99 [3,] 3.00 21.22 48.00 1.00 [4,] 4.00 29.68 64.00 1.00 [5,] 5.00 41.89 80.00 1.00 [6,] 6.00 54.02 96.00 1.00 [7,] 7.00 67.86 112.00 1.00 [8,] 8.00 85.87 128.00 1.00 [9,] 9.00 97.57 144.00 1.00 [10,] 10.00 122.73 160.00 0.99 [11,] 11.00 144.54 176.00 0.96 [12,] 12.00 177.79 192.00 0.76 [13,] 13.00 195.39 208.00 0.73 [14,] 14.00 220.51 224.00 0.55 [15,] 15.00 234.62 240.00 0.59 [16,] 16.00 260.44 256.00 0.41 [17,] 17.00 273.47 272.00 0.46 [18,] 18.00 303.15 288.00 0.26 [19,] 19.00 319.16 304.00 0.26 [20,] 20.00 329.03 320.00 0.35 [21,] 21.00 339.25 336.00 0.44 [22,] 22.00 366.79 352.00 0.28 [23,] 23.00 384.43 368.00 0.27 [24,] 24.00 417.26 384.00 0.12 Hit Enter to obtain residual plots: > pm5 <- VARpred(m5a,6) orig 841 Forecasts at origin: 841 IPD IPN IPB IPM [1,] 0.0002026 0.0026438 0.0017839 -0.0005003 [2,] -0.0005239 0.0024459 0.0005728 -0.0029292 [3,] -0.0007611 0.0003467 0.0007994 -0.0006600 [4,] 0.0010723 0.0013364 0.0020675 0.0022444 [5,] 0.0031437 0.0015586 0.0013713 0.0017264 [6,] 0.0029698 0.0016709 0.0019473 0.0020238 Standard Errors of predictions: [,1] [,2] [,3] [,4] [1,] 0.02391 0.007434 0.01092 0.01400 [2,] 0.02479 0.007534 0.01152 0.01448 [3,] 0.02498 0.007553 0.01198 0.01479 [4,] 0.02502 0.007586 0.01235 0.01489 [5,] 0.02504 0.007605 0.01256 0.01503 [6,] 0.02510 0.007606 0.01269 0.01521 Root mean square errors of predictions: [,1] [,2] [,3] [,4] [1,] 0.02426 0.007544 0.01108 0.01421 [2,] 0.09065 0.018003 0.05041 0.05122 [3,] 0.04821 0.010327 0.04573 0.04296 [4,] 0.03126 0.012094 0.04157 0.02795 [5,] 0.02808 0.010514 0.03333 0.03101 [6,] 0.03429 0.007830 0.02685 0.03484 > names(pm5) [1] "pred" "se.err" "mse" > lcl <- pm5$pred-1.96*pm5$se.err > ucl <- pm5$pred+1.96*pm5$se.err > lcl IPD IPN IPB IPM [1,] -0.04666505 -0.01192693 -0.01961151 -0.02794026 [2,] -0.04910847 -0.01232123 -0.02200341 -0.03130158 [3,] -0.04972142 -0.01445663 -0.02268828 -0.02964383 [4,] -0.04796521 -0.01353142 -0.02213228 -0.02694667 [5,] -0.04592923 -0.01334729 -0.02324942 -0.02773497 [6,] -0.04622290 -0.01323757 -0.02291735 -0.02779496 > ucl IPD IPN IPB IPM [1,] 0.04707020 0.01721443 0.02317923 0.02693965 [2,] 0.04806072 0.01721305 0.02314896 0.02544325 [3,] 0.04819916 0.01514998 0.02428708 0.02832382 [4,] 0.05010977 0.01620412 0.02626738 0.03143551 [5,] 0.05221672 0.01646456 0.02599205 0.03118783 [6,] 0.05216250 0.01657928 0.02681191 0.03184250 >