Rolling OLS Regressions and Predictions by Group
You should be able to achieve what you want using the groupby / apply pattern. The below code should be helpful. Create example data: from statsmodels.regression.rolling import RollingOLS from statsmodels.tools.tools import add_constant import pandas as pd import numpy as np # make some toy data race_dates = pd.to_datetime([‘2020-06-09’]*3 + [‘2020-12-01’]*4 + [‘2021-01-21’]*4 + [‘2021-05-04’]*5) distance … Read more