jive1¶
- weak_instruments.jive1.JIVE1(Y: ndarray[tuple[int, ...], dtype[float64]], X: ndarray[tuple[int, ...], dtype[float64]], Z: ndarray[tuple[int, ...], dtype[float64]], W: ndarray[tuple[int, ...], dtype[float64]] | None = None, talk: bool = False) JIVE1Result ¶
Calculates the JIVE1 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). Do not inlude the constant.
Z (NDArray[np.float64]) – A 2-D numpy array of the instruments (N x K), where K > L. Do not include the constant.
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 / debugging 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 JIVE1 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 JIVE1 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, and F-statistics 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.jive1 import JIVE1 >>> Y = np.array([1, 2, 3]) >>> X = np.array([[1], [2], [3]]) >>> Z = np.array([[1, 0], [0, 1], [1, 1]]) >>> result = JIVE1(Y, X, Z) >>> print(result.beta)
- class weak_instruments.jive1.JIVE1Result(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]], root_mse: ndarray[tuple[int, ...], dtype[float64]], pvals: ndarray[tuple[int, ...], dtype[float64]], tstats: ndarray[tuple[int, ...], dtype[float64]], cis: ndarray[tuple[int, ...], dtype[float64]])¶
Bases:
object
Stores results for the JIVE1 estimator.
- beta¶
Estimated coefficients for the JIVE1 model.
- Type:
NDArray[np.float64]
- leverage¶
Leverage values for each observation.
- Type:
NDArray[np.float64]
- fitted_values¶
Fitted values from the first pass of the JIVE1 estimator.
- Type:
NDArray[np.float64]
- r_squared¶
R-squared value of the model.
- Type:
float
- adjusted_r_squared¶
Adjusted R-squared value of the model.
- Type:
float
- f_stat¶
F-statistic of the model.
- Type:
float
- standard_errors¶
Robust standard errors for the estimated coefficients.
- Type:
NDArray[np.float64]
- root_mse¶
Root mean squared error of the model.
- Type:
float
- pvals¶
p-values for the estimated coefficients.
- Type:
list of float
- tstats¶
t-statistics for the estimated coefficients.
- Type:
list of float
- cis¶
Confidence intervals for the estimated coefficients.
- Type:
list of tuple
- summary(pvals, tstats, cis, root_mse)¶
Prints a summary of the JIVE1 results in a tabular format similar to statsmodels OLS.