Skip to main content

IV / 2SLS — Instrumental Variables & Two-Stage Least Squares

IV/2SLS handles endogeneity — when a regressor is correlated with the error (due to omitted variables, measurement error, or simultaneity). In that case OLS is biased and inconsistent. IV uses an instrument to isolate the exogenous part of the endogenous variable.

Valid-instrument conditions

A valid instrument ZZ must be: (1) relevant — correlated with the endogenous variable; (2) exogenous (exclusion) — affecting YY only through the endogenous variable, not directly. A weak instrument causes severe bias.


Two-stage mechanism

β^2SLS=(XPZX)1XPZY,PZ=Z(ZZ)1Z\hat{\beta}_{2SLS} = (X' P_Z X)^{-1} X' P_Z Y, \qquad P_Z = Z(Z'Z)^{-1}Z'

Required tests

  • Weak instrument: first-stage F-statistic (rule of thumb: F > 10).
  • Endogeneity: Durbin-Wu-Hausman test (is IV needed?).
  • Overidentification: Sargan/Hansen J test (when instruments > endogenous variables).

Running in EcoLab

  1. Modeling module → IV & simultaneous equations family → IV/2SLS.
  2. Declare YY, the exogenous variables, the endogenous variable(s) and the instrument(s) ZZ.
  3. Run; read the first-stage F, 2SLS coefficients, Sargan/Hansen; export the replication code.

Replication code

* ── IV / 2SLS estimation ──────────────────────────
* Endogenous: educ | Instruments: near_college, parent_educ
ivregress 2sls lnwage exper (educ = near_college parent_educ), first

* ── Post-estimation diagnostics ───────────────────
estat firststage // First-stage F (rule of thumb: F > 10)
estat endogenous // Durbin-Wu-Hausman endogeneity test
estat overid // Sargan / Hansen J overidentification test

Limitations

  • Weak/invalid instruments make IV worse than OLS.
  • Finding good instruments is usually hard; needs strong theoretical justification.

Video tutorial

Video Tutorial: Guide to running IV/2SLS in EcoLab

See also