class statsmodels.regression.rolling.RollingWLS(endog, exog, window=None, *, weights=None, min_nobs=None, missing='drop', expanding=False)[source]

Rolling Weighted Least Squares


A 1-d endogenous response variable. The dependent variable.


A nobs x k array where nobs is the number of observations and k is the number of regressors. An intercept is not included by default and should be added by the user. See


Length of the rolling window. Must be strictly larger than the number of variables in the model.

weightsarray_like, optional

A 1d array of weights. If you supply 1/W then the variables are pre- multiplied by 1/sqrt(W). If no weights are supplied the default value is 1 and WLS results are the same as OLS.

min_nobs{int, None}

Minimum number of observations required to estimate a model when data are missing. If None, the minimum depends on the number of regressors in the model. Must be smaller than window.

missingstr, default “drop”

Available options are “drop”, “skip” and “raise”. If “drop”, any observations with nans are dropped and the estimates are computed using only the non-missing values in each window. If ‘skip’ blocks containing missing values are skipped and the corresponding results contains NaN. If ‘raise’, an error is raised. Default is ‘drop’.

expandingbool, default False

If True, then the initial observations after min_nobs are filled using an expanding scheme until window observations are available, after which rolling is used.

See also


WLS estimation and parameter testing.


Tested against WLS for accuracy.

Results may differ from WLS applied to windows of data if this model contains an implicit constant (i.e., includes dummies for all categories) rather than an explicit constant (e.g., a column of 1s).


>>> from statsmodels.regression.rolling import RollingWLS
>>> from statsmodels.datasets import longley
>>> data = longley.load()
>>> exog = add_constant(data.exog, prepend=False)
>>> mod = RollingWLS(data.endog, exog)
>>> rolling_res =

Use params_only to skip all calculations except parameter estimation

>>> rolling_params =

Use expanding and min_nobs to fill the initial results using an expanding scheme until window observation, and the roll.

>>> mod = RollingWLS(data.endog, exog, window=60, min_nobs=12,
... expanding=True)
>>> rolling_res =


fit([method, cov_type, cov_kwds, reset, ...])

Estimate model parameters.

from_formula(formula, data, window[, ...])

Create a Model from a formula and dataframe.