GARCH Models in R
Kris Boudt
Professor of finance and econometrics
Sources:
Solution: Protect yourself through a robust approach
variance.models <- c("sGARCH", "gjrGARCH")
distribution.models <- c("norm", "std", "sstd")
c <- 1
for (var.model in variance.models) {
for (dist.model in distribution.models) {
garchspec <- ugarchspec(mean.model = list(armaOrder = c(0, 0)),
variance.model = list(model = var.model), distribution.model = dist.model)
garchfit <- ugarchfit(data = msftret, spec = garchspec)
if (c==1) { msigma <- sigma(garchfit)
} else { msigma <- merge(msigma, sigma(garchfit))}
c <- c + 1 }
}
avesigma <- xts(rowMeans(msigma), order.by = time(msigma))
coef(garchfit)
mu omega alpha1 beta1 skew shape
5.669200e-04 6.281258e-07 7.462984e-02 9.223701e-01 9.436331e-01 6.318621e+00
rugarch
has a default approach in getting sensible starting valuessetstart()
method to your ugarchspec()
GARCH model specificationgarchspec <- ugarchspec(mean.model = list(armaOrder = c(0,0)),
variance.model = list(model = "sGARCH"),
distribution.model = "sstd")
garchfit <- ugarchfit(data = sp500ret, spec = garchspec)
coef(garchfit)
mu omega alpha1 beta1 skew shape
5.669200e-04 6.281258e-07 7.462984e-02 9.223701e-01 9.436331e-01 6.318621e+00
likelihood(garchfit)
24280.33
garchspec <- ugarchspec(mean.model = list(armaOrder = c(0, 0)),
variance.model = list(model = "sGARCH"), distribution.model = "sstd")
setstart(garchspec) <- list(alpha1 = 0.05, beta1 = 0.9, shape = 8)
garchfit <- ugarchfit(data = sp500ret, spec = garchspec)
coef(garchfit)
mu omega alpha1 beta1 skew shape
5.638002e-04 6.303949e-07 7.466503e-02 9.224117e-01 9.438978e-01 6.309185e+00
likelihood(garchfit) # returns 24280.33
Return.clean()
in the package PerformanceAnalytics
with method = "boudt"
:# Clean the return series
library(PerformanceAnalytics)
clmsftret <- Return.clean(msftret, method = "boudt")
# Plot them on top of each other
plotret <- plot(msftret, col = "red")
plotret <- addSeries(clmsftret, col = "blue", on = 1)
Make the volatility predictions using raw and cleaned Microsoft returns
garchspec <- ugarchspec(mean.model = list(armaOrder = c(1, 0)),
variance.model = list(model = "gjrGARCH"), distribution.model = "sstd")
garchfit <- ugarchfit(data = msftret, spec = garchspec)
clgarchfit <- ugarchfit(data = clmsftret, spec = garchspec)
Compare them in a time series plot
plotvol <- plot(abs(msftret), col = "gray")
plotvol <- addSeries(sigma(garchfit), col = "red", on = 1)
plotvol <- addSeries(sigma(clgarchfit), col = "blue", on = 1)
plotvol
GARCH Models in R