Instrumental variables
The one method that still has a chance when the confounder that matters was never measured — and the reason it is a hard bargain: two of its three assumptions can never be checked against data, a weak instrument drags the estimate back towards the biased one it was meant to escape, and Mendelian randomisation is the version of this design most clinicians will meet.
What this page answers
The three pages before this one — DAGs, matching and weighting — all rest on the same premise: the confounders were measured. The grey nodes on a DAG are beyond the reach of matching and weighting. Those methods only find better ways to use the variables you already hold.
But in clinical research the confounder that matters most is usually the one nobody recorded: the fine gradations of disease severity, the clinician’s sense that this particular patient “does not look right”, the patient’s own health-seeking behaviour, socioeconomic position. Taiwan’s National Health Insurance claims database — the source most local database research runs on — holds prescriptions, diagnosis codes and laboratory values. It does not hold the reason the doctor wrote that prescription.
An instrumental variable (IV) is the only observational method that still has a chance in that situation. It does not adjust the confounder away; it goes around it. You look for an external factor that affects whether treatment is received and reaches the outcome through no other route, and then you use only the variation that factor creates.
The price is steep, and it belongs at the top rather than in a footnote: two of the three key assumptions can never be verified from data. Half of this page is about that.
A clinical scenario
The simulation is set up like this, and every role in it corresponds to something you meet in practice:
- U — disease severity, recorded in no field anywhere. Sicker patients are more likely to be started on the new drug (confounding by indication) and have worse outcomes to begin with.
- Z — which hospital the patient happened to attend. Hospitals differ in how readily they adopt the new drug (some departments switched early, others are still waiting). This is the instrument.
- A — whether the new drug was started (yes / no).
- Y — the symptom score at twelve weeks, lower being better. The drug’s true effect is to lower the score by 2.00 points.
figures/scripts/B6-04-iv.RThe simulated data really do behave that way: treated and untreated patients differ by 0.99 standard deviations in severity — that is the confounding by indication — while patients at the two hospitals differ by only 0.022 standard deviations, because the instrument flattened severity out. That contrast is the whole hope of the method.
Three assumptions, two of which cannot be verified
| Assumption | In plain words | Can data check it? |
|---|---|---|
| 1. Relevance | The instrument really does change whether treatment is received | Yes — look at the first-stage F statistic |
| 2. Exclusion restriction | The instrument reaches the outcome only through treatment, by no other route | No |
| 3. Independence (exchangeability) | The instrument and the outcome share no common cause; the instrument itself is unconfounded | No |
The first is the only one you can inspect. In this simulation, 72.1% of patients at the enthusiastic hospital started the drug against 37.2% at the other — a gap of 34.9 percentage points. The main example, a single simulation with n = 5000, gives a first-stage F of 701. That is a very strong instrument.
The second and third cannot be established in any dataset, because what they describe is an absent path and an unmeasured common cause. You do not hold those variables, so there is no test whose passing would mean the assumption holds.
But not provable is not the same as nothing to do: these two can be refuted. Data can produce evidence incompatible with the assumptions even though it can never produce evidence in favour of them. Two checks are standard. (1) Stratify on the instrument and compare the measured covariates — in effect a Table 1 by instrument level. If the two strata already differ in age, comorbidity or severity, independence is in immediate trouble. (2) Use a negative control outcome — pick an outcome the treatment could not plausibly affect; if the instrument appears to “act” on that too, the claim that it works only through treatment does not stand. The simulation on this page has already done the first of these: the sentence in the previous section about the two hospitals differing by only 0.022 standard deviations of severity is the conclusion of that balance table.
Negative controls come in two directions
Check (2) above uses a negative control outcome: an outcome the exposure could not plausibly affect. It has a mirror image, the negative control exposure: an exposure that could not plausibly affect the outcome. Both ask the same question from opposite ends — “if my analysis were clean, there should be nothing here; is there?”
Lipsitch and colleagues set out three requirements, and a control missing any one of them is not really a negative control:
- It shares the same confounders as the real exposure or outcome (otherwise it cannot detect the bias you care about)
- There is no genuine causal path between it and the relationship under test (otherwise an association is exactly what you should expect)
- It is measured and selected the same way as the main analysis (otherwise it cannot detect selection bias or measurement error)
The first is the one most often skipped and the one that matters most: a negative control sharing no confounders with the main analysis tells you nothing when it comes back clean.
A set of negative controls can calibrate
One negative control answers a yes-or-no question. A set of them can do more: estimate dozens of associations whose true value is known to be null, and the resulting distribution ought to sit on the null. When it does not, that displacement estimates the residual bias — and it can be used to make the main analysis’s p-values and intervals appropriately more conservative. This is empirical calibration, standard equipment in large database drug-safety work such as OHDSI and FDA Sentinel. The ITS and DiD page works through it on simulated data, including how much wider the calibrated intervals get.
There is a fourth assumption that often gets skipped, needed only when treatment is binary: monotonicity — nobody exists who would take the drug at the cautious hospital but refuse it at the enthusiastic one. When it holds, what an instrument estimates is the local average treatment effect (LATE): the effect only among the patients whose treatment was actually decided by the instrument, not the average treatment effect in everyone. Who are those patients? The data cannot identify them. This is the hardest property of an IV estimate to explain to a clinical colleague.
Running one for yourself
With a single binary instrument and a single treatment, two-stage least squares (2SLS) is identical to something far easier to read — the Wald ratio:
The numerator is “how much the outcome differs between hospitals”, the denominator “how much the treated proportion differs between hospitals”. You divide the difference in outcome by the difference in treatment. If switching hospitals moves the treated proportion by only about a third, the difference in outcomes has to be scaled up roughly threefold to describe what would happen if everyone were treated.
Writing it as a ratio has one advantage: you can see at a glance what happens when the denominator gets small. That is exactly the weak instrument problem.
set.seed(20260822)
simulate_cohort <- function(n, alpha_z, direct_z = 0) {
U <- rnorm(n) # severity: unmeasured
Z <- rbinom(n, 1, 0.5) # hospital: the instrument
A <- as.integer(-0.4 + alpha_z * Z + 0.9 * U + rnorm(n) > 0) # drug started
Y <- -2 * A + 2 * U + direct_z * Z + rnorm(n) # true effect = -2
data.frame(U, Z, A, Y)
}
d <- simulate_cohort(5000, alpha_z = 1.2)
# -- The naive approach: compare treated with untreated -------------------
summary(lm(Y ~ A, data = d))$coefficients["A", ]
# -- Wald ratio = 2SLS when there is one binary instrument ----------------
wald <- function(d) {
(mean(d$Y[d$Z == 1]) - mean(d$Y[d$Z == 0])) /
(mean(d$A[d$Z == 1]) - mean(d$A[d$Z == 0]))
}
wald(d)
# The exactly equivalent two-stage form (note: the second-stage standard
# error is wrong; fix it with a bootstrap or a dedicated package such as
# AER::ivreg / ivreg::ivreg)
stage1 <- lm(A ~ Z, data = d)
coef(lm(Y ~ fitted(stage1), data = d))[2]
# -- First-stage strength: the only assumption you can check --------------
summary(stage1)$fstatistic[1] # convention: above 10 counts as not weak
# -- Confidence interval: bootstrap the whole procedure -------------------
boot <- replicate(1000, wald(d[sample.int(nrow(d), replace = TRUE), ]))
quantile(boot, c(0.025, 0.975))
# -- What only a simulation can do: put the unmeasured confounder in ------
summary(lm(Y ~ A + U, data = d))$coefficients["A", ]Verified with R 4.6.0; base R is enough — both the 2SLS and the bootstrap use built-in functions
import numpy as np, statsmodels.api as sm
rng = np.random.default_rng(20260822)
def simulate_cohort(n, alpha_z, direct_z=0.0):
U = rng.normal(size=n)
Z = rng.binomial(1, 0.5, size=n)
A = (-0.4 + alpha_z * Z + 0.9 * U + rng.normal(size=n) > 0).astype(int)
Y = -2 * A + 2 * U + direct_z * Z + rng.normal(size=n)
return U, Z, A, Y
U, Z, A, Y = simulate_cohort(5000, alpha_z=1.2)
ols = sm.OLS(Y, sm.add_constant(A)).fit()
print(ols.params[1]) # the biased estimate
wald = (Y[Z == 1].mean() - Y[Z == 0].mean()) / (A[Z == 1].mean() - A[Z == 0].mean())
print(wald)
stage1 = sm.OLS(A, sm.add_constant(Z)).fit()
print(stage1.fvalue) # first-stage F
oracle = sm.OLS(Y, sm.add_constant(np.column_stack([A, U]))).fit()
print(oracle.params[1]) # only a simulation has thisThe Python side needs no special package either; linearmodels' IV2SLS additionally gives you Sargan, Wu-Hausman and friends.
Four estimates, one simulated dataset (the true effect is -2.00):
| Approach | Estimate | 95% CI | Distance from the truth |
|---|---|---|---|
| True effect (the simulation’s setting) | -2.00 | — | — |
| Treated compared directly with untreated | -0.03 | -0.14 to 0.09 | 1.97 |
| Instrumental variable (Wald ratio) | -1.77 | -2.15 to -1.45 | 0.23 |
| Unmeasured severity put into the model (simulation only) | -1.99 | -2.05 to -1.93 | 0.01 |
The second row is a disaster. The drug genuinely lowers the symptom score by 2.00 points, yet comparing treated with untreated patients directly returns -0.03 — confounding by indication has wiped the entire effect out, and the confidence interval crosses zero. “This analysis did not detect an effect of the drug” is an honest statement of what that row shows; but anyone reading only that row will take one more step and conclude that the drug does not work, and that step is the error.
The third row, the instrumental variable estimate, recovers it. The fourth is the answer only a simulation can give, and it confirms that the culprit really was the unmeasured severity.
Weak instruments
The first assumption is the only checkable one, and the consequences of failing that check are worse than they look. Turning the instrument’s strength from very weak up to very strong, with 400 simulations at each level:
figures/scripts/B6-04-iv.RThe F values in the table below are medians over a separate set of repeated simulations, not the F from the single main example above.
| First-stage F (median; n = 2000 each, 400 simulations) | Median estimate | 90% of simulations fall in | Share with the sign reversed |
|---|---|---|---|
| 0.6 | -0.20 | -24.84 to 19.40 | 49% |
| 1.0 | -0.75 | -11.91 to 11.93 | 41% |
| 2.4 | -1.82 | -12.43 to 6.22 | 26% |
| 15.7 | -1.98 | -4.75 to -0.17 | 4% |
| 85.8 | -2.01 | -2.97 to -1.29 | 0% |
| 265.1 | -2.01 | -2.56 to -1.55 | 0% |
Two things to take from it.
First, weak-instrument bias has a direction, and it is the bad one. In the weakest row the median estimate is -0.20 — that is not random scatter, it is a pull towards the naive estimate (-0.06 in this simulation). The intuition: when the instrument barely moves treatment, the denominator of the Wald ratio approaches zero, and any residual association left in the numerator — including the instrument’s own sampling noise — is magnified without limit. A weak instrument does not hand you an uninformative answer; it hands you the biased answer you started with, wrapped in a reassuringly wide confidence interval.
Second, getting the direction backwards is normal when the instrument is weak. In the weakest row, close to half of the simulations put the sign of the effect the wrong way round.
The conventional threshold is a first-stage F above 10. That number comes from simulation studies; it is a rule of thumb, not a theorem. The table shows estimates already close to unbiased once F is around 15, while the 90% range remains alarmingly wide. Recent methodological work argues that 10 is too permissive in weak-instrument settings, and there are inference procedures designed to be robust to weak instruments (the Anderson-Rubin test, for one). Report the F statistic itself, not the fact that it cleared a threshold.
When the exclusion restriction breaks
The right-hand panel above is the most important figure on this page. It gives the instrument a small direct effect on the outcome — breaking the second assumption — and changes nothing else:
| Direct effect of Z on Y | IV estimate | Bias |
|---|---|---|
| 0.00 | -2.01 | -0.01 |
| 0.10 | -1.67 | 0.33 |
| 0.25 | -1.29 | 0.71 |
| 0.50 | -0.55 | 1.45 |
A direct effect of only 0.50 — a quarter of the treatment’s own effect of 2.00 — moves the estimate from -2.01 to -0.55. The effect has all but disappeared.
And throughout, the first-stage F statistic stays in the hundreds. No diagnostic turns red.
Mendelian randomisation
The commonest instrument in medicine is genotype, and the design built on it is called Mendelian randomisation (MR).
The logic runs like this. Which allele you inherit from each parent is settled at conception and settled at random (Mendel’s law of segregation). So if a genetic variant affects the exposure you care about — LDL cholesterol, body mass index, alcohol intake — the first assumption is satisfied; and because the variant was fixed before birth, it cannot have been influenced by later lifestyle, socioeconomic position or disease status. Independence, the third assumption, therefore has a biological argument behind it rather than just optimism. That is MR’s central advantage over other instruments.
Here are the three assumptions in MR’s own vocabulary, with the way each one fails:
| Assumption | How MR states it | The concrete threat here |
|---|---|---|
| Relevance | The variant really does affect the exposure | A single SNP usually has a small effect → weak instrument |
| Exclusion restriction | The gene reaches the outcome only through this exposure | Pleiotropy: one gene influences several traits |
| Independence | Gene and outcome share no common cause | Population stratification: ancestry drives both allele frequency and disease risk |
Pleiotropy is MR’s central problem, because pleiotropy is the exclusion restriction being broken — and the fact that the exclusion restriction cannot be verified applies here just as it does everywhere else. What is done in practice is to use many SNPs together and then compare a family of estimators built to be less sensitive to pleiotropy (MR-Egger, weighted median, MR-PRESSO): if different methods agree, the chance that pleiotropy fooled all of them in the same way is lower. That is triangulation, not verification.
When to reach for an instrumental variable
An instrumental variable is not a more advanced form of adjustment; it is a trade that only works under specific conditions. The situations that suit it share three features:
- The most important confounder is definitely unmeasured, and you can name it. If the concern is only “there might be some residual confounding”, weighting plus a sensitivity analysis (an E-value, say) is usually the more practical route.
- There is an external source of variation you can justify physically or institutionally, rather than a variable picked out of the dataset because it correlates with treatment and not with the outcome. Picking one that way means using data to verify an assumption data cannot verify.
- The sample is large enough to survive a confidence interval three times wider.
When those do not hold, the honest move is to write unmeasured confounding into the limitations rather than force an IV analysis through. The target trial emulation page is worth reading alongside this one: many problems that look like unmeasured confounding are in fact design errors — an undefined time zero, the wrong comparator — and those are fixable by design.
Common misuses
| Misuse | Why it is wrong |
|---|---|
| “Our instrument passed all the tests” | Only the first assumption is testable; the other two cannot be verified even in principle |
| Reporting “F above 10” without reporting F | 10 is a rule of thumb, not a theorem; the reader needs the actual strength |
| Interpreting a point estimate from a weak instrument | Weak-instrument bias points back towards the biased estimate you were escaping |
| Picking a variable from the data because it correlates with treatment and not the outcome | That is using data to verify an assumption data cannot verify |
| Putting the instrument in the regression as a covariate as well | It cancels the one thing the instrument was for, and inflates residual bias |
| Calling an IV estimate the ATE for the whole population | With a binary treatment it is a LATE, specific to those whose treatment the instrument decided |
| Reading the second-stage standard error off a hand-written two-stage regression | The second stage ignores the first stage’s uncertainty, so it is too small |
| Treating an MR effect size as what a drug could achieve | MR estimates a lifetime difference in exposure |
| Running MR with a single estimator and no pleiotropy sensitivity analysis | Pleiotropy is the exclusion restriction breaking, and it cannot be checked directly |
| Concluding a treatment does not work because the IV interval crosses the null | It means this analysis did not detect a difference; IV intervals are wide by construction |
Reproducing every number on this page
/opt/homebrew/bin/Rscript figures/scripts/B6-04-iv.RRead the figure
The answer comes from the same statistical output that produced this page's figures, not from a number typed in beside them.
The simulation was given a true effect of -2.00. Comparing treated and untreated people directly gives -0.03 with an interval that crosses zero. How should that row be read?
Show the answer and why
Correct answer: The instrumental variable estimate on the same data is -1.77, and the naive comparison sits on zero because confounding by indication flattened the effect
Four estimates sit side by side on the same simulated data: the truth at -2.00, the naive comparison at -0.03, the instrumental variable at -1.77, and the model with unmeasured severity in it, which only a simulation can fit, at -1.99. The naive interval really is narrow, reaching only 0.09 — but that precision is built on a biased comparison, and a narrow interval does not make an answer right. Narrow and crossing zero is the most dangerous combination, because it invites the step from this analysis detected no effect to the drug has no effect. Sample size is not the culprit either: adding people would only make the wrong answer more precise. What is doing the damage is the unmeasured severity, which decides both who gets treated and who deteriorates.
The instrumental variable rescues the naive estimate, and the price is written in the width of the interval — even though this instrument is strong, with a first-stage F of 701. Why is it still this wide?
Show the answer and why
Correct answer: Because the two hospitals' treatment rates differ by only 0.349, the Wald ratio divides by it, and only that sliver carries information
The denominator of the Wald ratio is how much the treatment rate changes when you switch hospitals, which is 0.349 in this simulation. The numerator is divided by it, so the difference in outcomes is magnified nearly threefold and the noise is magnified with it, which is what widens the interval. The 0.721 is the treated fraction in the arm sent to that hospital; on its own it does not set precision, the difference between arms does — push it closer to one while the other arm holds still and the difference grows and the estimate becomes more precise, so incomplete adherence points at the wrong thing. The 0.022 is the standardised difference in severity between the instrument's arms, and sitting that close to zero is the evidence that the instrument qualifies rather than the reason it is imprecise. An instrumental variable trades precision for freedom from bias; when the sample is too small it honestly reports that it does not know, which is often more useful than a precise but biased number.
Turn the instrument down to its weakest setting and the median estimate is -0.20 against a true effect of -2.00. Which way does that bias run?
Show the answer and why
Correct answer: Toward the naive estimate. The naive estimate across the same replications is -0.06, and weak instrument estimates drift back toward it
Weak-instrument bias has a direction, and it is the unhelpful one: the weakest row has a median estimate of -0.20 while the naive estimate across the same replications is -0.06, so the estimate is pulled back toward the very thing it was meant to escape. The intuition is that the Wald ratio's denominator approaches zero, so any residual association in the numerator, including the instrument's own sampling noise, is magnified without limit. The scatter is extravagant too, with nine in ten replications between -24.84 and large positive values and nearly half getting the sign wrong; but wide and directional are separate claims, and here both hold. As for -1.98, that is the median of a row where the instrument is already fairly strong, converging near the truth rather than sitting past it, and it does not belong to the weak row.
Give the instrument a small direct effect on the outcome and change nothing else. The direct effect is 0.5, a quarter of the treatment's own effect. What happens to the first-stage F?
Show the answer and why
Correct answer: It does not move at all. With no direct effect the estimate is -2.01; open the direct effect and the estimate drifts while F stays in the hundreds
The first-stage F measures how strongly the instrument predicts treatment, which has nothing to do with whether the instrument bypasses treatment and touches the outcome directly — across the whole sequence in which the exclusion restriction is broken, F stays in the hundreds. With no direct effect the estimate is -2.01, right on the truth; open the direct effect to 0.5 and the estimate is pushed to -0.55 and the effect nearly disappears, with not one computable diagnostic changing colour along the way. The 1.45 is that row's bias column, the gap between estimate and truth, and not an F statistic. This is why saying two assumptions cannot be verified is not a disclaimer: the only effective check is to attack the arrow that should not exist with clinical knowledge — whether that physician also cared for patients better in other ways, whether people who live far away also differ socioeconomically.
The row with a median F of 15.7 has cleared the conventional threshold and its median estimate, -1.98, sits close to the truth. What should that row report?
Show the answer and why
Correct answer: The F itself. Ninety per cent of that row's replications are spread between -4.75 and nearly zero, so the estimate is close to unbiased and still alarmingly imprecise
The point estimate of -1.98 in the row with a median F of 15.7 really is close to the truth, but nine in ten of that row's replications are spread between -4.75 and -0.17 — unbiasedness and precision are different properties, and reading only the upper end as sitting on the negative side turns a settled sign into a quotable number. The conventional threshold comes from simulation studies, a rule of thumb rather than a theorem; recent methodological work considers it too lenient in weak-instrument settings, and there are inference methods built to be robust to weak instruments. The strongest row, with a median F of 265.06, has a far narrower interval, so there is real difference above the threshold, and the claim that everything above it is alike is refuted inside the same table. What to report is the F statistic, not the sentence that the threshold was cleared.
The simulation prints three numbers: 0.990, 0.349 and 0.022. Which one decides whether this instrument qualifies?
Show the answer and why
Correct answer: The 0.022, which is the difference in severity between the instrument's two arms, and only a value near zero shows the instrument did not pick up that confounder
The 0.022 is the difference in severity between the instrument's two arms, and it is near zero, which is exactly what an instrument needs: no association with the unmeasured confounder, which is how it gets around it. The 0.990 is not the instrument's arms at all but the difference between treated and untreated people, which is why the naive comparison fails; an instrument that looked like that would be worthless, and capturing a confounder in order to adjust it away describes what regression adjustment does, not what an instrument does. The 0.349 is not a severity difference either but the difference in treatment rates between arms, which is first-stage strength — one sets precision, the other sets bias, and collapsing them into an intuition that middling is best mixes two separate things. One caution: only a simulation can print this table. In a real study the confounder is unmeasured, so you cannot compute any of it and can only attack the arrow that should not exist with clinical knowledge.
Chapters that use this method
Watch next
INSTRUMENTAL VARIABLE ANALYSES EXPLAINED
The Logic of Instrumental Variables
The 3 Instrumental Variables Assumptions
Introduction to Instrumental Variables (IV)
工具變數 (instrumental variables)Sources and licences
This page is original writing