Instrumental Variables (2SLS) Lab

Explore bias from endogeneity and how a valid instrument recovers the causal effect. Adjust instrument strength, endogeneity, and noise; compare OLS vs. IV; and check the first-stage F-statistic for weak instruments.

Controls

-13
01.6
00.95
801000

Quick Scenarios

x (endogenous regressor)y (outcome)
OLS fit
IV (2SLS) fit
1.240
IV (2SLS) Estimate
True β = 1.50
1.988
OLS Estimate
Bias from corr(x, ε) when ρ > 0
297.33
First-Stage F
Rule-of-thumb: F ≥ 10

First Stage: x on z1

z1x
R² (first stage) = 0.499,  F = 297.33

Stata Implementation

* 2SLS with robust SEs
clear all
use "your_data.dta", clear

* First stage diagnostics (x on instruments)
regress x z1, vce(robust)
estat firststage

* Second stage (2SLS)
ivregress 2sls y (x = z1), vce(robust)

* Over-ID test (only when >1 instrument)
* estat overid  // (needs >1 instrument)

When does IV work?

Two key conditions:

  • Relevance: instruments explain variation in x (check first-stage F).
  • Exogeneity: instruments affect y only through x, uncorrelated with ε.

Good practice:

  • Report first-stage results and F-statistic.
  • Use robust or clustered SEs; consider LIML for weak IVs.