@misc{ivreg,
title = {ivreg},
author = {Fox and Kleiber and Zeileis},
howpublished = {\url{https://zeileis.github.io/ivreg/}},
note = {Software / documentation}
}Two-stage least squares treats the instrument as the source of variation: project the endogenous treatment onto Z, then regress Y on the fitted treatment. The estimand under monotonicity is the LATE for compliers — not the ATE — and a first-stage F ≲ 10 means trust nothing.
Input · what goes in
Outcome Y, an endogenous treatment D, an instrument Z (relevant + excludable), and covariates X.
Show data format & exampleHide example
Format — one row per unit: y, d (endogenous), z (instrument), covariates x.
y d z x1
3.1 1 1 0.4
1.8 0 0 -0.1
2.4 0 1 1.2
Pipeline · the recipe ⑂ has parallel branches
↑ Click any step in the diagram to read its logic, code, assumptions & discussion.
Outcome, endogenous treatment, instrument
Data preparation — shapes the raw inputs into what the estimator expects.
Assemble Y, D, Z, X. The instrument must affect D and only affect Y through D.
library(ivreg)
# y ~ d + x | z + x (endogenous d, instrument z)
- No comments on this step yet — be the first.
Log in to comment on this step.
Check instrument strength (first stage)
A pre-flight check — run this before trusting any estimate downstream.
A weak instrument (first-stage F ≲ 10) gives biased, unreliable 2SLS.
summary(lm(d ~ z + x))$fstatistic
- No comments on this step yet — be the first.
Log in to comment on this step.
Two-stage least squares (ivreg)
The core estimate — where the causal quantity itself is computed.
Project D on the instrument, then regress Y on the fitted treatment.
fit <- ivreg(y ~ d + x | z + x, data = df)
summary(fit)
- No comments on this step yet — be the first.
Log in to comment on this step.
Interpret as a complier effect (LATE)
Uncertainty quantification — standard errors, intervals, and aggregation.
Under monotonicity the estimand is the effect for compliers, not everyone.
# robust SEs; the estimate is the LATE
- No comments on this step yet — be the first.
Log in to comment on this step.
Output · what you get
⚠️ Unofficial community showcase of ivreg. Not affiliated with the authors; all credit to them.
When treatment is endogenous, an instrument identifies the complier (LATE) effect via two-stage least squares — after you check the instrument is strong.
Discussion (0)
Log in to join the discussion.