Pick 5 years of monthly adjusted closing data for two stocks or funds that you might feel are reasonably correlated. Build a VAR model to investigate the relationships. Discuss.
For my analysis I picked the Ford and GM monthly adjusted closing data. Being in the same industry and being US car manufacturers, I thought that Ford and GM would be more correlated than not. This was not the case. The model gave very flat forecasts.
library(readr)
require(forecast)
## Loading required package: forecast
## Warning: package 'forecast' was built under R version 3.4.2
## Warning in as.POSIXlt.POSIXct(Sys.time()): unknown timezone 'zone/tz/2018c.
## 1.0/zoneinfo/America/New_York'
require(fpp)
## Loading required package: fpp
## Loading required package: fma
## Loading required package: expsmooth
## Loading required package: lmtest
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: tseries
library(vars)
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following objects are masked from 'package:fma':
##
## cement, housing, petrol
## Loading required package: strucchange
## Loading required package: sandwich
## Loading required package: urca
library(tseries)
#Import
data <- read_csv("~/Desktop/data.csv")
## Parsed with column specification:
## cols(
## `GM Adj Close` = col_double(),
## `Ford Adj Close` = col_double()
## )
#Create time series
myts <- ts(data, start = c(2013, 4), end = c(2018,4), frequency = 12)
plot(myts)
#Create VAR model
VARselect(myts, lag.max=8, type="const")$selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 1 1 1 1
varfit.1<-VAR(myts, p=1, type="const")
summary(varfit.1)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: GM.Adj.Close, Ford.Adj.Close
## Deterministic variables: const
## Sample size: 60
## Log Likelihood: -171.134
## Roots of the characteristic polynomial:
## 0.9736 0.6455
## Call:
## VAR(y = myts, p = 1, type = "const")
##
##
## Estimation results for equation GM.Adj.Close:
## =============================================
## GM.Adj.Close = GM.Adj.Close.l1 + Ford.Adj.Close.l1 + const
##
## Estimate Std. Error t value Pr(>|t|)
## GM.Adj.Close.l1 0.85320 0.06139 13.897 < 2e-16 ***
## Ford.Adj.Close.l1 -0.47320 0.21240 -2.228 0.02985 *
## const 10.60752 3.62852 2.923 0.00496 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 1.842 on 57 degrees of freedom
## Multiple R-Squared: 0.8012, Adjusted R-squared: 0.7942
## F-statistic: 114.9 on 2 and 57 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Ford.Adj.Close:
## ===============================================
## Ford.Adj.Close = GM.Adj.Close.l1 + Ford.Adj.Close.l1 + const
##
## Estimate Std. Error t value Pr(>|t|)
## GM.Adj.Close.l1 -0.05282 0.02218 -2.382 0.02059 *
## Ford.Adj.Close.l1 0.76588 0.07672 9.982 4.01e-14 ***
## const 4.52637 1.31071 3.453 0.00105 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.6653 on 57 degrees of freedom
## Multiple R-Squared: 0.6889, Adjusted R-squared: 0.678
## F-statistic: 63.11 on 2 and 57 DF, p-value: 3.533e-15
##
##
##
## Covariance matrix of residuals:
## GM.Adj.Close Ford.Adj.Close
## GM.Adj.Close 3.3921 0.6009
## Ford.Adj.Close 0.6009 0.4426
##
## Correlation matrix of residuals:
## GM.Adj.Close Ford.Adj.Close
## GM.Adj.Close 1.0000 0.4904
## Ford.Adj.Close 0.4904 1.0000
fcast<-forecast(varfit.1, h=12 )
fcast
## GM.Adj.Close
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2018 37.60977 35.24944 39.97010 33.99995 41.21958
## Jun 2018 37.54838 34.54962 40.54714 32.96217 42.13459
## Jul 2018 37.49941 34.11724 40.88157 32.32683 42.67198
## Aug 2018 37.45870 33.79641 41.12099 31.85771 43.05969
## Sep 2018 37.42356 33.53380 41.31331 31.47469 43.37243
## Oct 2018 37.39226 33.30699 41.47752 31.14438 43.64014
## Nov 2018 37.36365 33.10511 41.62219 30.85078 43.87653
## Dec 2018 37.33702 32.92228 41.75176 30.58525 44.08878
## Jan 2019 37.31187 32.75487 41.86886 30.34254 44.28119
## Feb 2019 37.28788 32.60048 41.97529 30.11911 44.45666
## Mar 2019 37.26486 32.45734 42.07238 29.91240 44.61733
## Apr 2019 37.24266 32.32413 42.16118 29.72042 44.76489
##
## Ford.Adj.Close
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## May 2018 10.87891 10.026302 11.73152 9.574958 12.18286
## Jun 2018 10.87172 9.828149 11.91528 9.275717 12.46772
## Jul 2018 10.86945 9.729964 12.00893 9.126758 12.61214
## Aug 2018 10.87030 9.669194 12.07140 9.033367 12.70723
## Sep 2018 10.87310 9.625017 12.12118 8.964322 12.78188
## Oct 2018 10.87710 9.589334 12.16487 8.907631 12.84657
## Nov 2018 10.88182 9.558718 12.20492 8.858310 12.90533
## Dec 2018 10.88694 9.531595 12.24229 8.814117 12.95977
## Jan 2019 10.89228 9.507162 12.27739 8.773928 13.01062
## Feb 2019 10.89769 9.484952 12.31042 8.737095 13.05828
## Mar 2019 10.90310 9.464657 12.34154 8.703191 13.10301
## Apr 2019 10.90846 9.446049 12.37087 8.671896 13.14502
plot(fcast)