Blog
Policy & causal

Instrumental variables and 2SLS

What endogeneity is, how an instrument and 2SLS untangle it, and how to read the first-stage F and diagnostics.

Skari team7 min

The more often people went to the gym, the higher their fitness scores. Run a regression and you get this.

"One more visit a month raises the fitness score by 1.35 points!"

But people who simply love exercise may both go to the gym more and be fitter. That motivation is not in the survey, so you cannot put it in the regression either.

This is where instrumental variables (IV) and two-stage least squares (2SLS) come in. Today we look at what endogeneity is and how an instrument untangles it.

What endogeneity is

When an explanatory variable (X) is tangled up with factors missing from the regression, X is called endogenous. Ordinary regression (OLS) coefficients are then pushed to one side.

  • Omitted variables — a factor such as motivation that affects both X and Y
  • Reverse causality — being fit is what makes people go to the gym more
  • Measurement error — X is not measured accurately

The idea behind an instrument

Find a variable (Z) that moves X but affects Y only through X. That Z is the instrument.

In today's example we use the distance from home to the public gym. People who live closer go more often, but distance itself is assumed not to change fitness.

The differences in visits caused by distance are then clean variation, unrelated to motivation, and the effect can be estimated from that variation alone.

Two conditions for a good instrument

① Relevance — Z must be clearly related to X. A first-stage F of 10 or more is taken to mean the instrument is not weak.

② Exclusion — Z must affect Y only through X. This cannot be tested with data; it has to be argued.

For example, if neighbourhoods near a gym also have more parks and walking paths, distance could affect fitness by another route. Add such factors as control variables.

Two-stage least squares (2SLS)

  • Stage 1 — regress the endogenous variable (visits) on the instrument (distance) and controls to get predicted values.
  • Stage 2 — regress the outcome (fitness) on those predicted values and the controls. This coefficient is the IV estimate of the effect.

Running the two stages by hand gives wrong standard errors, so use a tool that estimates 2SLS in one go.

Today's example

  • Participants — 600 adults (simulated data)
  • Outcome (Y) — self-rated fitness score
  • Endogenous variable (X) — gym visits per month
  • Instrument (Z) — distance from home to the public gym (km)
  • Control (W) — age

Reading the results

MeasureValue
OLS1.35 points · 95% CI [1.18, 1.51]
First stage−0.73 visits per km · F = 77.5
2SLS0.78 points · 95% CI [0.28, 1.28]
Endogeneity test (Hausman)p = .019

With a first-stage F of 77.5, far above 10, a weak instrument is no worry.

By 2SLS, one more visit a month raises the fitness score by about 0.78 points. The OLS figure of 1.35 had motivation mixed in and was inflated by about 42%.

In exchange, the 2SLS confidence interval is wider. Using only clean variation means using less information — think of it as the price of removing bias.

It is also worth noting that this is the effect for people whose visits change because of distance.

Diagnostics to report alongside

  • Weak instrument (first-stage F) — below 10, the estimate is hard to trust
  • Overidentification test (Sargan-Hansen J) — only possible with more instruments than endogenous variables
  • Endogeneity test (Hausman) — if significant, it justifies IV over OLS

How to write it up

To account for the endogeneity of monthly gym visits, a two-stage least squares (2SLS) analysis was conducted using distance from home to the public gym as the instrument (control: age, N = 600). In the first stage, distance significantly predicted visits (b = −0.73, F = 77.52, p < .001). In the second stage, one additional monthly visit raised self-rated fitness by 0.78 points (SE = 0.25, 95% CI [0.28, 1.28]), z = 3.08, p = .002, 42% smaller than the OLS estimate (1.35). The Hausman test supported the endogeneity of visits (χ² = 5.54, p = .019).

Example sentence · the numbers are made up

In Skari

In Skari Statistics, load your data, switch the analysis list to By field and open Economics · policy → Policy effects (causal) to find Instrumental Variables (IV) and Two-Stage Least Squares (2SLS). (Under By method, they are in Econometrics → Causal Inference.)

In Instrumental Variables, the variables step asks for the outcome (Y), the endogenous variable (X) and the instruments (Z); the settings step adds exogenous controls (W).

Choosing the outcome, endogenous variable and instruments — opened on 500 simulated cases with a true effect of 1.5
Choosing the outcome, endogenous variable and instruments — opened on 500 simulated cases with a true effect of 1.5

Try instrumental variables on your data

Opens Statistics at By field → Economics · policy → Policy effects (causal)

Open IV

Run the analysis and the results come together as a report. The IV effect with its confidence interval and the first-stage F sit at the top.

Top of the report — example result (simulated data, two instruments and one control)
Top of the report — example result (simulated data, two instruments and one control)

One table sets the OLS and IV estimates side by side.

OLS and IV (2SLS) estimates compared — same example (IV lands closer to the true effect of 1.5)
OLS and IV (2SLS) estimates compared — same example (IV lands closer to the true effect of 1.5)

First-stage instrument coefficients, reduced-form coefficients and the weak-instrument, overidentification and endogeneity tests are tabled, and a plot sets OLS beside 2SLS.

First-stage instrument coefficients and diagnostic tests — same example
First-stage instrument coefficients and diagnostic tests — same example

With several endogenous variables, the Two-Stage Least Squares (2SLS) menu lets you pick several endogenous variables and instruments. Each endogenous variable gets its own first-stage diagnostics and instrument validity checks (strength, endogeneity, overidentification).

The report downloads as Word, PDF or Excel.

Wrapping up

The heart of instrumental variables is finding a variable that moves X but reaches Y only through X, and estimating the effect from that clean variation alone. Check that the first-stage F is 10 or more and that the exclusion condition can be argued, and you can answer "so what is the real effect?" on much firmer ground.

Want the theory behind it?The Academy's instrumental variables chapter covers endogeneity, the exclusion restriction, weak instruments and LATE in depth →

Keep reading

Every feature free through Dec 31, 2026

Run the analyses from these posts on your own data