rolling_ols
eap_pl.rolling_ols(data, *, y, x, group_by, date_col, anchors, months, min_obs)Fit rolling OLS with an intercept on a panel of numeric returns.
Each fit includes the full formation month and the preceding months - 1 calendar months. It uses all rows with finite outcomes and predictors, with any forecast or holding period after the formation month.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | pl.DataFrame | pl.LazyFrame | Panel with group, date, outcome, and predictor columns. | required |
| y | str | Outcome column. | required |
| x | Sequence[str] | Predictor columns in the desired output order. | required |
| group_by | str | Group column, shared by data and anchors. | required |
| date_col | str | Date column in data. | required |
| anchors | pl.DataFrame | Unique group and month keys. The month column contains the first date of each requested formation month as a Polars Date. |
required |
| months | int | Number of calendar months in each window. | required |
| min_obs | int | Minimum matched observations required per window. A fit also requires positive residual degrees of freedom. | required |
Returns
| Name | Type | Description |
|---|---|---|
| polars.DataFrame | In anchor order with the keys, nobs, Intercept, the named slope columns, and rmse (the residual standard error). Fit statistics are null when the window is too small or rank deficient. |