# load data
data("sp500")
sp500 = sp500[1:1000]
# create model specification
spec = MSGARCH::create.spec()
# fit the model on the data with ML estimation using DEoptim intialization
set.seed(123)
fit = MSGARCH::fit.mle(spec = spec, y = sp500, ctr = list(do.init = FALSE))
# run pred method in-sample
pred.its = MSGARCH::pred(object = fit, log = TRUE, do.its = TRUE)
sum(pred.its$pred, na.rm = TRUE)
# create mesh
x = seq(-3,3,0.01)
# run pred method on mesh at T + 1
pred = MSGARCH::pred(object = fit, x = x, log = TRUE, do.its = FALSE)
plot(pred)
Run the code above in your browser using DataLab