# Moving window forecasting in Python

I am looking to create some code that will out-of-sample forecast the HAR-RV model.

The model itself is formulated as the following, and the betas are estimated through HAC-OLS or Newey-West.

Where weekly and monthly are 5 and 22 daily averages of the daily RV, but if you're interested read more about it here.

So I have all the data and parameters ready in pandas dataframes.

I now wish to forecast on moving windows so that I can obtain a time series that will show me how the entire period would have been predicted on a weekly basis.

So my problem is now that I dont really know how to write something like that. I dont really know how I should interpret the forecasting of this model.

I have seen very intuitive models for forecasting GARCH, but I am having a hard time coming up with the proper equation for forecasting HARRV, and so forth trouble programming it.

This is what I have accomplished.

This code:

Model = smf.ols(formula='RVFCAST ~ RV1 + RV5 + RV22', data = df).fit(use_correction=True)
mdl = Model.get_robustcov_results(cov_type='HAC', maxlags=1, use_correction=True)
#print(mdl.summary());
#print(pd.stats.ols.OLS(y=df['RVFCAST'], x=df[['RV1', 'RV5', 'RV22']], nw_lags=1))

actual = pd.DataFrame(0.0005 + 0.272 * df.RV1 + -0.0486 * df.RV5 + 0.7061 * df.RV22)

pred = pd.DataFrame(mdl.predict())

rw = pd.rolling_window(pred, window = 5, win_type = 'blackman')


As you see I used the rolling_window function which I believe applies a rolling window analysis, and the data/function applied is the "pred" which, as you can see, is a OLS prediction from my previous HAC-OLS.

But all in all, I have no idea if what I have done is correct at all, if the rolling_window function does what I want it to do, so my question is whether or not this is correct or just gobbledygook.