Netflix <- read.csv("NFLX.csv")
AMC <- read.csv("AMC.csv") 
Netflixts <- ts(Netflix[,5], start = c(2015,12), frequency = 12)
AMCts <- ts(AMC[,5], start = c(2015,12), frequency = 12)

As shown by the correlation, the two stocks are very negatively correlated. This make sense as more people use netflix, less will go to cinema.

autoplot(Netflixts)+autolayer(AMCts)

cor(Netflixts,AMCts)
## [1] -0.8528698

To work with our data, we will take the difference to acheive stationary data.

dNetflix<-diff(Netflixts,1)
dAMC<-diff(AMCts,1)
autoplot(dNetflix)

autoplot(dAMC)

Both dataset seems to be stationary. Looking at the ACF and PACF plots, there does not seem to be autocorrelation and significant dependence.

ggAcf(diff(Netflixts))

ggPacf(diff(Netflixts))

ggAcf(diff(AMCts))

ggPacf(diff(AMCts))

Using the varselect function, all the selection model suggest to use VAR(1)

stockvar<-cbind(Netflixts,AMCts)
VARselect(stockvar[,1:2], lag.max=8,
  type="const")[["selection"]]
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      1      1      1      1
var1 <- VAR(stockvar[,1:2], p=1, type="const")
serial.test(var1, lags.pt=10, type="PT.asymptotic")
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object var1
## Chi-squared = 24.969, df = 36, p-value = 0.9165

The residuals for the model pass the test for serial correlation.

forecast(var1,h=30) %>%
  autoplot() + xlab("Year")

The forecast for both stock are negatively correlated. Netflix has a steeper gain while AMC continues to lose in value. The model suggests to long Netflix and short AMC.

Forecasting with stationary data. The VARselect function also suggest using VAR(1)

stockvar2<-cbind(dNetflix,dAMC)
VARselect(stockvar2[,1:2], lag.max=8,
  type="const")[["selection"]]
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      1      1      1      1
vard1 <- VAR(stockvar2[,1:2], p=1, type="const")
serial.test(vard1, lags.pt=10, type="PT.asymptotic")
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object vard1
## Chi-squared = 24.765, df = 36, p-value = 0.9212
forecast(vard1,h=30) %>%
  autoplot() + xlab("Year")

The prediction for the stationary data are flat and essentially 0. This shows the model cannot predict increase or decrease of stock price without using its hisotry.