Comparing GARCH Models

What is a GARCH model?

GARCH stands for generalized ARCH model. Well, what is an ARCH model? ARCH stands for Auto-Regressive Conditional Heteroscedasticity. The definition of an ARCH model is one where there is a fraction of the variability assigned to long-run variance and a proportion of variance assigned to each autoregressive variance component where q is the number of previous time periods. This gives us a linear combination of long-term variance and individual variance components.

However, In empirical work with ARCH models high values of q is often required. A more parsimonious representation is the Generalised ARCH model (back to GARCH). In the GARCH model, we have three components: long-term variance, auto-regressive variance, and moving average variance. We assign some weight to the long-run average variance rate, and the sum of the weights in the model must add up to 1. All parameters in GARCH models are simply estimated by maximum likelihood using the same basic likelihood function, assuming normality. In maximum likelihood methods we choose parameters that maximize the likelihood of the observations occurring. The package documentation also describes “QMLE”. Quasi-Maximum Likelihood Estimation assumes normal distribution and uses robust standard errors for interferences.

Which is what I got from the slides. From lecture, I think that this was really well summarized by explaining it as a two step process that the garchFit() function does:

obtain the errors from some sort of linear model

use these errors to determine proper weights, or which variations are worth more. the total of the weights is 1

Since we talked about how volatile daily stock prices are, I will look at daily adjusted close of the stock for Beyond Meat, Inc. 

#libraries
library(forecast)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(fGarch)
## Loading required package: timeDate
## Loading required package: timeSeries
## Loading required package: fBasics
#import 
bynd <- read.csv("C:/Users/andre/Documents/Boston College/2. Summer 2020/Forecasting/week 5/BYND.csv")

#dates & close
date <- bynd[,1]
adj.close <- bynd[,6]
daily <- cbind(date, adj.close)
dailyts <- ts(daily[,2], start = c(2019,05,02), end = c(2020,07,28), frequency = 365)
autoplot(dailyts)

Since this is already daily data, I’ll make a GARCH model for this. Or at least that’s what I wanted to do. I used the following code to try to run a GARCH model

mygarch <- garchFit(data = train, formula=garch(1,1),cond.dist=“QMLE”, trace=FALSE)

however, I keep getting this error:

Error in matrix(0, ncoef, ncoef) : invalid ‘nrow’ value (too large or NA) In addition: There were 50 or more warnings (use warnings() to see the first 50)

Then, when I run this code (the only change I’ve made is adding ~ to the formula aspect, like is in the function documentation)

mygarch <- garchFit(train, formula=~garch(1,1),cond.dist=“QMLE”, trace=FALSE)

which leads to a different error

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : 0 (non-NA) cases. In addition: There were 50 or more warnings (use warnings() to see the first 50)

Except, there is no missing data

sum(is.na(dailyts))
## [1] 0

I don’t think that the issue can be that the data is too large, this is only 313 observations, and the training set that I was trying to model was only 250 observations. Does anyone have any insight into this? It would be very appreciated!

I also have a note from lecture about using the function forecastGARCH() when doing the forecasting - this doesn’t work with my code either, but what is the difference between this and just regular forecast()?

Additionally, to compare this to other models, I wanted to aggregate my data into monthly data (and then run ETS and ARIMA models). Does anyone have useful strategies with how to deal with yahoo.Finance dates? When I used the as.Date function, it switched the order and it looked like there were a lot of NA values where they weren’t originially.

I look forward to seeing what you all have!

Update This is a work in progress that I plan on tweaking throughout the week. I was able to get my daily stock data into the proper data format as a new data frame

#dates & close
date <- c(bynd[,1])
date <- as.Date(date, tryFormats =c("%m/%d/%Y")) #capital Y to get 4 digit year
adj.close <- bynd[,6]

#daily data frame
daily <- cbind.data.frame(date,adj.close)
head(daily)
##         date adj.close
## 1 2019-05-02     65.75
## 2 2019-05-03     66.79
## 3 2019-05-06     74.79
## 4 2019-05-07     79.17
## 5 2019-05-08     72.25
## 6 2019-05-09     68.27