Step 13: Instrumental Variables and 2SLS
- A regressor is endogenous if it is correlated with the error, \( \text{Cov}(x,u) \neq 0 \). OLS is then biased and inconsistent: more data give a more precise estimate of the wrong number.
- Endogeneity has three sources: omitted variables, measurement error in \( x \) (attenuation) and simultaneity (\( y \) also affects \( x \)).
- An instrument \( z \) must be relevant (\( \text{Cov}(z,x) \neq 0 \), testable) and exogenous (\( \text{Cov}(z,u) = 0 \), argued, not tested). The simple IV estimate is \( \text{Cov}(z,y)/\text{Cov}(z,x) \).
- Two-stage least squares regresses \( x \) on all exogenous variables, then \( y \) on the fitted \( \hat{x} \). Never report hand-made second-stage standard errors.
- Exam point: check the first-stage \( F \) (below 10 means weak instruments), and say what the Hausman and Sargan tests can and cannot show.
What endogeneity means
Every regression so far has rested on one assumption: nothing in the error is related to the explanatory variables. Heteroskedasticity (Step 11) and autocorrelation (Step 12) only spoil the standard errors. A regressor correlated with the error spoils the coefficient itself.
Write the OLS slope as the true value plus an error term, and divide top and bottom by \( n \). As \( n \) grows, the numerator goes to \( \text{Cov}(x,u) \) and the denominator to \( \text{Var}(x) \):
If \( \text{Cov}(x,u) \neq 0 \), OLS is inconsistent: even with an infinite sample it estimates the wrong number, and the sign of the error is the sign of \( \text{Cov}(x,u) \). A study of a million workers with an endogenous regressor gives a very precise estimate of the wrong number.
Source 1: omitted variables
If the true model contains \( q \) but you leave it out, \( q \) sits in the error. Whenever \( q \) is correlated with \( x \), so is \( u \). The leading example is ability in a wage equation: able people earn more for given schooling and also stay in education longer. So \( \text{Cov}(\text{educ}, u) > 0 \) and OLS overstates the return to education. (Our article on predicting the direction of omitted variable bias shows how to sign it.) The book’s companion wage data were simulated with a true return of 0.085; OLS gives 0.1054 even with seven controls.
Source 2: measurement error in a regressor
Suppose you observe \( x = x^* + e \), where \( e \) is a random recording error (classical measurement error). The error \( e \) ends up both in \( x \) and in the regression error, so they are correlated, and
The fraction, the reliability ratio, lies between 0 and 1, so the estimate is shrunk towards zero: attenuation bias. If schooling has true variance 3.5 and is misreported with error variance 0.5, OLS converges to \( 0.875 \times 0.085 = 0.0744 \), 12.5% below the truth. Measurement error in the dependent variable is much less harmful: it joins the error and only costs precision.
Source 3: simultaneity
In a market, price and quantity are set together. Demand is \( q = \alpha_0 + \alpha_1 p + u_d \) with \( \alpha_1 < 0 \), and supply is \( q = \gamma_0 + \gamma_1 p + u_s \) with \( \gamma_1 > 0 \). Solving for the equilibrium price gives \( p = (\alpha_0 – \gamma_0 + u_d – u_s)/(\gamma_1 – \alpha_1) \), so a positive demand shock raises the price. Price is correlated with the demand error, and a regression of \( q \) on \( p \) is pulled from the demand slope towards the positive supply slope. Police and crime, investment and growth: wherever \( y \) feeds back into \( x \), suspect endogeneity.
| Source | Example | Usual effect on OLS |
|---|---|---|
| Omitted variable | Ability left out of a wage equation | Bias in the direction of \( \beta_q\,\text{Cov}(x,q) \); here upwards |
| Measurement error in \( x \) | Schooling or income misreported | Attenuation towards zero |
| Simultaneity | Price and quantity; police and crime | A mixture of the two relationships |
The idea of an instrument
The variation in an endogenous \( x \) is a mixture: some of it moves with \( u \), some does not. If a variable shifts \( x \) but has nothing to do with \( u \), the movements in \( x \) it causes are “clean”. Tracing how \( y \) responds to those movements alone reveals \( \beta_1 \).
Take the covariance of \( y = \beta_0 + \beta_1x + u \) with \( z \): \( \text{Cov}(z,y) = \beta_1\text{Cov}(z,x) + \text{Cov}(z,u) \). Exogeneity sets the last term to zero, and relevance lets us divide:
The first stage measures how much the instrument moves \( x \); the reduced form how much it moves \( y \). Because \( z \) affects \( y \) only through \( x \), dividing one by the other isolates \( \beta_1 \). When \( z \) is a dummy, both slopes are differences in group means and the ratio is the Wald estimator, \( (\bar{y}_1 – \bar{y}_0)/(\bar{x}_1 – \bar{x}_0) \). OLS is the special case \( z = x \).
IV is consistent but not unbiased: in small samples it is biased towards OLS. It is also less precise. With homoskedastic errors, approximately
Worked example: the return to education
The book’s wage data contain dist_college, the distance in kilometres from a worker’s home at 16 to the nearest college. The argument, first made by Card (1995) with US data: living near a college makes study cheaper, so it raises schooling (relevance); where a family lived is, arguably, unrelated to ability and has no direct effect on adult wages (exogeneity). The second claim is not watertight: families who value education may live near colleges, and colleges cluster in cities, where wages are higher. In the simulated data the instrument is valid by construction; in a real study you would have to defend it.
With no controls, \( \text{Cov}(z,y) = -0.3813 \) and \( \text{Cov}(z,x) = -5.3758 \), where \( z \) is distance, \( x \) is schooling and \( y \) is log wage. Workers living at most 20.65 km away (the median) have mean log wage 2.8994 and mean schooling 11.944 years; those further away, 2.8685 and 11.338. Compute the IV estimate and the Wald estimate.
Growing up near a college raises wages by about 3.1% and schooling by 0.6 years, so a year of schooling is worth about 5.1%. The Wald estimate is cruder, because splitting at the median throws away information. Both lie below OLS, in line with upward ability bias.
The price is precision. The correlation between schooling and distance is only −0.167, so the IV standard error should be about \( 1/0.167 \approx 6 \) times the OLS one: \( 0.00809/0.167 = 0.048 \), close to the 0.0487 from a 2SLS command. The 95% interval runs from about −0.03 to 0.17. It contains the OLS estimate, the true value of 0.085, and zero.
The data also contain parent_educ, the schooling of the better-educated parent. It is a much stronger predictor of schooling (correlation 0.373). But is it exogenous? Educated parents tend to have higher incomes and better networks, which may raise their children’s earnings directly, and parents’ education is probably correlated with the child’s own ability, the very variable causing the problem. Most economists would treat it with suspicion.
Two-stage least squares
Real models have control variables \( w_1, \dots, w_k \) and sometimes several instruments \( z_1, \dots, z_m \). The structural equation is \( y = \beta_0 + \beta_1x + \delta_1w_1 + \dots + \delta_kw_k + u \). Two-stage least squares (2SLS) works in two steps.
| Stage | What you do |
|---|---|
| 1 | Regress \( x \) on all exogenous variables, the instruments and the controls. Save the fitted values \( \hat{x} \): they are built only from exogenous variables. |
| 2 | Regress \( y \) on \( \hat{x} \) and the controls. The coefficient on \( \hat{x} \) is the 2SLS estimate. |
The idea is to keep only the part of the variation in \( x \) that the instruments explain. With one instrument and no controls, 2SLS gives exactly the simple IV formula.
IV2SLS in Python’s linearmodels, ivreg in R’s AER, ivregress 2sls in Stata. And never leave the controls out of the first stage.With the seven controls of the book’s Model (4), the results are in Figure 1.
2SLS with distance gives 0.0612 (standard error 0.0448), against 0.1054 (0.0075) from OLS. The point estimate is well below OLS, as ability bias predicts, but the interval from −0.027 to 0.149 cannot rule out the OLS value or zero. Adding parent_educ as a second instrument gives 0.0801 with a standard error of 0.0182: a stronger first stage buys precision, but only by leaning on the doubtful instrument. With more instruments than endogenous regressors the model is overidentified; with exactly as many it is just identified; with fewer it cannot be estimated. In your own work use heteroskedasticity-robust 2SLS standard errors (here 0.0427 instead of 0.0448).
Weak instruments
An instrument only loosely related to \( x \) is weak. Weakness is more than a wide interval: 2SLS is then biased towards OLS, its distribution is far from normal, and the usual tests are unreliable. The standard check is the first-stage \( F \) statistic for the excluded instruments (the controls stay in). With one instrument it is the square of its \( t \) statistic.
Newer work is stricter. Stock and Yogo (2005) tabulated critical values that depend on the number of instruments and the bias you will tolerate, and Lee, McCrary, Moreira and Porter (2022) showed that with one instrument the usual 5% \( t \) test is reliable only when \( F \) exceeds about 104.7. For the wage equation the first-stage \( F \) is 29.38 with distance alone and 101.73 with both instruments. By the old rule both are strong; by the newer one the single-instrument \( t \) test deserves caution.
The book’s simulation (5,000 samples, true slope 1, strongly endogenous \( x \)) shows what goes wrong. OLS has a median of about 1.75–1.80 either way. With a strong instrument (mean \( F = 32.6 \)) the median IV estimate is 1.005 and a 5% test rejects the truth 5.9% of the time. With a weak one (mean \( F = 2.2 \)) the median is 1.250, dragged towards OLS, the middle 90% of estimates runs from −2.73 to 5.26, and the test rejects 10.4% of the time. A weak instrument also magnifies any small failure of exogeneity, because \( \operatorname{plim}\hat\beta_1^{IV} = \beta_1 + \text{Cov}(z,u)/\text{Cov}(z,x) \).
Testing endogeneity and the instruments
Durbin–Wu–Hausman. If \( x \) is exogenous, OLS and 2SLS are both consistent and OLS is more precise. The regression version: save the first-stage residuals \( \hat{v} \), add them to the structural equation, and \( t \)-test their coefficient. In the wage data it is 0.0455 with \( t = 1.019 \), \( p = 0.308 \): we cannot reject exogeneity. That is a lesson in power, not evidence. The gap between OLS and the truth is 0.02 while the IV standard error is 0.045.
Sargan overidentification test. With more instruments than you need, you can check whether they agree. Regress the 2SLS residuals on all exogenous variables; \( nR^2 \sim \chi^2_q \), where \( q \) is the number of extra instruments. With distance and parents’ education, \( nR^2 = 0.221 \), \( p = 0.638 \): they agree. But agreement is not validity. Two instruments that are invalid in the same way, both linked to ability, can agree perfectly and both be wrong.
Worked example: the demand for coffee
The book’s file coffee_market.csv has 240 months of simulated price and quantity data, generated with a true demand elasticity of −0.6. Each month shows only an equilibrium point, so when demand and supply both shift the points form a cloud that traces neither curve. But if something shifts only supply, the equilibria slide along the demand curve and trace it out. Rainfall in the growing region and a transport fuel-cost index are such supply shifters.
Naive OLS of log quantity on log price gives −0.1721. It is not a demand elasticity at all, but a blend of the demand and supply slopes; adding log income moves it to −0.4044. In the first stage, more rain lowers the price and dearer fuel raises it, with an \( F \) of 281.6 for the two instruments, far above both 10 and 104.7. 2SLS gives a price elasticity of −0.5879 (standard error 0.0395, interval −0.666 to −0.510), which contains the true −0.6. The Wu–Hausman statistic of 128.88 rejects exogeneity of price decisively, and the Sargan statistic of 1.348 (\( p = 0.246 \)) says the two instruments agree.
A roaster is considering a 5% price rise. Using the 2SLS elasticity, what happens to quantity and revenue? What would naive OLS have suggested?
OLS would have doubled the expected gain from raising prices. Note the identification rule: to estimate demand you need variables that shift supply only. Income shifts demand, so it belongs in the demand equation and cannot instrument for price there.
What IV estimates when effects differ
If the return to schooling differs across people, Imbens and Angrist (1994) showed that IV estimates a local average treatment effect (LATE): the average effect for the compliers, the people whose schooling the instrument actually changed. Distance to college identifies the return for people who studied because a college was nearby, not for those who would have gone anyway. So two valid instruments can legitimately give different answers. When you report an IV result, say whose behaviour the instrument moves. Famous examples include Angrist and Krueger’s (1991) quarter of birth and Angrist’s (1990) Vietnam-era draft lottery. For a longer treatment, read our article Instrumental Variables and Two-Stage Least Squares.
Practise: 6 questions
Try each one on paper first, then check the worked answer.
EasyQ1. Household income in a survey has true variance 4 and is reported with classical measurement error of variance 1. The true effect of income on saving is 0.10. What will OLS estimate in a large sample? Show worked answer
\( \operatorname{plim}\hat\beta_1 = 0.8 \times 0.10 = 0.08 \): attenuated by 20% towards zero.
A larger sample does not help; it only makes the wrong number more precise.
EasyQ2. In a lottery for places at a selective school, winners later earn 2.4% more (in logs, 0.024) and have 0.4 more years of schooling than losers. Compute the Wald estimate of the return to a year of schooling and state the assumption it needs. Show worked answer
Assumption: winning the lottery affects earnings only through extra schooling (the exclusion restriction). If the selective school also raised earnings through networks, the estimate would mix the two.
MediumQ3. In a sample, \( \text{Cov}(z,y) = 1.2 \) and \( \text{Cov}(z,x) = 8 \). The OLS slope has standard error 0.02 and \( \text{Corr}(x,z) = 0.25 \). Compute the IV estimate, its approximate standard error, and an approximate 95% interval. Show worked answer
\( \text{se} \approx 0.02/0.25 = 0.08 \).
Interval: \( 0.15 \pm 1.96 \times 0.08 = [-0.007, 0.307] \). It just includes zero: the instrument removes bias at a large cost in precision.
MediumQ4. A first-stage regression with one excluded instrument and several controls gives \( t = 3.1 \) on the instrument. Is the instrument weak by the Staiger–Stock rule? What are the consequences if it is? Show worked answer
Consequences: 2SLS is biased towards OLS, its distribution is far from normal, and nominal 5% tests reject too often. Any small violation of exogeneity is magnified.
Remedies: look for a stronger instrument or report weak-instrument-robust (Anderson–Rubin) intervals.
MediumQ5. A model with one endogenous regressor uses two instruments on \( n = 500 \) observations. Regressing the 2SLS residuals on all exogenous variables gives \( R^2 = 0.009 \). Carry out the Sargan test at 5% and interpret. Show worked answer
\( nR^2 = 500 \times 0.009 = 4.5 \), against the \( \chi^2_1 \) critical value 3.84: reject (\( p = 0.034 \)).
At least one instrument appears correlated with the error, or the two give genuinely different estimates (for example different LATEs). The test cannot tell you which instrument is at fault.
ExamQ6. A researcher wants the price elasticity of demand for fresh fish in a coastal city, using monthly data on price and quantity. (a) Explain why OLS of log quantity on log price will not estimate the demand elasticity. [2] (b) From these candidates, choose a suitable instrument and explain your choice: average temperature in the city; storm days at sea; household income. [3] (c) 2SLS gives an elasticity of −1.25. What does a 4% price rise do to revenue? [2] Show worked answer
(b) Storm days at sea. [B1] They reduce the catch and so shift supply (relevance). [B1] They plausibly do not change how much fish consumers want at a given price (exogeneity); temperature and income shift demand, so they belong in the demand equation and cannot be excluded. [B1]
(c) Quantity falls by about \( 1.25 \times 4 = 5\% \). [M1] Revenue changes by about \( 4 – 5 = -1\% \): it falls, because demand is elastic. [A1]
Total: 7 marks.
Check yourself
1. Which instrument condition can be tested directly from the data?
2. Classical measurement error in a regressor makes the OLS slope
3. A first-stage \( F \) statistic of 6 for one instrument suggests
Your score: 0 out of 3
The short version
- Endogeneity, \( \text{Cov}(x,u) \neq 0 \), makes OLS inconsistent: \( \operatorname{plim}\hat\beta_1 = \beta_1 + \text{Cov}(x,u)/\text{Var}(x) \).
- Sources: omitted variables, measurement error in \( x \) (attenuation) and simultaneity.
- A valid instrument is relevant (testable) and exogenous (argued). Simple IV is reduced form over first stage; with a dummy instrument it is the Wald estimator. IV is consistent but less precise.
- 2SLS: regress \( x \) on all exogenous variables, then \( y \) on \( \hat{x} \) and the controls; use a 2SLS command for standard errors.
- Wage data: OLS 0.1054, 2SLS with distance 0.0612 (se 0.0448), with both instruments 0.0801; truth 0.085. Coffee: 2SLS elasticity −0.588 against naive OLS −0.172; truth −0.6.
- First-stage \( F < 10 \) means weak instruments. Hausman tests endogeneity, Sargan tests agreement; neither proves validity. IV estimates a local effect for compliers.
- The full chapter in Econometrics Made Simple has the code in Python, R and Stata, the weak-instrument simulation and a complete set of exercises with answers.
Studying more than one subject? The Complete Book Bundle gives you every Economics, Statistics, Mathematics and Econometrics book in one download.
Further reading on EconTutorials
Related in-depth articles from our blog:
- Instrumental Variables and Two-Stage Least Squares: Solving the Endogeneity Problem
- Omitted Variable Bias: How to Predict the Direction Before You Run the Regression
- Ordinary Least Squares (OLS): Derivation, Assumptions, and Why Omitted Variable Bias Ruins Everything
- Hypothesis Testing in Economics: t-Tests, p-Values, and Statistical Significance
