IV - Instrumental Variables
Overview
The IV (Instrumental Variables) estimator provides consistent estimation for exactly identified models where regressors are endogenous. It addresses the endogeneity problem by using instrumental variables to obtain consistent parameter estimates when OLS would be biased.
Mathematical Foundation
The IV method addresses endogeneity in the structural equation:
where \(\text{Cov}(\mathbf{X}, \mathbf{\epsilon}) \neq 0\) (endogeneity problem).
Instrumental Variables Requirements
For valid instruments \(\mathbf{Z}\):
- Instrument Relevance: \(\text{Cov}(\mathbf{Z}, \mathbf{X}) \neq 0\)
- Instrument Exogeneity: \(\text{Cov}(\mathbf{Z}, \mathbf{\epsilon}) = 0\)
- Exact Identification: \(\text{dim}(\mathbf{Z}) = \text{dim}(\mathbf{X})\)
IV Estimator
For exactly identified models:
Covariance Matrix: \(\text{Var}(\hat{\mathbf{\beta}}_{IV}) = \sigma^2(\mathbf{Z}'\mathbf{X})^{-1}(\mathbf{Z}'\mathbf{Z})(\mathbf{Z}'\mathbf{X})^{-1}\)
API Reference
Constructor
Parameters:
- fit_intercept (bool): Whether to calculate the intercept for this model.
Methods
fit()
Fit the IV model for exactly identified case.Parameters:
- instruments (np.ndarray): Instrumental variables matrix Z
- regressors (np.ndarray): Endogenous regressors matrix X
- targets (np.ndarray): Target values y
Requirements: - Number of instruments must equal number of regressors - n_samples > n_features + fit_intercept
predict()
Generate predictions using fitted IV coefficients.Statistical Methods
standard_errors()→ Standard errors of coefficientst_statistics()→ T-statistics for significance testsp_values()→ P-values for coefficient testsconfidence_intervals(alpha=0.05)→ Confidence intervalssummary()→ Comprehensive regression summarycovariance_matrix()→ Coefficient covariance matrix
Properties
Core Results:
- coefficients: IV regression coefficients
- intercept: IV regression intercept
- r_squared: R-squared (can be negative for IV models)
- r_squared_adj: Adjusted R-squared
- mse: Mean squared error
- residuals: Regression residuals
Model Information:
- n_samples: Number of observations
- n_features: Number of features
- fit_intercept: Whether intercept is included
Implementation Details
Numerical Stability
- Automatic algorithm selection for solving (Z'X)⁻¹
- SVD fallback for rank-deficient matrices
- Robust handling of ill-conditioned systems
Performance
- Memory-efficient computation
- Vectorized operations
- Minimal memory allocation
Usage Guidelines
Use IV when:
- Regressors are endogenous
- You have exactly as many instruments as endogenous regressors
- Instruments are strong (first-stage F > 10) and valid
Use alternatives when: - More instruments than regressors → Use TSLS - Regressors are exogenous → Use OLS - Instruments are weak → Consider other methods