hful¶
- weak_instruments.hful.HFUL(Y: ndarray, X: ndarray, Z: ndarray, G: ndarray[tuple[int, ...], dtype[float64]] | None = None, talk: bool = False, colnames=None) HFULResult ¶
Calculates the HFUL estimator for weak instrument robust inference.
- Parameters:
Y (np.ndarray) – A 1-D or 2-D numpy array of the dependent variable (N,).
X (np.ndarray) – A 2-D numpy array of the endogenous regressors (N, L).
Z (np.ndarray) – A 2-D numpy array of the instruments (N, K).
G (np.ndarray, optional) – A 2-D numpy array of additional controls (N, G). Default is None.
talk (bool, optional) – If True, provides detailed output for debugging purposes. Default is False.
colnames (list, optional) – List of column names for the coefficients. Default is None.
- Returns:
- An object containing the following attributes:
betas (NDArray[np.float64]): The estimated coefficients for the model.
se_list (list of float): Standard errors for the estimated coefficients.
tstat_list (list of float): t-statistics for the estimated coefficients.
pval_list (list of float): p-values for the estimated coefficients.
ci_list (list of tuple): Confidence intervals for the estimated coefficients.
- Return type:
- Raises:
ValueError – If the dimensions of Y, X, or Z are inconsistent or invalid.
Notes
The HFUL estimator is designed for robust inference in the presence of weak instruments.
The function computes coefficient estimates, standard errors, t-statistics, p-values, and confidence intervals.
Additional controls can be included via the G argument.
Example
>>> import numpy as np >>> from weak_instruments.HFUL import HFUL >>> Y = np.random.randn(100) >>> X = np.random.randn(100, 1) >>> Z = np.random.randn(100, 2) >>> result = HFUL(Y, X, Z) >>> result.summary()
- class weak_instruments.hful.HFULResult(betas, se_list, tstat_list, pval_list, ci_list)¶
Bases:
object
Stores results for the HFUL estimator.
- betas¶
Estimated coefficients for the HFUL model.
- Type:
NDArray[np.float64]
- se_list¶
Standard errors of the estimated coefficients.
- Type:
list of float
- tstat_list¶
t-statistics for the estimated coefficients.
- Type:
list of float
- pval_list¶
p-values for the estimated coefficients.
- Type:
list of float
- ci_list¶
Confidence intervals for the estimated coefficients.
- Type:
list of tuple
- summary()¶
Prints a summary of the HFUL results in a tabular format similar to statsmodels OLS.