linearmodels.iv.model.IVJIVE¶
-
class linearmodels.iv.model.IVJIVE(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)[source]¶ Jackknife instrumental variables estimator (JIVE).
- 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.
- 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), or ifweightsare not strictly positive and finite.TypeError – If an input is complex or cannot be converted to float64.
See also
linearmodels.iv.model.IV2SLSEstimation of IV models using two-stage least squares.
linearmodels.iv.model.IVLIMLLimited information ML and k-class estimation of IV models.
linearmodels.iv.model.IVGMMEstimation of IV models using the generalized method of moments.
linearmodels.iv.model.IVGMMCUEEstimation of IV models using continuously updating GMM.
Notes
JIVE replaces the 2SLS first-stage fitted values \(\hat{X}=P_ZX\) with leave-one-out predictions. The prediction for observation \(i\) is the fitted value from a first stage regression that does not use observation \(i\)
\[\tilde{x}_i = \frac{\hat{x}_i - h_i x_i}{1 - h_i}, \qquad h_i = z_i'(Z'Z)^{-1}z_i,\]where \(Z\) contains the exogenous regressors and the instruments and \(h_i\) is the leverage of observation \(i\). The estimator is
\[\hat{\beta}_{JIVE} = (\tilde{X}'X)^{-1} \tilde{X}'y.\]This is the estimator that is called JIVE1 by Angrist, Imbens and Krueger (1999). Exogenous regressors are in \(Z\), so they are their own leave-one-out predictions. In a weighted model the estimator is applied to the data that has been multiplied by the square root of the weights.
The leverages are used to compute \(\tilde{X}\) without estimating \(n\) regressions, using a QR decomposition of \(Z\). The estimator cannot be computed if an observation has a leverage of 1, which happens if it is the only observation that has a non-zero value of one of the instruments, e.g., a dummy variable that is 1 for a single observation.
The covariance estimators are the same as in the other IV models, and are computed using \(\tilde{X}\) as the instruments. See
fit(). These are valid when the number of instruments is small relative to the strength of the first stage. They can understate the uncertainty when there are many instruments (see Chao, Swanson, Hausman, Newey and Woutersen, 2012).JIVE reduces the many instruments bias of 2SLS, but it can have a larger variance, particularly when the instruments are weak (see Davidson and MacKinnon, 2006).
The estimates do not use the estimate of \(\kappa\) of LIML, but the Anderson-Rubin and Basmann F tests of overidentification of the results do. The estimate of \(\kappa\) is not defined if there are fewer than \(1 + n_{endog}\) observations more than the number of exogenous regressors and instruments, or if the residuals of the dependent variable and the endogenous regressors on the exogenous regressors and instruments are collinear (see
IVLIML). The model is estimated then, and the tests are anInvalidTestStatistic.Changed in version 7.1: The Anderson-Rubin and Basmann F tests are an
InvalidTestStatisticif \(\kappa\) is not defined. Earlier versions computed them from the rounding error of a singular matrix, or the statistics were NaN.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. AValueErroris raised if the index ofexog,endog,instrumentsorweightsdiffers from the index ofdependent. Either reindex the input to the index ofdependent, or callto_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. Ifdependentdoes not carry labels, the inputs that do must use the same index as the first ofexog,endog,instrumentsandweightsthat does. The same rule applies toclusterspassed tofit. Dates and time deltas are compared by value, so that the same dates at different resolutions, e.g.,datetime64[us]anddatetime64[ns], are the same labels.References
Angrist, J. D., Imbens, G. W., & Krueger, A. B. (1999). Jackknife instrumental variables estimation. Journal of Applied Econometrics, 14(1), 57-67.
Chao, J. C., Swanson, N. R., Hausman, J. A., Newey, W. K., & Woutersen, T. (2012). Asymptotic distribution of JIVE in a heteroskedastic IV regression with many instruments. Econometric Theory, 28(1), 42-86.
Davidson, R., & MacKinnon, J. G. (2006). The case against JIVE. Journal of Applied Econometrics, 21(6), 827-833.
Examples
>>> import numpy as np >>> from linearmodels.iv import IVJIVE >>> rng = np.random.default_rng(0) >>> n = 500 >>> z = rng.standard_normal((n, 3)) >>> x = z[:, 0] + rng.standard_normal(n) >>> exog = np.ones((n, 1)) >>> y = x + rng.standard_normal(n) >>> mod = IVJIVE(y, exog, x[:, None], z) >>> res = mod.fit()Methods
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 used to create the model.
Flag indicating the model includes a constant or equivalent.
Locations of observations with missing values.
Locations of observations included in estimation.