class statsmodels.regression.rolling.RollingWLS(endog, exog, window=None, weights=None, min_nobs=None, missing='drop')[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.


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’.

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(as_pandas=False)
>>> 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 =


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

Estimate model parameters.

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

Create a Model from a formula and dataframe.