Instrumental Variables — IV Estimation
Statistics
Isolating Exogenous Variation to Solve Endogeneity
Instrumental variables exploit external variation that affects the treatment but not the outcome directly. Two-stage least squares uses this exogenous variation to produce consistent causal estimates even when OLS fails.
-
Economics — Estimate returns to education using quarter of birth as an instrument
-
Healthcare — Assess treatment effects when?? assignment is non-random
-
Political Science — Evaluate policy impacts with institutional instruments
A valid instrument creates a natural experiment that breaks the correlation between treatment and error.
Instrumental variables (IV) methods address endogeneity — when a covariate is correlated with the error term. IV uses an external variable (the instrument) to isolate exogenous variation in the treatment.
The IV Approach
Required Conditions
Relevance
The instrument must be strongly correlated with the endogenous variable.
Exogeneity (Exclusion Restriction)
The instrument must be uncorrelated with the error term — it affects only through .
Two-Stage Least Squares (2SLS)
The most common IV estimation method.
Stage 1
Regress on (and any exogenous covariates):
Stage 2
Regress on :
IV Estimator Formula
Weak Instruments
Testing for Weak Instruments
| F-statistic | Interpretation |
|------------|---------------|
| F > 10 | Rule of thumb: instrument is strong |
| F < 10 | Potentially weak; use weak-IV robust methods |
Overidentification
When you have more instruments than endogenous variables, you can test whether the instruments are valid.
| Decision | Interpretation |
|---------|---------------|
| Reject | At least one instrument is invalid |
| Fail to reject | Instruments are jointly valid |
Hausman Test for Endogeneity
If is rejected, endogeneity is present and IV is preferred.
Python Implementation
import numpy as np
import pandas as pd
import statsmodels.api as sm
from linearmodels.iv import IV2SLS
import matplotlib.pyplot as plt
np.random.seed(42)
# Simulate endogeneity
n = 1000
Z = np.random.randn(n) # Instrument
U = np.random.randn(n) # Unobserved confounder
X = 0.8 * Z + 0.5 * U + np.random.randn(n) * 0.5 # Endogenous
Y = 2.0 * X + 1.5 * U + np.random.randn(n) # Outcome
# Naive OLS (biased)
ols = sm.OLS(Y, sm.add_constant(X)).fit()
print(f"OLS estimate: {ols.params[1]:.3f} (true: 2.0)")
# IV/2SLS
iv_model = IV2SLS.from_formula('Y ~ 1 + [X ~ Z]',
data=pd.DataFrame({'Y': Y, 'X': X, 'Z': Z})).fit()
print(f"IV estimate: {iv_model.params['X']:.3f} (true: 2.0)")
# First-stage F-stat
first_stage = sm.OLS(X, sm.add_constant(Z)).fit()
f_stat = first_stage.fvalue
print(f"\nFirst-stage F-statistic: {f_stat:.1f}")
print(f"Weak instrument: {'Yes' if f_stat < 10 else 'No'}")
# Hausman test
diff = ols.params[1] - iv_model.params['X']
var_diff = ols.bse[1]**2 - iv_model.std_errors['X']**2
hausman_stat = diff**2 / var_diff
print(f"\nHausman test: {hausman_stat:.3f} (p ~ {1 - stats.chi2.cdf(hausman_stat, 1):.3f})")
Worked Example
Key Takeaways
Related Topics
-
See Causal Inference for the potential outcomes framework
-
See Regression Discontinuity for another quasi-experimental method
-
See Difference-in-Differences for policy evaluation