statsmodels.regression.rolling.RollingRegressionResults.get_resid#

RollingRegressionResults.get_resid(out_of_sample=False)[source]#

Compute the rolling residuals

Parameters:
out_of_samplebool, optional

If False (default), the residual for observation t uses the parameters estimated from the window that ends at observation t, so that observation t is included in the estimation. If True, the residual for observation t uses the parameters estimated from the window that ends at observation t-1, which is the one-step ahead prediction error.

Returns:
residualsndarray or Series

The residuals y[t] - x[t] @ params with one value for each observation. A Series is returned if the model was created using pandas inputs.

See also

statsmodels.regression.linear_model.RegressionResults.resid

Residuals of a single regression.

Notes

Only one residual is computed for each window so that the residuals of every observation in every window do not need to be stored. The residuals are computed using the unweighted data, as in WLS.

The residual is nan when the parameters are not available, e.g., for the observations before the first window has min_nobs observations, or when the observation is missing.