## Roku and Netflix Data
roku <- read.csv("//Users//kevinclifford//Downloads//ROKU.csv", header=TRUE)
netflix <- read.csv("//Users//kevinclifford//Downloads//NFLX.csv", header=TRUE)
##Removing variables
roku$Open <- NULL
roku$High <- NULL
roku$Low <- NULL
roku$Close <- NULL
roku$Volume <- NULL
netflix$Open <- NULL
netflix$High <- NULL
netflix$Low <- NULL
netflix$Close <- NULL
netflix$Volume <- NULL
## Roku missing first 5 months
netflix <- netflix[6:60,]
stream <- data.frame(roku$Adj.Close, netflix$Adj.Close)
stream_ts <- ts(stream)
stream_ts %>% autoplot() + labs(title="Roku and Netflix Adjusted Closing Prices") +
ylab("Price") +
guides(colour=guide_legend(title="Adjusted Closing Price"))

## VAR
VAR <- VAR(stream_ts)
summary(VAR)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: roku.Adj.Close, netflix.Adj.Close
## Deterministic variables: const
## Sample size: 54
## Log Likelihood: -538.741
## Roots of the characteristic polynomial:
## 0.9453 0.8051
## Call:
## VAR(y = stream_ts)
##
##
## Estimation results for equation roku.Adj.Close:
## ===============================================
## roku.Adj.Close = roku.Adj.Close.l1 + netflix.Adj.Close.l1 + const
##
## Estimate Std. Error t value Pr(>|t|)
## roku.Adj.Close.l1 0.95729 0.06563 14.586 <2e-16 ***
## netflix.Adj.Close.l1 -0.01273 0.06777 -0.188 0.852
## const 13.57211 20.68763 0.656 0.515
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 35.27 on 51 degrees of freedom
## Multiple R-Squared: 0.9176, Adjusted R-squared: 0.9144
## F-statistic: 284 on 2 and 51 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation netflix.Adj.Close:
## ==================================================
## netflix.Adj.Close = roku.Adj.Close.l1 + netflix.Adj.Close.l1 + const
##
## Estimate Std. Error t value Pr(>|t|)
## roku.Adj.Close.l1 0.14354 0.07346 1.954 0.05619 .
## netflix.Adj.Close.l1 0.79313 0.07585 10.456 2.76e-14 ***
## const 63.73237 23.15494 2.752 0.00817 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 39.47 on 51 degrees of freedom
## Multiple R-Squared: 0.8862, Adjusted R-squared: 0.8817
## F-statistic: 198.5 on 2 and 51 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## roku.Adj.Close netflix.Adj.Close
## roku.Adj.Close 1244 398
## netflix.Adj.Close 398 1558
##
## Correlation matrix of residuals:
## roku.Adj.Close netflix.Adj.Close
## roku.Adj.Close 1.0000 0.2859
## netflix.Adj.Close 0.2859 1.0000
VAR_fc <- VAR %>% forecast(h=12)
VAR_fc %>% autoplot(netflix)

VAR_fc %>% autoplot(roku)
