iv-regression-guide
Apply instrumental variables, 2SLS, and address endogeneity issues
npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill iv-regression-guide --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Instrumental Variables Regression Guide A skill for applying instrumental variables (IV) estimation to address endogeneity in regression models. Covers the logic of IV, two-stage least squares (2SLS), instrument validity tests, weak instrument diagnostics, and reporting standards. ## The Endogeneity Problem ### Why OLS Fails ``` Ordinary Least Squares assumes: E[u | X] = 0 (Regressors are uncorrelated with the error term) This assumption is violated when: - Omitted variable bias: A confound affects both X and Y - Simultaneity: X affects Y and Y affects X - Measurement error: X is measured with noise Consequence: OLS estimates are biased and inconsistent. No amount of data will fix this. ``` ### The IV Solution An instrumental variable Z satisfies two conditions: ``` 1. Relevance: Z is correlated with the endogenous regressor X Cov(Z, X) != 0 2. Exclusion: Z affects Y ONLY through X (not directly) Cov(Z, u) = 0 Z --> X --> Y Z -/-> Y (no direct path) ``` ## Two-Stage Least Squares (2SLS) ### How 2SLS Works ``` Stage 1: Regress the endogenous variable on the instrument(s) X = gamma_0 + gamma_1 * Z + controls + v Save the fitted values: X_hat Stage 2: Regress the outcome on the fitt
- The Endogeneity Problem
- Why OLS Fails
- The IV Solution
- Two-Stage Least Squares (2SLS)
- How 2SLS Works
- Implementation in Python
- Implementation in R
- Instrument Validity Tests
- First-Stage F-Statistic (Relevance)
- Overidentification Test (Exclusion Restriction)
- Classic IV Examples
- Famous Instruments in Economics
- Reporting IV Results
- Required Elements
What does the iv-regression-guide skill do?
Apply instrumental variables, 2SLS, and address endogeneity issues
How do I install it?
Run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill iv-regression-guide --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From brycewang-stanford/Auto-Empirical-Research-Skills, a repository with 3,244 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.