Prediction using our estimated VAR model
library('urca')
Warning message:
package ‘urca’ was built under R version 3.5.1
> library('vars')
[1] "MSFT"
> getSymbols('SNP', from='2014-01-02', to='2019-03-01')
[1] "SNP"
> getSymbols('DTB3', src='FRED')
[1] "DTB3"
> chartSeries(ClCl(MSFT))
> chartSeries(ClCl(SNP))
> chartSeries(ClCl(DTB3))
> DTB3.sub <- DTB3['2014-01-02/2019-03-01']
> MSFT.ret <- diff(log(Ad(MSFT)))
> SNP.ret <- diff(log(Ad(SNP)))
> dataDaily <- na.omit(merge(SNP.ret,MSFT.ret,DTB3.sub), join='inner')
> SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close)
Error: unexpected ')' in "SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close)"
> SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> MSFT.M <- to.monthly(MSFT.ret)$MSFT.ret.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> DTB3.M <- to.monthly(DTB3.sub)$DTB3.sub.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> var1 <- VAR(dataDaily, lag.max=4, ic="AIC")
> VARselect(dataDaily,lag.max=4)
$`selection`
AIC(n) HQ(n) SC(n) FPE(n)
4 4 1 4
$criteria
1 2 3
AIC(n) -2.464174e+01 -2.464248e+01 -2.466476e+01
HQ(n) -2.462365e+01 -2.461081e+01 -2.461951e+01
SC(n) -2.459354e+01 -2.455812e+01 -2.454425e+01
FPE(n) 1.987132e-11 1.985672e-11 1.941926e-11
4
AIC(n) -2.468849e+01
HQ(n) -2.462968e+01
SC(n) -2.453183e+01
FPE(n) 1.896380e-11
> summary(var1)
VAR Estimation Results:
=========================
Endogenous variables: SNP.Adjusted, MSFT.Adjusted, DTB3
Deterministic variables: const
Sample size: 1284
Log Likelihood: 10423.26
Roots of the characteristic polynomial:
1.001 0.542 0.542 0.5176 0.5176 0.4773 0.4773 0.472 0.472 0.4609 0.4609 0.2154
Call:
VAR(y = dataDaily, lag.max = 4, ic = "AIC")
Estimation results for equation SNP.Adjusted:
=============================================
SNP.Adjusted = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 -0.0205471 0.0304468 -0.675
MSFT.Adjusted.l1 -0.0379886 0.0368232 -1.032
DTB3.l1 -0.0155916 0.0269548 -0.578
SNP.Adjusted.l2 -0.0062255 0.0304197 -0.205
MSFT.Adjusted.l2 -0.0374988 0.0369029 -1.016
DTB3.l2 0.0242194 0.0358107 0.676
SNP.Adjusted.l3 -0.0439807 0.0304174 -1.446
MSFT.Adjusted.l3 0.1151185 0.0368966 3.120
DTB3.l3 -0.0302208 0.0357942 -0.844
SNP.Adjusted.l4 -0.0497948 0.0304242 -1.637
MSFT.Adjusted.l4 -0.0208537 0.0369513 -0.564
DTB3.l4 0.0219332 0.0269829 0.813
const 0.0001936 0.0006673 0.290
Pr(>|t|)
SNP.Adjusted.l1 0.49989
MSFT.Adjusted.l1 0.30243
DTB3.l1 0.56307
SNP.Adjusted.l2 0.83787
MSFT.Adjusted.l2 0.30975
DTB3.l2 0.49896
SNP.Adjusted.l3 0.14845
MSFT.Adjusted.l3 0.00185 **
DTB3.l3 0.39867
SNP.Adjusted.l4 0.10194
MSFT.Adjusted.l4 0.57261
DTB3.l4 0.41645
const 0.77171
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01766 on 1271 degrees of freedom
Multiple R-Squared: 0.01561, Adjusted R-squared: 0.006314
F-statistic: 1.679 on 12 and 1271 DF, p-value: 0.06571
Estimation results for equation MSFT.Adjusted:
==============================================
MSFT.Adjusted = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 0.0336001 0.0251298 1.337
MSFT.Adjusted.l1 -0.0785143 0.0303927 -2.583
DTB3.l1 -0.0067972 0.0222476 -0.306
SNP.Adjusted.l2 0.0019187 0.0251074 0.076
MSFT.Adjusted.l2 -0.0685211 0.0304584 -2.250
DTB3.l2 0.0029217 0.0295570 0.099
SNP.Adjusted.l3 0.0028309 0.0251055 0.113
MSFT.Adjusted.l3 0.0176866 0.0304532 0.581
DTB3.l3 0.0486031 0.0295433 1.645
SNP.Adjusted.l4 -0.0004455 0.0251111 -0.018
MSFT.Adjusted.l4 -0.0522804 0.0304983 -1.714
DTB3.l4 -0.0446517 0.0222708 -2.005
const 0.0010630 0.0005507 1.930
Pr(>|t|)
SNP.Adjusted.l1 0.1814
MSFT.Adjusted.l1 0.0099 **
DTB3.l1 0.7600
SNP.Adjusted.l2 0.9391
MSFT.Adjusted.l2 0.0246 *
DTB3.l2 0.9213
SNP.Adjusted.l3 0.9102
MSFT.Adjusted.l3 0.5615
DTB3.l3 0.1002
SNP.Adjusted.l4 0.9858
MSFT.Adjusted.l4 0.0867 .
DTB3.l4 0.0452 *
const 0.0538 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01457 on 1271 degrees of freedom
Multiple R-Squared: 0.01647, Adjusted R-squared: 0.007182
F-statistic: 1.773 on 12 and 1271 DF, p-value: 0.04769
Estimation results for equation DTB3:
=====================================
DTB3 = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 -0.0713351 0.0312667 -2.282
MSFT.Adjusted.l1 -0.0006042 0.0378148 -0.016
DTB3.l1 0.8655354 0.0276806 31.269
SNP.Adjusted.l2 -0.0257874 0.0312388 -0.825
MSFT.Adjusted.l2 -0.0077074 0.0378966 -0.203
DTB3.l2 -0.0417348 0.0367750 -1.135
SNP.Adjusted.l3 0.0286504 0.0312365 0.917
MSFT.Adjusted.l3 0.0068030 0.0378901 0.180
DTB3.l3 0.0220419 0.0367580 0.600
SNP.Adjusted.l4 -0.0405748 0.0312434 -1.299
MSFT.Adjusted.l4 0.0618115 0.0379463 1.629
DTB3.l4 0.1562648 0.0277095 5.639
const 0.0011816 0.0006852 1.724
Pr(>|t|)
SNP.Adjusted.l1 0.0227 *
MSFT.Adjusted.l1 0.9873
DTB3.l1 < 2e-16 ***
SNP.Adjusted.l2 0.4092
MSFT.Adjusted.l2 0.8389
DTB3.l2 0.2566
SNP.Adjusted.l3 0.3592
MSFT.Adjusted.l3 0.8575
DTB3.l3 0.5488
SNP.Adjusted.l4 0.1943
MSFT.Adjusted.l4 0.1036
DTB3.l4 2.1e-08 ***
const 0.0849 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01813 on 1271 degrees of freedom
Multiple R-Squared: 0.9995, Adjusted R-squared: 0.9995
F-statistic: 2.015e+05 on 12 and 1271 DF, p-value: < 2.2e-16
Covariance matrix of residuals:
SNP.Adjusted MSFT.Adjusted DTB3
SNP.Adjusted 3.118e-04 1.014e-04 3.456e-06
MSFT.Adjusted 1.014e-04 2.124e-04 3.279e-06
DTB3 3.456e-06 3.279e-06 3.289e-04
Correlation matrix of residuals:
SNP.Adjusted MSFT.Adjusted DTB3
SNP.Adjusted 1.00000 0.39397 0.01079
MSFT.Adjusted 0.39397 1.00000 0.01241
DTB3 0.01079 0.01241 1.00000
> plot(var1)
Hit <Return> to see next plot:
Hit <Return> to see next plot:
library('urca')
Warning message:
package ‘urca’ was built under R version 3.5.1
> library('vars')
[1] "MSFT"
> getSymbols('SNP', from='2014-01-02', to='2019-03-01')
[1] "SNP"
> getSymbols('DTB3', src='FRED')
[1] "DTB3"
> chartSeries(ClCl(MSFT))
> chartSeries(ClCl(SNP))
> chartSeries(ClCl(DTB3))
> DTB3.sub <- DTB3['2014-01-02/2019-03-01']
> MSFT.ret <- diff(log(Ad(MSFT)))
> SNP.ret <- diff(log(Ad(SNP)))
> dataDaily <- na.omit(merge(SNP.ret,MSFT.ret,DTB3.sub), join='inner')
> SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close)
Error: unexpected ')' in "SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close)"
> SNP.M <- to.monthly(SNP.ret)$SNP.ret.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> MSFT.M <- to.monthly(MSFT.ret)$MSFT.ret.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> DTB3.M <- to.monthly(DTB3.sub)$DTB3.sub.Close
Warning message:
In to.period(x, "months", indexAt = indexAt, name = name, ...) :
missing values removed from data
> var1 <- VAR(dataDaily, lag.max=4, ic="AIC")
> VARselect(dataDaily,lag.max=4)
$`selection`
AIC(n) HQ(n) SC(n) FPE(n)
4 4 1 4
$criteria
1 2 3
AIC(n) -2.464174e+01 -2.464248e+01 -2.466476e+01
HQ(n) -2.462365e+01 -2.461081e+01 -2.461951e+01
SC(n) -2.459354e+01 -2.455812e+01 -2.454425e+01
FPE(n) 1.987132e-11 1.985672e-11 1.941926e-11
4
AIC(n) -2.468849e+01
HQ(n) -2.462968e+01
SC(n) -2.453183e+01
FPE(n) 1.896380e-11
> summary(var1)
VAR Estimation Results:
=========================
Endogenous variables: SNP.Adjusted, MSFT.Adjusted, DTB3
Deterministic variables: const
Sample size: 1284
Log Likelihood: 10423.26
Roots of the characteristic polynomial:
1.001 0.542 0.542 0.5176 0.5176 0.4773 0.4773 0.472 0.472 0.4609 0.4609 0.2154
Call:
VAR(y = dataDaily, lag.max = 4, ic = "AIC")
Estimation results for equation SNP.Adjusted:
=============================================
SNP.Adjusted = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 -0.0205471 0.0304468 -0.675
MSFT.Adjusted.l1 -0.0379886 0.0368232 -1.032
DTB3.l1 -0.0155916 0.0269548 -0.578
SNP.Adjusted.l2 -0.0062255 0.0304197 -0.205
MSFT.Adjusted.l2 -0.0374988 0.0369029 -1.016
DTB3.l2 0.0242194 0.0358107 0.676
SNP.Adjusted.l3 -0.0439807 0.0304174 -1.446
MSFT.Adjusted.l3 0.1151185 0.0368966 3.120
DTB3.l3 -0.0302208 0.0357942 -0.844
SNP.Adjusted.l4 -0.0497948 0.0304242 -1.637
MSFT.Adjusted.l4 -0.0208537 0.0369513 -0.564
DTB3.l4 0.0219332 0.0269829 0.813
const 0.0001936 0.0006673 0.290
Pr(>|t|)
SNP.Adjusted.l1 0.49989
MSFT.Adjusted.l1 0.30243
DTB3.l1 0.56307
SNP.Adjusted.l2 0.83787
MSFT.Adjusted.l2 0.30975
DTB3.l2 0.49896
SNP.Adjusted.l3 0.14845
MSFT.Adjusted.l3 0.00185 **
DTB3.l3 0.39867
SNP.Adjusted.l4 0.10194
MSFT.Adjusted.l4 0.57261
DTB3.l4 0.41645
const 0.77171
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01766 on 1271 degrees of freedom
Multiple R-Squared: 0.01561, Adjusted R-squared: 0.006314
F-statistic: 1.679 on 12 and 1271 DF, p-value: 0.06571
Estimation results for equation MSFT.Adjusted:
==============================================
MSFT.Adjusted = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 0.0336001 0.0251298 1.337
MSFT.Adjusted.l1 -0.0785143 0.0303927 -2.583
DTB3.l1 -0.0067972 0.0222476 -0.306
SNP.Adjusted.l2 0.0019187 0.0251074 0.076
MSFT.Adjusted.l2 -0.0685211 0.0304584 -2.250
DTB3.l2 0.0029217 0.0295570 0.099
SNP.Adjusted.l3 0.0028309 0.0251055 0.113
MSFT.Adjusted.l3 0.0176866 0.0304532 0.581
DTB3.l3 0.0486031 0.0295433 1.645
SNP.Adjusted.l4 -0.0004455 0.0251111 -0.018
MSFT.Adjusted.l4 -0.0522804 0.0304983 -1.714
DTB3.l4 -0.0446517 0.0222708 -2.005
const 0.0010630 0.0005507 1.930
Pr(>|t|)
SNP.Adjusted.l1 0.1814
MSFT.Adjusted.l1 0.0099 **
DTB3.l1 0.7600
SNP.Adjusted.l2 0.9391
MSFT.Adjusted.l2 0.0246 *
DTB3.l2 0.9213
SNP.Adjusted.l3 0.9102
MSFT.Adjusted.l3 0.5615
DTB3.l3 0.1002
SNP.Adjusted.l4 0.9858
MSFT.Adjusted.l4 0.0867 .
DTB3.l4 0.0452 *
const 0.0538 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01457 on 1271 degrees of freedom
Multiple R-Squared: 0.01647, Adjusted R-squared: 0.007182
F-statistic: 1.773 on 12 and 1271 DF, p-value: 0.04769
Estimation results for equation DTB3:
=====================================
DTB3 = SNP.Adjusted.l1 + MSFT.Adjusted.l1 + DTB3.l1 + SNP.Adjusted.l2 + MSFT.Adjusted.l2 + DTB3.l2 + SNP.Adjusted.l3 + MSFT.Adjusted.l3 + DTB3.l3 + SNP.Adjusted.l4 + MSFT.Adjusted.l4 + DTB3.l4 + const
Estimate Std. Error t value
SNP.Adjusted.l1 -0.0713351 0.0312667 -2.282
MSFT.Adjusted.l1 -0.0006042 0.0378148 -0.016
DTB3.l1 0.8655354 0.0276806 31.269
SNP.Adjusted.l2 -0.0257874 0.0312388 -0.825
MSFT.Adjusted.l2 -0.0077074 0.0378966 -0.203
DTB3.l2 -0.0417348 0.0367750 -1.135
SNP.Adjusted.l3 0.0286504 0.0312365 0.917
MSFT.Adjusted.l3 0.0068030 0.0378901 0.180
DTB3.l3 0.0220419 0.0367580 0.600
SNP.Adjusted.l4 -0.0405748 0.0312434 -1.299
MSFT.Adjusted.l4 0.0618115 0.0379463 1.629
DTB3.l4 0.1562648 0.0277095 5.639
const 0.0011816 0.0006852 1.724
Pr(>|t|)
SNP.Adjusted.l1 0.0227 *
MSFT.Adjusted.l1 0.9873
DTB3.l1 < 2e-16 ***
SNP.Adjusted.l2 0.4092
MSFT.Adjusted.l2 0.8389
DTB3.l2 0.2566
SNP.Adjusted.l3 0.3592
MSFT.Adjusted.l3 0.8575
DTB3.l3 0.5488
SNP.Adjusted.l4 0.1943
MSFT.Adjusted.l4 0.1036
DTB3.l4 2.1e-08 ***
const 0.0849 .
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01813 on 1271 degrees of freedom
Multiple R-Squared: 0.9995, Adjusted R-squared: 0.9995
F-statistic: 2.015e+05 on 12 and 1271 DF, p-value: < 2.2e-16
Covariance matrix of residuals:
SNP.Adjusted MSFT.Adjusted DTB3
SNP.Adjusted 3.118e-04 1.014e-04 3.456e-06
MSFT.Adjusted 1.014e-04 2.124e-04 3.279e-06
DTB3 3.456e-06 3.279e-06 3.289e-04
Correlation matrix of residuals:
SNP.Adjusted MSFT.Adjusted DTB3
SNP.Adjusted 1.00000 0.39397 0.01079
MSFT.Adjusted 0.39397 1.00000 0.01241
DTB3 0.01079 0.01241 1.00000
> plot(var1)
Hit <Return> to see next plot:
Hit <Return> to see next plot:
0 Comments