I am trying to produce one-step ahead forecast using GARCH in Python using a fixed windows method. I ultimately want to put the code below in a for loop, but this code snippet does not perform as I expect.
egarch = arch_model(train_data, mean='zero', lags=0, vol='EGARCH', p=1, o=1, q=1, dist='normal') egarch_fit = egarch.fit(); prediction = egarch_fit.forecast(horizon=1); prediction.variance
I expected the final line to print a numeric value, the one step ahead prediction based on train_data. However, the output I get is a dataframe with many NaN values and the prediction. How do I obtain the numerical forecasts? And how come the length of the returned dataframe is equal to the original sample size and not the size of train_data?
I read the reference (https://arch.readthedocs.io/en/latest/univariate/forecasting.html#arch.univariate.base.ARCHModelForecast) and it makes me believe that a for loop is not necessary to get one-step ahead forecasts based on a fixed window. However, I do not know how to obtain such a result. Furthermore, the code in the reference returns a dataframe, but I prefer a simple array of predictions.