I have the log returns of closing prices and am trying to use GARCH(1,1) model to forecast volatility of these log returns. So, far I have the following code, but I get incorrect values for my forecast.
library(quantmod)
library(tseries)
library(fGarch)
r = Data[indexStart:indexEnd] # Log Returns
fgarch.fitted = fGarch::garchFit(~ garch(1,1), data = as.zoo(na.omit(r)),trace = FALSE)
predict(fgarch.fitted, n.ahead = 1,doplot=F)[3]