library(vars)
## Loading required package: MASS
## Loading required package: strucchange
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: urca
## Loading required package: lmtest
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(urca)
library(tseries)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.2 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x stringr::boundary() masks strucchange::boundary()
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::select() masks MASS::select()
library(dplyr)
library(VARsignR)
library(ggplot2)
library(lpirfs)
vardat = read.csv("C:\\\\Users\\\\cthom\\\\OneDrive\\\\Boston College\\\\Econometrics\\\\stressvar.csv")
vardata = ts(vardat, start=c(2012,1), frequency = 4)
vardata
## ï..SP500 GDP X10y.3m Unemp IndPro PCE
## 2012 Q1 1348.784 16068.82 1.969 8.267 96.800 10959.30
## 2012 Q2 1349.679 16207.13 1.738 8.200 97.413 11005.03
## 2012 Q3 1400.943 16319.54 1.540 8.033 97.397 11059.37
## 2012 Q4 1418.139 16420.39 1.617 7.800 97.910 11165.67
## 2013 Q1 1513.980 16629.05 1.865 7.733 98.624 11265.60
## 2013 Q2 1609.491 16699.55 1.935 7.533 99.091 11290.97
## 2013 Q3 1674.944 16911.07 2.674 7.233 99.492 11379.20
## 2013 Q4 1768.667 17133.11 2.684 6.933 100.153 11518.37
## 2014 Q1 1834.871 17144.28 2.716 6.667 100.869 11618.10
## 2014 Q2 1900.373 17462.70 2.588 6.200 102.213 11784.67
## 2014 Q3 1975.908 17743.23 2.473 6.067 102.828 11934.30
## 2014 Q4 2009.344 17852.54 2.253 5.700 103.424 12053.83
## 2015 Q1 2063.690 17991.35 1.944 5.533 102.324 12083.93
## 2015 Q2 2101.829 18193.71 2.146 5.433 100.878 12224.73
## 2015 Q3 2027.200 18306.96 2.180 5.100 100.888 12347.73
## 2015 Q4 2052.312 18332.08 2.065 5.033 99.467 12397.53
## 2016 Q1 1951.225 18425.31 1.624 4.900 98.878 12495.07
## 2016 Q2 2075.132 18611.62 1.491 4.933 98.492 12637.37
## 2016 Q3 2162.057 18775.46 1.266 4.900 98.743 12759.07
## 2016 Q4 2184.879 18968.04 1.705 4.767 98.598 12881.53
## 2017 Q1 2325.928 19153.91 1.840 4.567 98.740 13046.47
## 2017 Q2 2397.971 19322.92 1.353 4.400 100.163 13144.40
## 2017 Q3 2467.175 19558.69 1.187 4.300 99.888 13268.13
## 2017 Q4 2603.277 19882.97 1.145 4.133 101.210 13497.43
## 2018 Q1 2733.477 20143.72 1.176 4.033 101.768 13667.43
## 2018 Q2 2703.131 20492.49 1.046 3.933 103.085 13864.77
## 2018 Q3 2849.601 20659.10 0.849 3.767 103.948 14002.60
## 2018 Q4 2698.926 20813.33 0.684 3.833 103.922 14119.33
## 2019 Q1 2721.004 21001.59 0.214 3.867 102.965 14155.57
## 2019 Q2 2882.328 21289.27 -0.016 3.667 102.363 14375.73
## 2019 Q3 2957.853 21505.01 -0.228 3.600 102.353 14529.50
## 2019 Q4 3082.756 21694.46 0.184 3.600 101.690 14653.93
## 2020 Q1 3055.869 21481.37 0.261 3.800 99.955 14439.07
## 2020 Q2 2931.688 19477.44 0.545 13.067 87.069 12989.73
## 2020 Q3 3319.834 21138.57 0.537 8.800 95.461 14293.80
## 2020 Q4 3554.502 21477.60 0.772 6.767 97.364 14467.60
## 2021 Q1 3865.707 22038.23 1.285 6.167 98.240 15005.47
## 2021 Q2 4183.626 22722.58 1.566 5.933 99.572 15672.60
colnames(vardata)
## [1] "ï..SP500" "GDP" "X10y.3m" "Unemp" "IndPro" "PCE"
autoplot(vardata)
VARselect(vardata, lag.max=8, type="const")
## $selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 5 5 5 5
##
## $criteria
## 1 2 3 4 5 6 7 8
## AIC(n) 2.392460e+01 2.205283e+01 1.929844e+01 -1.709548e+01 -Inf -Inf -Inf -Inf
## HQ(n) 2.455216e+01 2.321829e+01 2.100181e+01 -1.485420e+01 -Inf -Inf -Inf -Inf
## SC(n) 2.588627e+01 2.569594e+01 2.462299e+01 -1.008949e+01 -Inf -Inf -Inf -Inf
## FPE(n) 2.589045e+10 5.460179e+09 9.405621e+08 3.026490e-06 0 0 0 0
var1 = VAR(vardata, p=2, type="const", season=NULL, exog=NULL)
summary(var1)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: ï..SP500, GDP, X10y.3m, Unemp, IndPro, PCE
## Deterministic variables: const
## Sample size: 36
## Log Likelihood: -643.786
## Roots of the characteristic polynomial:
## 1.203 1.203 1.05 0.7977 0.7977 0.7011 0.6421 0.6421 0.5137 0.5137 0.4321 0.4321
## Call:
## VAR(y = vardata, p = 2, type = "const", exogen = NULL)
##
##
## Estimation results for equation ï..SP500:
## =========================================
## ï..SP500 = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 8.386e-01 2.522e-01 3.325 0.00295 **
## GDP.l1 1.358e-01 3.211e-01 0.423 0.67620
## X10y.3m.l1 3.309e+01 7.660e+01 0.432 0.66980
## Unemp.l1 7.371e+01 3.614e+01 2.040 0.05303 .
## IndPro.l1 -2.347e+01 2.588e+01 -0.907 0.37393
## PCE.l1 2.095e-01 4.308e-01 0.486 0.63138
## ï..SP500.l2 8.153e-02 3.078e-01 0.265 0.79343
## GDP.l2 -6.502e-01 3.185e-01 -2.041 0.05284 .
## X10y.3m.l2 5.537e+01 6.827e+01 0.811 0.42563
## Unemp.l2 -1.558e-01 4.377e+01 -0.004 0.99719
## IndPro.l2 2.214e+01 2.867e+01 0.772 0.44799
## PCE.l2 7.150e-01 3.875e-01 1.845 0.07789 .
## const -2.278e+03 3.132e+03 -0.727 0.47436
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 85.61 on 23 degrees of freedom
## Multiple R-Squared: 0.9894, Adjusted R-squared: 0.9839
## F-statistic: 179.3 on 12 and 23 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation GDP:
## ====================================
## GDP = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 5.499e-01 1.069e+00 0.514 0.61202
## GDP.l1 4.485e-02 1.361e+00 0.033 0.97400
## X10y.3m.l1 -6.582e+01 3.248e+02 -0.203 0.84116
## Unemp.l1 4.977e+02 1.532e+02 3.248 0.00354 **
## IndPro.l1 -9.621e+01 1.097e+02 -0.877 0.38964
## PCE.l1 3.600e+00 1.827e+00 1.971 0.06090 .
## ï..SP500.l2 -1.122e+00 1.305e+00 -0.860 0.39889
## GDP.l2 -1.913e+00 1.350e+00 -1.416 0.17010
## X10y.3m.l2 4.883e+02 2.894e+02 1.687 0.10512
## Unemp.l2 -1.544e+02 1.856e+02 -0.832 0.41405
## IndPro.l2 1.759e+02 1.216e+02 1.447 0.16138
## PCE.l2 1.319e+00 1.643e+00 0.803 0.43021
## const -1.798e+04 1.328e+04 -1.354 0.18891
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 363 on 23 degrees of freedom
## Multiple R-Squared: 0.974, Adjusted R-squared: 0.9604
## F-statistic: 71.78 on 12 and 23 DF, p-value: 2.745e-15
##
##
## Estimation results for equation X10y.3m:
## ========================================
## X10y.3m = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 0.0018203 0.0006176 2.947 0.00723 **
## GDP.l1 0.0002442 0.0007861 0.311 0.75890
## X10y.3m.l1 0.6897996 0.1875464 3.678 0.00125 **
## Unemp.l1 -0.2646757 0.0884826 -2.991 0.00652 **
## IndPro.l1 0.0354424 0.0633649 0.559 0.58134
## PCE.l1 -0.0022384 0.0010548 -2.122 0.04481 *
## ï..SP500.l2 0.0008019 0.0007535 1.064 0.29828
## GDP.l2 0.0003304 0.0007799 0.424 0.67575
## X10y.3m.l2 -0.4541397 0.1671559 -2.717 0.01230 *
## Unemp.l2 -0.0408263 0.1071747 -0.381 0.70675
## IndPro.l2 -0.0914318 0.0702111 -1.302 0.20572
## PCE.l2 -0.0005199 0.0009487 -0.548 0.58897
## const 26.9161436 7.6685005 3.510 0.00188 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.2096 on 23 degrees of freedom
## Multiple R-Squared: 0.956, Adjusted R-squared: 0.933
## F-statistic: 41.64 on 12 and 23 DF, p-value: 1.067e-12
##
##
## Estimation results for equation Unemp:
## ======================================
## Unemp = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 -0.0001586 0.0044073 -0.036 0.9716
## GDP.l1 0.0001341 0.0056099 0.024 0.9811
## X10y.3m.l1 -0.1555722 1.3383437 -0.116 0.9085
## Unemp.l1 -1.1839142 0.6314176 -1.875 0.0735 .
## IndPro.l1 0.2340491 0.4521760 0.518 0.6097
## PCE.l1 -0.0109379 0.0075273 -1.453 0.1597
## ï..SP500.l2 0.0059429 0.0053773 1.105 0.2805
## GDP.l2 0.0054736 0.0055651 0.984 0.3356
## X10y.3m.l2 -1.6704361 1.1928358 -1.400 0.1747
## Unemp.l2 0.8124874 0.7648060 1.062 0.2991
## IndPro.l2 -0.5081121 0.5010311 -1.014 0.3211
## PCE.l2 -0.0016329 0.0067699 -0.241 0.8115
## const 80.3908802 54.7229395 1.469 0.1554
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 1.496 on 23 degrees of freedom
## Multiple R-Squared: 0.6093, Adjusted R-squared: 0.4055
## F-statistic: 2.989 on 12 and 23 DF, p-value: 0.01162
##
##
## Estimation results for equation IndPro:
## =======================================
## IndPro = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 3.294e-03 5.899e-03 0.558 0.582016
## GDP.l1 -1.543e-03 7.509e-03 -0.205 0.839000
## X10y.3m.l1 8.669e-01 1.791e+00 0.484 0.633011
## Unemp.l1 3.553e+00 8.452e-01 4.204 0.000339 ***
## IndPro.l1 8.157e-01 6.053e-01 1.348 0.190911
## PCE.l1 1.671e-02 1.008e-02 1.659 0.110780
## ï..SP500.l2 -1.078e-02 7.198e-03 -1.497 0.147940
## GDP.l2 -1.042e-02 7.449e-03 -1.399 0.175302
## X10y.3m.l2 2.003e+00 1.597e+00 1.254 0.222293
## Unemp.l2 -1.667e+00 1.024e+00 -1.628 0.117079
## IndPro.l2 5.100e-01 6.707e-01 0.760 0.454701
## PCE.l2 6.806e-03 9.062e-03 0.751 0.460206
## const -1.065e+02 7.325e+01 -1.454 0.159410
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 2.002 on 23 degrees of freedom
## Multiple R-Squared: 0.713, Adjusted R-squared: 0.5633
## F-statistic: 4.763 on 12 and 23 DF, p-value: 0.0006612
##
##
## Estimation results for equation PCE:
## ====================================
## PCE = ï..SP500.l1 + GDP.l1 + X10y.3m.l1 + Unemp.l1 + IndPro.l1 + PCE.l1 + ï..SP500.l2 + GDP.l2 + X10y.3m.l2 + Unemp.l2 + IndPro.l2 + PCE.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## ï..SP500.l1 5.504e-01 7.883e-01 0.698 0.49205
## GDP.l1 -5.501e-01 1.003e+00 -0.548 0.58882
## X10y.3m.l1 -3.422e+01 2.394e+02 -0.143 0.88756
## Unemp.l1 3.319e+02 1.129e+02 2.939 0.00738 **
## IndPro.l1 -1.122e+02 8.088e+01 -1.388 0.17858
## PCE.l1 3.488e+00 1.346e+00 2.591 0.01635 *
## ï..SP500.l2 -8.427e-01 9.618e-01 -0.876 0.39003
## GDP.l2 -1.647e+00 9.954e-01 -1.654 0.11164
## X10y.3m.l2 3.789e+02 2.134e+02 1.776 0.08895 .
## Unemp.l2 -7.969e+01 1.368e+02 -0.583 0.56586
## IndPro.l2 1.649e+02 8.962e+01 1.841 0.07862 .
## PCE.l2 1.223e+00 1.211e+00 1.010 0.32299
## const -1.253e+04 9.788e+03 -1.280 0.21328
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 267.6 on 23 degrees of freedom
## Multiple R-Squared: 0.9701, Adjusted R-squared: 0.9546
## F-statistic: 62.27 on 12 and 23 DF, p-value: 1.319e-14
##
##
##
## Covariance matrix of residuals:
## ï..SP500 GDP X10y.3m Unemp IndPro PCE
## ï..SP500 7329.533 15831.9 6.64138 -48.71136 71.16076 12304.790
## GDP 15831.948 131757.7 10.30027 -522.45277 692.65210 95543.159
## X10y.3m 6.641 10.3 0.04394 -0.02051 0.01261 9.314
## Unemp -48.711 -522.5 -0.02051 2.23770 -2.83777 -378.456
## IndPro 71.161 692.7 0.01261 -2.83777 4.00941 507.133
## PCE 12304.790 95543.2 9.31406 -378.45644 507.13346 71591.526
##
## Correlation matrix of residuals:
## ï..SP500 GDP X10y.3m Unemp IndPro PCE
## ï..SP500 1.0000 0.5095 0.37007 -0.38036 0.41511 0.5372
## GDP 0.5095 1.0000 0.13537 -0.96218 0.95299 0.9837
## X10y.3m 0.3701 0.1354 1.00000 -0.06541 0.03005 0.1661
## Unemp -0.3804 -0.9622 -0.06541 1.00000 -0.94741 -0.9455
## IndPro 0.4151 0.9530 0.03005 -0.94741 1.00000 0.9466
## PCE 0.5372 0.9837 0.16606 -0.94555 0.94657 1.0000
plot(var1)
#The performance of the models looks good! The R-squared of the models is high, and they graphically follow the data well. The residuals are normal and spike around covid, which the models were able to quickly adjust to.
var1.serial = serial.test(var1, lags.pt=8, type="PT.asymptotic")
var1.serial
##
## Portmanteau Test (asymptotic)
##
## data: Residuals of VAR object var1
## Chi-squared = 252.03, df = 216, p-value = 0.04674
var1.predict = predict(var1)
var1.predict
## $ï..SP500
## fcst lower upper CI
## [1,] 4712.001 4544.2029 4879.799 167.7978
## [2,] 5255.200 5009.2135 5501.186 245.9861
## [3,] 5671.998 5341.6077 6002.389 330.3907
## [4,] 5972.742 5552.0050 6393.478 420.7366
## [5,] 6054.864 5537.7110 6572.017 517.1531
## [6,] 5808.626 5197.7318 6419.521 610.8946
## [7,] 5191.361 4492.3569 5890.365 699.0039
## [8,] 4199.101 3401.7603 4996.442 797.3409
## [9,] 2901.505 1973.9109 3829.099 927.5939
## [10,] 1474.378 367.2893 2581.466 1107.0883
##
## $GDP
## fcst lower upper CI
## [1,] 25294.42 24582.99 26005.86 711.4365
## [2,] 28277.06 27334.37 29219.74 942.6867
## [3,] 31448.48 30202.94 32694.01 1245.5339
## [4,] 34991.76 33250.30 36733.22 1741.4595
## [5,] 38114.22 35734.19 40494.26 2380.0350
## [6,] 40022.45 36964.65 43080.26 3057.8048
## [7,] 40062.92 36343.94 43781.90 3718.9810
## [8,] 37442.69 33094.06 41791.32 4348.6291
## [9,] 31609.38 26642.29 36576.47 4967.0853
## [10,] 22509.09 16807.82 28210.35 5701.2625
##
## $X10y.3m
## fcst lower upper CI
## [1,] 0.7989865 0.3881301 1.20984281 0.4108564
## [2,] -0.6229826 -1.1988293 -0.04713584 0.5758467
## [3,] -2.5380687 -3.3054736 -1.77066383 0.7674049
## [4,] -5.1241668 -6.1477203 -4.10061320 1.0235536
## [5,] -8.2639121 -9.6424027 -6.88542160 1.3784906
## [6,] -11.5215014 -13.3747891 -9.66821370 1.8532877
## [7,] -14.3285502 -16.7601510 -11.89694935 2.4316008
## [8,] -15.9676838 -19.0263355 -12.90903209 3.0586517
## [9,] -15.6331118 -19.3070923 -11.95913127 3.6739805
## [10,] -12.5822470 -16.8264451 -8.33804897 4.2441981
##
## $Unemp
## fcst lower upper CI
## [1,] -0.5669071 -3.498806 2.364992 2.931899
## [2,] -8.6045790 -12.169126 -5.040032 3.564547
## [3,] -16.0177589 -20.272788 -11.762730 4.255029
## [4,] -24.1877828 -29.625290 -18.750275 5.437507
## [5,] -31.0787321 -37.980073 -24.177391 6.901341
## [6,] -34.0310955 -42.474053 -25.588138 8.442958
## [7,] -31.4107735 -41.319358 -21.502189 9.908584
## [8,] -21.2446406 -32.536561 -9.952720 11.291921
## [9,] -2.1356080 -14.894622 10.623406 12.759014
## [10,] 25.7114739 10.947873 40.475075 14.763601
##
## $IndPro
## fcst lower upper CI
## [1,] 111.04764 107.12311 114.97218 3.924536
## [2,] 123.66360 118.31563 129.01157 5.347970
## [3,] 135.16942 128.37498 141.96386 6.794442
## [4,] 147.50006 138.65080 156.34931 8.849256
## [5,] 156.81366 145.46047 168.16685 11.353192
## [6,] 159.03878 145.16334 172.91423 13.875447
## [7,] 151.69545 135.52339 167.86751 16.172064
## [8,] 131.82128 113.49399 150.14857 18.327287
## [9,] 97.76774 77.04070 118.49478 20.727038
## [10,] 50.61157 26.37926 74.84389 24.232313
##
## $PCE
## fcst lower upper CI
## [1,] 17684.76 17160.342 18209.18 524.4196
## [2,] 19926.31 19195.463 20657.15 730.8454
## [3,] 22269.07 21278.043 23260.09 991.0252
## [4,] 24794.20 23410.824 26177.57 1383.3727
## [5,] 26865.87 25005.637 28726.10 1860.2331
## [6,] 27899.66 25549.949 30249.37 2349.7120
## [7,] 27420.47 24604.678 30236.26 2815.7913
## [8,] 24874.23 21614.624 28133.84 3259.6065
## [9,] 19932.31 16216.780 23647.83 3715.5257
## [10,] 12669.16 8369.467 16968.85 4299.6919
plot(var1.predict)
impulse = irf(var1, response = "ï..SP500", n.ahead=8, boot = FALSE, runs=100, cumulative = FALSE)
impulse
##
## Impulse response coefficients
## $ï..SP500
## ï..SP500
## [1,] 85.61269
## [2,] 68.14450
## [3,] 56.58738
## [4,] 74.26402
## [5,] 70.91285
## [6,] 46.54385
## [7,] 17.16049
## [8,] -24.16848
## [9,] -78.96095
##
## $GDP
## ï..SP500
## [1,] 0.00000
## [2,] -50.70098
## [3,] -86.44201
## [4,] -98.88606
## [5,] -126.86091
## [6,] -146.11271
## [7,] -142.48730
## [8,] -122.02130
## [9,] -77.43604
##
## $X10y.3m
## ï..SP500
## [1,] 0.000000
## [2,] 13.497993
## [3,] 21.612891
## [4,] 22.012904
## [5,] 15.258602
## [6,] 4.432736
## [7,] -12.196935
## [8,] -36.114620
## [9,] -65.586404
##
## $Unemp
## ï..SP500
## [1,] 0.000000
## [2,] 28.907462
## [3,] 7.825832
## [4,] -13.068555
## [5,] -18.793991
## [6,] -29.024400
## [7,] -36.674973
## [8,] -32.593967
## [9,] -19.291601
##
## $IndPro
## ï..SP500
## [1,] 0.000000
## [2,] -10.161542
## [3,] -8.603609
## [4,] -20.807436
## [5,] -39.363501
## [6,] -54.550259
## [7,] -65.884853
## [8,] -73.554348
## [9,] -72.380023
##
## $PCE
## ï..SP500
## [1,] 0.000000
## [2,] 9.312727
## [3,] 37.248010
## [4,] 35.827223
## [5,] 16.798674
## [6,] -13.199275
## [7,] -60.105053
## [8,] -122.697074
## [9,] -190.640709
var1.impulse = as.data.frame(impulse$irf)
colnames(var1.impulse) =c("Sp500", "GDP", "int_spread", "Unemp", "IndPro", "PCE")
var1.impulse
## Sp500 GDP int_spread Unemp IndPro PCE
## 1 85.61269 0.00000 0.000000 0.000000 0.000000 0.000000
## 2 68.14450 -50.70098 13.497993 28.907462 -10.161542 9.312727
## 3 56.58738 -86.44201 21.612891 7.825832 -8.603609 37.248010
## 4 74.26402 -98.88606 22.012904 -13.068555 -20.807436 35.827223
## 5 70.91285 -126.86091 15.258602 -18.793991 -39.363501 16.798674
## 6 46.54385 -146.11271 4.432736 -29.024400 -54.550259 -13.199275
## 7 17.16049 -142.48730 -12.196935 -36.674973 -65.884853 -60.105053
## 8 -24.16848 -122.02130 -36.114620 -32.593967 -73.554348 -122.697074
## 9 -78.96095 -77.43604 -65.586404 -19.291601 -72.380023 -190.640709
plot(var1.impulse$Sp500, type="l", col="blue", ylim=c(-150,100), lwd=5)
lines(var1.impulse$GDP, col="green")
lines(var1.impulse$int_spread, col="purple")
lines(var1.impulse$Unemp, col="black")
lines(var1.impulse$IndPro, col="orange")
lines(var1.impulse$PCE, col="yellow")
legend("topright", c("SP500", "GDP", "Int_Spread", "Unemp", "IndPro", "PCE"), fill = c("blue", "green", "purple", "black", "orange", "yellow"), bty = "n", cex = 1)
#The stress test shows predictions for Sp500 and variable movements over 2 years following the negative impulse. Unemployment Increases, GDP drops, intrest rate spreads widen, personal consumption increases in the short run, but then falls in line with the rest of the indicators. The SP500 responds positively with the increase in expenditure, but than decreases as all variables drag down over time. Ater a year and a half, GDP begins to rebound.
#Lets try multivariate ARIMA
uni_sp = read.csv("C:\\\\Users\\\\cthom\\\\OneDrive\\\\Boston College\\\\Econometrics\\\\spuni.csv")
uni_rest = read.csv("C:\\\\Users\\\\cthom\\\\OneDrive\\\\Boston College\\\\Econometrics\\\\unirest.csv") %>% as.matrix()
arima.fit = Arima(uni_sp, xreg=uni_rest)
arima.fit
## Series: uni_sp
## Regression with ARIMA(0,0,0) errors
##
## Coefficients:
## intercept ï..GDP X10y.3m Unemp IndPro PCE
## -7921.4343 0.2356 202.0376 101.4220 6.2379 0.3331
## s.e. 799.8058 0.1048 23.0518 11.8969 7.0994 0.1511
##
## sigma^2 estimated as 5168: log likelihood=-213.11
## AIC=440.22 AICc=443.95 BIC=451.68
#The Arima model fits the data well. As the options for multi-variate time series modeling are limited, the 3 models completed for this assignment were the VAR, Impulse based projections, and multi-variate ARIMA.