linearmodels.iv.model._OLS

class linearmodels.iv.model._OLS(dependent: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...], exog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...], *, weights: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None)[source]

Compute OLS estimates when required.

Private class used when model reduces to OLS. Should use the statsmodels version when needing a supported public API.

Parameters:
dependent: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...]

Dependent variable (nobs by 1).

exog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...]

Exogenous regressors (nobs by nexog).

weights: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None

Observation weights used in estimation. The weights must be strictly positive and finite. They are rescaled to have a mean of 1. A NaN weight is missing, and its observation is dropped. The default is to weight all observations equally.

See also

statsmodels.regression.linear_model.OLS

Ordinary least squares.

statsmodels.regression.linear_model.GLS

Generalized least squares.

Notes

Uses IV2SLS internally by setting endog and instruments to None. Uses IVLIML with kappa=0 to estimate OLS models.

Rows are paired by position. An input that carries labels (a pandas Series or DataFrame with an index other than the default 0, 1, …, n-1, or an xarray DataArray with coordinates) must use the same index, in the same order, as dependent, so that a value cannot be attached to the wrong observation. A ValueError is raised if the index of exog or weights differs from the index of dependent. Either reindex the input to the index of dependent, or call to_numpy() to pair its values by position. NumPy arrays and pandas objects with a default index do not carry labels and are always paired by position. If dependent does not carry labels, the inputs that do must use the same index as the first of exog and weights that does. The same rule applies to clusters passed to fit. Dates and time deltas are compared by value, so that the same dates at different resolutions, e.g., datetime64[us] and datetime64[ns], are the same labels.

Methods

estimate_parameters(x, y, z, kappa)

Parameter estimation without error checking.

fit(*[, cov_type, debiased])

Estimate model parameters.

from_formula(formula, data, *[, weights, ...])

Create a model from a formula.

predict(params, *[, exog, endog, data, eval_env])

Predict values for additional data.

resids(params)

Compute model residuals.

wresids(params)

Compute weighted model residuals.

Properties

formula

Formula used to create the model.

has_constant

Flag indicating the model includes a constant or equivalent.

isnull

Locations of observations with missing values.

notnull

Locations of observations included in estimation.