I am quite confused with rolling windows for statsmodels RollingOLS
which is described in the RollingOLS example page.
It mentions that
Estimated values are aligned so that models estimated using data points t, (t+1), ..., (t + windows) are stored in location (t + windows).
I have some questions:
Q1: Assume we are at row t, if I set RollingOLS(endog, exog, window=60)
, it estimates the model using data from [t - 60, t] (i.e. (t - 60), (t - 59), ..., t) which has 61 observations, right? But this is an window of 61 days.
Q2: If we use model.params
to extract the estimated coefficients, the coefficients at row t is the OLS results using data from [t - 60, t] (i.e. (t - 60), (t - 59), ..., t), am I right?
Q3: If my guess in Q2 is right, how do we solve the rolling problem mentioned here? That is
I want to run a rolling 100-day window OLS regression estimation, which is:
First for the 101st row, I run a regression of Y-X1,X2,X3 using the 1st to 100th rows, and estimate Y for the 101st row;
Then for the 102nd row, I run a regression of Y-X1,X2,X3 using the 2nd to 101st rows, and estimate Y for the 102nd row;
Then for the 103rd row, I run a regression of Y-X1,X2,X3 using the 2nd to 101st rows, and estimate Y for the 103rd row;
Until the last row.