I am using the library rugarch and I try to find "manually" the same outputs than the library to check that I understand everything correctly. I would like my variance intercept (omega) to be equal to the unconditional variance of my dataset. Therefore, I set variance.targeting = TRUE in the ugarchspec function.
I could check that my unconditional covariance is almost equal to : omega/(1-alpha1-beta1) However, I am unable to find "manually" the same conditional variance time series with the GARCH equation: sigma(t)² = omega + alpha1 * X(t-1)^2 + beta1 * sigma(t-1)²
Here is a reproducible example to illustrate my problem:
data(sp500ret)
sp500ret <- scale(sp500ret, scale = FALSE, center = TRUE) # de-mean
model <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1), variance.targeting = TRUE),
mean.model = list(armaOrder = c(0, 0), include.mean = FALSE), distribution.model = "norm")
fit <- ugarchfit(model, sp500ret)
omega <- fit@fit$coef[3]
alpha <- fit@fit$coef[2]
beta <- fit@fit$coef[1]
var(sp500ret)
# 0.0001426482
omega / (1 - alpha - beta)
# 0.0001426587
var_rugarch <- fit@fit$var
var_manual <- c()
var_manual[1] <- var_rugarch[1]
for (t in 2:5523) {
var_manual[t] <- omega + alpha * sp500ret[t-1]^2 + beta * var_manual[t-1]
}
which(var_rugarch == var_manual)
# [1] 1
However, when variance.targeting = FALSE, the last line indicates that var_rugarch = var_manual. Why these two variables are not the same when variance.targeting = TRUE?