I am new user in R. Please help me!
I have 1114 observations with 8 assets. For example, I have fitted a multivariate DCC-GARCH model to the first 1000 data points and I want to do 1-ahead forecast for 3 periods later such as
1) Data[1:1000,] In-sample data, forecast for Data[1001,]
2) Data[1:1001,] In-sample data, forecast for Data[1002,]
3) Data[1:1002,] In-sample data, forecast for Data[1003,]
Below is my reproducible code:-
# load libraries
library(rugarch)
library(rmgarch)
library(FinTS)
library(tseries)
library (fPortfolio)
data(dji30retw)
for (i in 1:3) {
Dat.Initial = dji30retw[, 1:8, drop = FALSE]
Dat <- Dat.Initial[1:(1000+(i-1)), ]
#Fitting the data
uspec = ugarchspec(mean.model = list(armaOrder = c(0,0)), variance.model = list(garchOrder = c(1,1), model = "sGARCH"), distribution.model = "norm")
spec1 = dccspec(uspec = multispec( replicate(8, uspec)), dccOrder = c(1,1), distribution = "mvnorm")
fit1 <- list()
fit1[[i]] = dccfit(spec1, data = Dat, out.sample = 1, fit.control = list(eval.se=T))
#Out of sample forecasting
dcc.focast <- list()
dcc.focast[[i]]=dccforecast(fit1[[i]], n.ahead = 1, n.roll = 0)
print(dcc.focast[[i]])
}
The codes works perfectly. I can now get my dcc.focast values. But why is it, if I execute
dcc.focast[[1]]
NULL
it gives me "NULL". Shouldn't it produce the same answer as the "print(dcc.focast[[i]])" as in the loop?
The problem here, it only gives me dcc.focast[[3]]. The rest are are "NULL". What is the mistake that I have done? Anyone can help to explain?