linearmodels.iv.model.IVLIML

class linearmodels.iv.model.IVLIML(dependent: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...], exog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None, endog: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None, instruments: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None, *, weights: IVData | ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None = None, fuller: int | float = 0, kappa: int | float | None = None)[source]

Limited information ML and k-class estimation of IV models.

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, ...] | None

Exogenous regressors (nobs by nexog). None if the model has no exogenous regressors.

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

Endogenous regressors (nobs by nendog). None if the model has no endogenous regressors.

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

Instrumental variables (nobs by ninstr). None if the model has no instruments.

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.

fuller: int | float = 0

Fuller’s alpha to modify the LIML estimator. The default is 0, which returns the unmodified LIML estimator.

kappa: int | float | None = None

Parameter value for k-class estimation. If not provided, it is computed to produce the LIML parameter estimate.

Raises:
  • ValueError – If the model has no regressors, if there are fewer instruments than endogenous regressors, if [exog, endog] or [exog, instruments] does not have full column rank, if all observations have a missing value, if the inputs have different numbers of observations or labels that do not match (see Notes), if weights are not strictly positive and finite, or if kappa or fuller is not a scalar.

  • TypeError – If an input is complex or cannot be converted to float64.

See also

linearmodels.iv.model.IV2SLS

Estimation of IV models using two-stage least squares.

linearmodels.iv.model.IVGMM

Estimation of IV models using the generalized method of moments.

linearmodels.iv.model.IVGMMCUE

Estimation of IV models using continuously updating GMM.

Notes

kappa and fuller should not be used simultaneously since Fuller’s alpha applies an adjustment to kappa, and so the same result can be computed using only kappa. Fuller’s alpha is used to adjust the LIML estimate of \(\kappa\), which is computed whenever kappa is not provided.

The LIML estimator is defined as

\[\begin{split}\hat{\beta}_{\kappa} & =(X(I-\kappa M_{z})X)^{-1}X(I-\kappa M_{z})Y\\ M_{z} & =I-P_{z}\\ P_{z} & =Z(Z'Z)^{-1}Z'\end{split}\]

where \(Z\) contains both the exogenous regressors and the instruments. \(\kappa\) is estimated as part of the LIML estimator.

When using Fuller’s \(\alpha\), the value used is modified to

\[\kappa-\alpha/(n-n_{instr})\]

\(\kappa\) is the smallest eigenvalue of the cross product of the residuals of the dependent variable and the endogenous regressors on the exogenous regressors, relative to the cross product of their residuals on the exogenous regressors and the instruments, which is inverted. It is not defined if the residuals on the exogenous regressors and the instruments are linearly dependent. That occurs if there are fewer than \(1 + n_{endog}\) observations more than the number of exogenous regressors and instruments (for example, fewer than 4 observations for a constant, one endogenous regressor and one instrument), and if the residuals are collinear for another reason. Whether the residuals are collinear does not depend on the units of the variables. fit raises a ValueError if kappa is not provided and \(\kappa\) is not defined. The model is estimated if kappa is provided, and then the Anderson-Rubin and Basmann F tests of overidentification of the results are an InvalidTestStatistic, since they use the estimate of \(\kappa\).

Two cases are not covered, see GH823. An endogenous regressor that is exactly a linear combination of the exogenous regressors and instruments has residuals that are only rounding error, and so does \(\kappa\). With 2 or more endogenous regressors, \(\kappa\) loses accuracy, and the estimate can fail, if the variables are on very different scales.

Changed in version 7.1: A ValueError is raised if \(\kappa\) is not defined. Earlier versions used the rounding error of the singular cross product, for example 0.8125 instead of 1 in a just-identified model with 3 observations, a constant, one endogenous regressor and one instrument. It was NaN on some platforms, with the estimates and their covariance, and a RuntimeWarning was emitted.

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, endog, instruments 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, endog, instruments 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.

Todo

  • VCV: bootstrap

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.