jive2¶
- weak_instruments.jive2.JIVE2(Y: ndarray[tuple[int, ...], dtype[float64]], X: ndarray[tuple[int, ...], dtype[float64]], Z: ndarray[tuple[int, ...], dtype[float64]], G: ndarray[tuple[int, ...], dtype[float64]] | None = None, talk: bool = False) JIVE2Result ¶
Calculates the JIVE2 estimator defined by Blomquist and Dahlberg (1999) in Jackknife IV estimation.
- Parameters:
Y (NDArray[np.float64]) – A 1-D numpy array of the dependent variable (N x 1).
X (NDArray[np.float64]) – A 2-D numpy array of the endogenous regressors (N x L).
Z (NDArray[np.float64]) – A 2-D numpy array of the instruments (N x K), where K > L.
W (NDArray[np.float64]) – A 2-D numpy array of the exogenous controls (N x G). Do not include the constant. These are not necessary for the function.
talk (bool) – If True, provides detailed output for teaching purposes. Default is False.
- Returns:
- An object containing the following attributes:
beta (NDArray[np.float64]): The estimated coefficients for the model.
leverage (NDArray[np.float64]): The leverage values for each observation.
fitted_values (NDArray[np.float64]): The fitted values from the first pass of the JIVE2 estimator.
r_squared (float): The R-squared value for the model.
adjusted_r_squared (float): The adjusted R-squared value for the model.
f_stat (float): The F-statistic for the model.
standard_errors (NDArray[np.float64]): The robust standard errors for the estimated coefficients.
- Return type:
- Raises:
ValueError – If the dimensions of Y, X, or Z are inconsistent or invalid.
RuntimeWarning – If the number of instruments (columns in Z) is not greater than the number of regressors (columns in X).
Notes
The JIVE2 estimator is a jackknife-based instrumental variable estimator designed to reduce bias in the presence of many instruments.
- The function performs a two-pass estimation:
The first pass calculates fitted values and leverage values using the instruments.
The second pass removes the ith observation to calculate unbiased estimates.
Additional statistics such as R-squared, adjusted R-squared, F-statistics, and robust standard errors are calculated for model evaluation.
If the number of endogenous regressors is 1, first-stage statistics (R-squared and F-statistic) are also computed.
Example
>>> import numpy as np >>> from weak_instruments.jive2 import JIVE2 >>> Y = np.array([1, 2, 3]) >>> X = np.array([[1], [2], [3]]) >>> Z = np.array([[1, 0], [0, 1], [1, 1]]) >>> result = JIVE2(Y, X, Z) >>> print(result.beta)
- class weak_instruments.jive2.JIVE2Result(beta: ndarray[tuple[int, ...], dtype[float64]], leverage: ndarray[tuple[int, ...], dtype[float64]], fitted_values: ndarray[tuple[int, ...], dtype[float64]], r_squared: ndarray[tuple[int, ...], dtype[float64]], adjusted_r_squared: ndarray[tuple[int, ...], dtype[float64]], f_stat: ndarray[tuple[int, ...], dtype[float64]], standard_errors: ndarray[tuple[int, ...], dtype[float64]])¶
Bases:
object