With an unobserved confounder, unconfoundedness fails. Even a randomized experiment can face this problem through noncompliance: subjects are randomly assigned but some do not comply, so the actually-treated group is self-selected and that selection may be correlated with the outcome.
17.1 Instrumental Variables
17.1.1 Uncontrolled Confounder
The graph below is the problem: \(c\) is an unobserved common cause of the treatment \(w\) and the outcome \(y\). There is no adjustment set, because \(c\) is not measured.
17.1.2 Why Does IV Work?
Adding \(z\) gives a variable that moves \(w\) and reaches \(y\) only through \(w\). The arrow \(z \to w\) is the relevance condition, and the absence of any arrow from \(z\) to \(y\) or to \(c\) is the exclusion restriction and the exogeneity condition. The missing arrows carry the assumptions.
17.1.3 IV Under Potential Outcomes
W has two potential outcomes W(1) and W(0), as a function of Z.
Y has two potential outcomes Y(1) and Y(0), as a function of W.
Intention to Treat (ITT) is the average treatment effect of the treatment assignment Z. It is the difference between the average potential outcome under assignment to treatment (\(Z=1\)) and the average potential outcome under assignment to control (\(Z=0\)). It is the average treatment effect of the treatment assignment Z, regardless of whether the subject complies with the assignment.
There are four possible groups of subjects in the case of binary treatment and binary instrument. The groups are defined by the potential treatment status \((W(0), W(1))\) — how the subject would take treatment under each value of the instrument — not by the observed \((Z, W)\):
\(W(0)=0, W(1)=0\): never-taker
\(W(0)=0, W(1)=1\): complier
\(W(0)=1, W(1)=0\): defier
\(W(0)=1, W(1)=1\): always-taker
compliance groups
W(1)=0
W(1)=1
W(0)=0
N
C
W(0)=1
D
A
These four groups (strata) have different causal mechanisms. The compliers and defiers are the groups whose treatment status responds to the assignment \(Z\) — compliers in the same direction as the assignment, defiers in the opposite direction. The always-takers and never-takers take the same treatment regardless of \(Z\).
Unfortunately we cannot identify the compliance group by looking at the data.
Z
W
G
0
0
C, N
0
1
A, D
1
0
N, D
1
1
C, A
17.1.4 Assumptions
Exclusion restriction: \(Y(w, 1) = Y(w,0)\)
Exogeneity of instrument: \(Z \perp [W(0),W(1), Y(0), Y(1)]\)
Monotonicity (no defiers): \(W(0) \leq W(1)\)
17.1.5 LATE Identification
Since we excluded defiers, and the other two groups (always-takers and never-takers) are not affected by the treatment assignment Z. The only effect we can identify is the treatment effect on the compliers. This is called the Local Average Treatment Effect (LATE).
Below we write potential outcomes indexed by the instrument, \(Y(Z=z)\), rather than by treatment status, \(Y(d)\). The exclusion restriction is exactly what licenses this: since \(Y(w,1)=Y(w,0)\), \(Y\) depends on \(Z\) only through \(W\), so \(Y(Z=z) = Y(W(z), z) = Y(W(z))\) in the usual treatment-indexed notation. For a complier (\(W(1)=1, W(0)=0\)), this means \(Y(Z=1) = Y(1)\) and \(Y(Z=0) = Y(0)\), so \(E[Y(Z=1)-Y(Z=0) \mid G=C]\) below is exactly \(E[Y(1)-Y(0) \mid G=C]\), the LATE in treatment-indexed notation.
\[ \small
\begin{aligned}
& E[Y(Z=1) - Y(Z=0) | G = C] \\
&= \frac{E[Y(Z=1) - Y(Z=0)]}{P(W(1)=1, W(0)=0)} \text{ (exclusion: zero effect for A and N; monotonicity: no D) } \\
&= \frac{E[Y|Z=1] - E[Y|Z=0]}{1-P(W=0|Z=1)-P(W=1|Z=0)} \text{ (monotonicity rules out D; the A and N shares subtract) } \\
&= \frac{E[Y|Z=1] - E[Y|Z=0]}{P(W=1|Z=1)-P(W=1|Z=0)} \\
&= \frac{E[Y|Z=1] - E[Y|Z=0]}{E[W|Z=1]-E[W|Z=0]}
\end{aligned}
\tag{17.1}\]
17.1.6 Parametric Models
With a binary instrument this is exactly the ratio of two OLS coefficients — no linearity assumption is needed, since a regression on a binary regressor just computes the two group means. This is sometimes called the Wald estimator.
Why do covariates help? It is important to separate two assumptions here. Conditioning on covariates \(X\) can make the as-if-random (conditional independence) assumption more credible: the instrument may be unconfounded only within levels of \(X\). But the exclusion restriction – that the instrument has no direct effect on the outcome – is a substantive structural assumption that covariates do not generally repair. Adding \(X\) removes a direct \(Z \to Y\) path only if that path runs entirely through \(X\), or if exclusion is conditional by design. So covariates help with conditional independence, not with exclusion per se.
17.1.7 Example
We simulate \(n = 10{,}000\) observations. Three variables \((w, m, z)\) are drawn jointly normal with mean zero and unit variances, so their covariances are also their correlations: \(\text{corr}(w,m) = 0.36\), \(\text{corr}(w,z) = 0.64\), and \(\text{corr}(m,z) = 0\). A fourth variable \(u \sim N(0,1)\) is independent of everything. The outcome is \(y = w + m + u\).
So \(m\) is the omitted confounder, correlated with the treatment \(w\) but not with the instrument \(z\), and the true coefficient on \(w\) is 1. Because all variances are 1, we can predict the omitted-variable bias exactly: regressing \(y\) on \(w\) alone gives \(1 + \text{Cov}(m,w) = 1.36\).
We fit three models: OLS of \(y\) on \(w\), OLS of \(y\) on \(w\) and \(m\), and 2SLS using \(z\) as the instrument for \(w\).
Code
## DGP: data.y = data.w + data.m + data.uRandom.seed!(66)nobs =10000## here we have three variables w, m, z.## m is the omitted variable; w and m are correlated; z is the instrument,## which is correlated with w, but not m. u is independent of everything else.## with unit variances, the covariances below ARE the correlationscrwm =0.36; crmz =0.0; crwz =0.64covarMat = [1.0 crwm crwz; crwm 1.0 crmz; crwz crmz 1.0]mat =rand(MvNormal(zeros(3), covarMat), nobs)'data =DataFrame(w = mat[:, 1], m = mat[:, 2], z = mat[:, 3])data.u =rand(Normal(0, 1), nobs)# dgpdata.y = data.w .+ data.m .+ data.ulm_biased =feols(data, @formula(y ~ w))lm_full =feols(data, @formula(y ~ w + m))tsls_model =feiv(data, @formula(y ~1); endo =:w, inst =:z);
Code
# lm is biaseddisplay(coeftable(lm_biased))# lm_full is gooddisplay(coeftable(lm_full))# tsls is good.display(coeftable(tsls_model))
Estimate
Std. Error
z value
Pr(>
(Intercept)
-0.0116415
0.0136663
-0.85
0.3943
w
1.35705
0.0136527
99.40
<1e-99
Estimate
Std. Error
z value
Pr(>
(Intercept)
-0.00914669
0.00997142
-0.92
0.3590
w
0.997584
0.0106743
93.46
<1e-99
m
0.998357
0.0106525
93.72
<1e-99
Estimate
Std. Error
z value
Pr(>
w
0.999871
0.0219208
45.61
<1e-99
(Intercept)
-0.00577212
0.0141291
-0.41
0.6829
OLS on \(w\) alone gives 1.3571, matching the predicted 1.36 to two decimals. OLS controlling for \(m\) gives 0.9976 on \(w\) and 0.9984 on \(m\), both close to the true 1, which is what we would do if the confounder were observed. 2SLS gives 0.9999 with a standard error of 0.0219, recovering the truth without ever using \(m\).
Note the cost of instrumenting: the 2SLS standard error is 0.0219 against 0.0107 for the OLS that controls for \(m\), twice as large. The instrument uses only the part of \(w\) that \(z\) explains, and here that is 41% of its variance.
17.1.8 Control Function Approach
Two-stage least squares can be implemented equivalently via the control function (CF) approach. Understanding why makes the extension to nonlinear models (the Poisson IV chapter) transparent.
Algebraic motivation. Because w is endogenous, decompose the structural error:
\[\varepsilon = \rho v + \eta, \qquad v \equiv w - E[w \mid z], \qquad E(z\eta) = 0,\; E(zv) = 0. \tag{17.3}\]
If we knew\(v\), controlling for it directly would eliminate the confounding channel. We don’t know \(v\), but the first-stage residual \(\hat v = w - \hat w\) is a consistent estimate. Substituting into the structural equation:
\[y = \alpha + \beta w + \rho\,\hat v + \text{error}. \tag{17.4}\]
OLS on this augmented second stage gives a consistent \(\hat\beta\) — identical to 2SLS by the Frisch–Waugh–Lovell (FWL) theorem. The coefficient \(\hat\rho\) on \(\hat v\) doubles as a Durbin–Wu–Hausman (DWH) endogeneity test: under \(H_0\) (w is exogenous), \(\rho = 0\).
Code
importStatsBase: coef, stderror, coefnamespick(m, v, name) = v[findfirst(==(name), coefnames(m))]# Manual 2SLS, explicitlystage1 =feols(data, @formula(w ~ z))data.w_hat = data.w .- stage1.residualstsls_manual =feols(data, @formula(y ~ w_hat))# Control function: first-stage residual v_hat in the augmented regressiondata.v_hat = stage1.residualslm_cf =feols(data, @formula(y ~ w + v_hat))# Compare β̂_w from manual 2SLS and CF — should be identical by FWL@printf("Manual 2SLS beta_w = %.8f\n", pick(tsls_manual, coef(tsls_manual), "w_hat"))@printf("Control funct beta_w = %.8f\n", pick(lm_cf, coef(lm_cf), "w"))# DWH endogeneity test: t-stat on v_hatrho, rho_se =pick(lm_cf, coef(lm_cf), "v_hat"), pick(lm_cf, stderror(lm_cf), "v_hat")@printf("DWH test on v_hat: coef = %.4f se = %.4f t = %.3f p = %.4g\n", rho, rho_se, rho / rho_se, 2*ccdf(Normal(), abs(rho / rho_se)))
Manual 2SLS beta_w = 0.99987086
Control funct beta_w = 0.99987086
DWH test on v_hat: coef = 0.6100 se = 0.0270 t = 22.563 p = 9.987e-113
Both routes give \(\hat\beta_w = 0.99987086\), agreeing to all eight printed digits, which confirms FWL. The coefficient on \(\hat v\) is 0.6100 with a standard error of 0.0270, so \(t = 22.6\) and \(H_0\!:\rho = 0\) is rejected: w is endogenous. That coefficient also has a value we can derive. With \(\varepsilon = m + u\) and \(v = w - 0.64z\), we have \(\text{Cov}(\varepsilon, v) = \text{Cov}(m,w) = 0.36\) and \(\text{Var}(v) = 1 - 0.64^2 = 0.5904\), so \(\rho = 0.36/0.5904 = 0.610\). The estimate matches it to three decimals. One caveat: the OLS standard errors from the augmented regression are not valid for \(\hat\beta\) (\(\hat v\) is a generated regressor; the DWH test is fine because under \(H_0\) the first-stage estimation error does not matter). Use 2SLS standard errors, or bootstrap the two stages jointly as we do in the Poisson IV chapter.
Why FWL fails in nonlinear models. FWL is a property of linear projections; once we replace OLS with Poisson or Probit, the estimator is no longer a linear projection and the partialling-out logic does not apply. In a nonlinear second stage, \(\hat v\) must enter inside the link function (e.g. \(\exp(\mathbf{x}\boldsymbol\beta + \rho \hat v)\)), which requires a structural assumption beyond instrument exogeneity. This is the subject of the Poisson IV chapter.
17.2 When 2SLS with Covariates Is Actually LATE
The LATE identification above is clean because we have no covariates. The Wald estimator gives us LATE, full stop. But in practice we usually add covariates to defend conditional exogeneity:
\[
Y = \beta W + \gamma^\top X + U, \qquad W = \pi Z + \delta^\top X + V.
\tag{17.5}\]
Does 2SLS on this still give us a LATE? Angrist and Pischke (2009) say it gives a weighted average of covariate-specific LATEs. Blandhol et al. (2025) show that this is generally not true.
17.2.1 Why the Linear Specification Hides an Assumption
By Frisch-Waugh-Lovell, the IV estimand is
\[
\beta_{iv} = \frac{E[Y \tilde Z]}{E[W \tilde Z]}, \qquad \tilde Z = Z - L[Z \mid X],
\tag{17.6}\]
where \(L[Z \mid X]\) is the linear projection of \(Z\) on \(X\). So \(\tilde Z\) is the part of \(Z\) that a linear regression on \(X\) cannot explain.
What if the true \(E[Z \mid X]\) is not linear in \(X\)? Then \(L[Z \mid X] \neq E[Z \mid X]\), and the residual instrument \(\tilde Z\) still picks up some of the conditional mean. The IV estimand then mixes treatment effects across compliance groups. Blandhol et al. (2025) prove that \(\beta_{iv}\) is a non-negatively weighted average of conditional LATEs only if the rich covariates condition holds:
\[
L[Z \mid X] = E[Z \mid X].
\tag{17.7}\]
This is a parametric assumption about \(E[Z \mid X]\). It is implicit in the linear-in-\(X\) specification, and it is rarely defended. When it fails, \(\beta_{iv}\) picks up treatment effects for always-takers as well as compliers, and some always-taker terms enter with negative weight.
“2SLS with covariates estimates LATE” is true only if \(X\) enters saturated (one dummy per cell), or the true \(E[Z \mid X]\) happens to be linear in \(X\).
17.2.2 A Simulation
We build a DGP where \(E[Z \mid X]\) is strongly nonlinear in \(X\), so the linear-in-\(X\) specification has to fail, and then compare four estimators against the true LATE.
We draw \(n = 8000\) observations with a single covariate \(X \sim U(-1,1)\). The instrument is \(Z \sim \text{Bernoulli}(p_Z(X))\) with \(p_Z(X) = \Lambda(0.3 + X + 2\sin(2.5\pi X))\) — the sine term is what a linear projection cannot reproduce. Potential treatments come from one uniform draw \(U\) compared against two thresholds, \(T_0 = \mathbb{1}\{U < \Lambda(-1.6+X)\}\) and \(T_1 = \mathbb{1}\{U < \min(\Lambda(-0.4+X)+0.2,\, 0.95)\}\), so \(T_1 \ge T_0\) and monotonicity holds by construction. Observed treatment is \(W = ZT_1 + (1-Z)T_0\). The effect is heterogeneous in \(X\), \(\tau(X) = 0.5+1.5X\), and the potential outcomes are \(Y(0) = 1 + 2X + 0.8X^2 + \varepsilon\) with \(\varepsilon \sim N(0,1)\) and \(Y(1) = Y(0) + \tau(X)\).
Two features matter. \(X\) enters both the instrument propensity and the treatment thresholds, so \(Z\) is exogenous only conditional on \(X\). And \(\tau\) depends on \(X\), so which units the instrument moves determines the answer.
Code
usingMLJusingDecisionTreeusingRandomusingStatisticsusingLinearAlgebraRandom.seed!(13)n =8000plogis(z) =1/ (1+exp(-z))# Single covariate on [-1, 1]X =2.*rand(n) .-1# True conditional mean of Z is wildly nonlinear in X.# A linear projection L[Z|X] cannot reproduce this.pZ_true =plogis.(0.3.+1.0.* X .+2.0.*sin.(2.5.*π.* X))Z =Int.(rand(n) .< pZ_true)# Potential treatment states with monotonicity (T1 >= T0).# X enters the propensity, so X confounds W <-> Y.U =rand(n)p0 =plogis.(-1.6.+1.0.* X)p1 =min.(plogis.(-0.4.+1.0.* X) .+0.2, 0.95)T0 =Int.(U .< p0)T1 =Int.(U .< p1)W =ifelse.(Z .==1, T1, T0)G = [t1 ==1&& t0 ==1 ? :AT : t1 ==0&& t0 ==0 ? :NT ::CP for (t1, t0) inzip(T1, T0)]# Heterogeneous treatment effect — varies with Xτ =0.5.+1.5.* XY0 =1.0.+2.0.* X .+0.8.* X .^2.+randn(n)Y1 = Y0 .+ τY =ifelse.(W .==1, Y1, Y0)true_LATE =mean(τ[G .==:CP])@printf("Compliance shares AT=%.3f CP=%.3f NT=%.3f\n",mean(G .==:AT), mean(G .==:CP), mean(G .==:NT))@printf("True unconditional LATE = %.3f\n", true_LATE)
Compliance shares AT=0.188 CP=0.425 NT=0.388
True unconditional LATE = 0.617
The compliance shares are 18.8% always-takers, 42.5% compliers and 38.8% never-takers, and the true LATE, the mean of \(\tau\) over compliers, is 0.617.
We now compare four estimators against it: the unconditional Wald ratio, 2SLS with \(X\) entered linearly, 2SLS with a degree-7 polynomial in \(X\), and DDML PLIV with random-forest nuisance learners. Julia has no counterpart of R’s DoubleML package, so we write the PLIV cross-fitting out.
Code
# Helper: TSLS via the matrix expression (Xmat is the exogenous matrix incl.# constant). Returns the coefficient on W and its conventional standard error.functiontsls_matrix(Y, W, Z, Xmat) Wmat =hcat(W, Xmat) Zmat =hcat(Z, Xmat) What = Zmat * ((Zmat'* Zmat) \ (Zmat'* Wmat)) β = (What'* Wmat) \ (What'* Y)e= Y .- Wmat * β σ2=sum(abs2, e) / (length(Y) -size(Wmat, 2))return β[1], sqrt(σ2*inv(What'* What)[1, 1])end# (a) Wald — biased: Z is not unconditionally exogenous because X confounds.wald = (mean(Y[Z .==1]) -mean(Y[Z .==0])) / (mean(W[Z .==1]) -mean(W[Z .==0]))# (b) TSLS with X entered linearly — the textbook spec.b_lin, se_lin =tsls_matrix(Float64.(Y), Float64.(W), Float64.(Z), hcat(ones(n), X))# (c) TSLS with a rich basis (polynomial up to degree 7) — closer to saturation.b_poly, se_poly =tsls_matrix(Float64.(Y), Float64.(W), Float64.(Z),hcat([X .^ k for k in0:7]...))# (d) DDML PLIV with random-forest nuisance learners and 5-fold cross-fitting.RandomForestRegressor =@load RandomForestRegressor pkg=DecisionTree verbosity=0learner =RandomForestRegressor(n_trees =500, max_depth =5)nsplits =5s =shuffle(1:n)folds = [s[1+floor(Int, (k-1)*n/nsplits) :floor(Int, k*n/nsplits)] for k in1:nsplits]mY =zeros(n); mW =zeros(n); mZ =zeros(n)Xtab =DataFrame(X = X)for fold_idx in1:nsplits test = folds[fold_idx] train =setdiff(1:n, test)for (out, dest) in ((Y, mY), (W, mW), (Z, mZ)) mach =machine(learner, Xtab[train, :], Float64.(out[train])) MLJ.fit!(mach, verbosity =0) dest[test] = MLJ.predict(mach, Xtab[test, :])endendrY = Y .- mY; rW = W .- mW; rZ = Z .- mZb_pliv =sum(rZ .* rY) /sum(rZ .* rW)ψ = (rY .- b_pliv .* rW) .* rZ # PLIV scorese_pliv =sqrt(mean(ψ .^2) /mean(rW .* rZ)^2/ n)results =DataFrame( Estimator = ["True LATE","Wald (no covariates)","TSLS, X linear","TSLS, poly(X, 7)","DDML PLIV (cross-fit, random forest)"], Estimate =round.([true_LATE, wald, b_lin, b_poly, b_pliv], digits =3), SE = [missing, missing, round(se_lin, digits =3), round(se_poly, digits =3),round(se_pliv, digits =3)])
5×3 DataFrame
Row
Estimator
Estimate
SE
String
Float64
Float64?
1
True LATE
0.617
missing
2
Wald (no covariates)
1.91
missing
3
TSLS, X linear
0.552
0.059
4
TSLS, poly(X, 7)
0.585
0.067
5
DDML PLIV (cross-fit, random forest)
0.582
0.07
The linear-in-\(X\) 2SLS does not recover the true LATE — and neither do the more flexible versions. Two things are going on, and the standard errors in the table help separate them. First, the estimands differ: for this DGP the linear-projection 2SLS converges to 0.55, and the polynomial 2SLS and DDML PLIV converge to approximately \(\beta_{rich} = 0.58\) (computable by integrating the weight formula below), all below the LATE of 0.617 — a real but modest gap that persists at any sample size. Second, sampling noise: the SEs are 0.06 to 0.07, and in this draw each estimate lands within 0.01 of its own estimand, at 0.552, 0.585 and 0.582, so here the whole gap to the LATE is the difference in estimands. The Wald estimator is far off for a different reason entirely, at 1.910 against a truth of 0.617: \(Z\) is not unconditionally exogenous, and Wald has no way to use \(X\).
What are the polynomial 2SLS and DDML PLIV estimating, if not LATE? PLIV targets \(\beta_{rich}\), a weighted average of conditional LATEs with weights proportional to \(\text{Var}(Z \mid X) \cdot P(\text{complier} \mid X)\); the polynomial 2SLS targets nearly the same quantity (a degree-7 polynomial cannot fully reproduce this \(E[Z \mid X]\), so its estimand is a misspecified-projection variant sitting just below \(\beta_{rich}\)). These are non-negatively weighted, so weakly causal. But they are not the unconditional LATE we usually want.
17.2.3 Diagnostic: RESET on Z ~ X
Rich covariates says \(E[Z \mid X]\) is linear in \(X\). Ramsey’s RESET test (Ramsey 1969) checks one implication of that: whether a few higher-order terms add to a regression of \(Z\) on \(X\). It can detect some departures from linearity. It cannot establish linearity, and it says nothing about exclusion, instrument independence or monotonicity.
Code
usingGLM# RESET with type = "regressor", power = 2:3: F-test of X^2 and X^3 added to Z ~ Xdf_reset =DataFrame(Z =Float64.(Z), X = X, X2 = X .^2, X3 = X .^3)m_restricted =lm(@formula(Z ~ X), df_reset)m_unrestricted =lm(@formula(Z ~ X + X2 + X3), df_reset)rss_r, rss_u =sum(abs2, residuals(m_restricted)), sum(abs2, residuals(m_unrestricted))q, k_u =2, 4F_stat = ((rss_r - rss_u) / q) / (rss_u / (n - k_u))@printf("RESET = %.2f, df1 = %d, df2 = %d, p-value = %.3g\n", F_stat, q, n - k_u, ccdf(FDist(q, n - k_u), F_stat))
It rejects strongly here, \(\text{RESET} = 131.6\) on 2 and 7,996 degrees of freedom with \(p < 10^{-56}\), which is the right answer given that we put a sine wave in \(E[Z \mid X]\). The same test on real data is cheap. A rejection is a clear warning against reading 2SLS as the LATE; a non-rejection is weaker evidence, because the test looks only at the terms we included.
17.2.4 What to Do Instead
Blandhol et al. (2025) give four steps for empirical work.
Reconsider the covariates. If \(Z\) is unconditionally exogenous, drop them. A kitchen-sink set of controls makes rich covariates less likely.
Run RESET on Z ~ X. A rejection rules out reading linear IV as the LATE. A non-rejection is consistent with rich covariates but does not prove it, and the other IV assumptions still need their own argument.
If RESET rejects, report DDML PLIV alongside 2SLS. That is what the cross-fitting chunk above does. DDML PLIV targets \(\beta_{rich}\), a non-negatively weighted average of conditional LATEs.
For a binary instrument, also estimate the unconditional LATE. With instrument propensity score weighting (Słoczyński 2024),
where \(\hat p(X) = P(Z = 1 \mid X)\) is estimated nonparametrically. Stata has kappalate (Słoczyński, Uysal and Wooldridge), which implements this and related weighting estimators of the LATE. In Julia it is straightforward to build once \(\hat p(X)\) is in hand.
17.2.5 A Note on the FRDD Example
The fuzzy-RDD example at the end of this chapter is 2SLS with race, state of birth, and quarter-of-birth fixed effects entered as covariates. That section traces the gap between the 2SLS and the local rdrobust estimates to the first stage, which is close to zero near the cutoff. Rich covariates is a separate question about the 2SLS estimate itself, and the RESET test on the above-cutoff instrument against those covariates is the right first thing to run.
17.2.6 Bottom Line
“2SLS with covariates estimates LATE” needs the rich covariates condition. That condition is a parametric assumption on \(E[Z \mid X]\) that researchers rarely defend, and a simple RESET test often rejects it. The honest alternatives are DDML PLIV for \(\beta_{rich}\) and IPSW (or DDML) for the unconditional LATE. Even when rich covariates holds, \(\beta_{rich}\) can be quite different from the unconditional LATE we usually care about.
17.3 Regression Discontinuity Design
RDD (regression discontinuity design) is a quasi-experimental design that is used to estimate causal effects of interventions when assignment to the intervention is determined by whether a subject’s value on an observed covariate exceeds a threshold. The idea is that the assignment is as good as random, so we can estimate the causal effect of the intervention by comparing the outcomes of subjects who are just above and just below the threshold.
17.3.1 Sharp RDD
We have a continuous variable \(X\), called the running variable, which determines the binary treatment \(W\). The treatment is assigned according to a threshold \(c\). The outcome variable \(Y\) is a function of \(X\) and \(W\).
\[ W=\mathbb{1}(X>c) \tag{17.9}\]
Lee (2008) studies the effect of incumbency advantage in elections. His identification strategy is based on the discontinuity generated by the rule that the party with a majority vote share wins. The forcing variable \(X_i\) is the difference in vote share between the Democratic and Republican parties in one election, with the threshold \(c = 0\). The outcome variable \(Y_i\) is vote share at the second election.
rdplot bins the running variable and returns bin means and a polynomial fit on each side of the cutoff, which we plot. A visible jump at zero is the design working.
Code
senate = CSV.read("data/rdrobust_senate.csv", DataFrame)# Calculate RD plot dataplot_data =rdplot(senate.vote, senate.margin, c=0.0)fig =Figure()ax =Axis(fig[1, 1], xlabel="Margin", ylabel="Vote")scatter!(ax, plot_data.vars_bins.rdplot_mean_x, plot_data.vars_bins.rdplot_mean_y, color=:gray, markersize=6)# Plot polynomial fit for left sidepoly_l =filter(r -> r.rdplot_x <0.0, plot_data.vars_poly)lines!(ax, poly_l.rdplot_x, poly_l.rdplot_y, color=:blue, linewidth=2)# Plot polynomial fit for right sidepoly_r =filter(r -> r.rdplot_x >=0.0, plot_data.vars_poly)lines!(ax, poly_r.rdplot_x, poly_r.rdplot_y, color=:blue, linewidth=2)vlines!(ax, [0.0], color=:black, linestyle=:dash)fig
The rdrobust_RDsenate data are 1,297 US Senate races. The running variable margin is the Democratic margin of victory in an election and vote is the Democratic vote share in the next election for the same seat. The bin means step up discontinuously at a margin of zero.
In words, the treatment effect is the difference in the outcome from the right side and from the left side. This is the same as the difference in the outcome at the threshold, as if the treatment is assigned randomly.
17.3.3 Estimation of SRDD
Before the real data, a simulation where we know the answer. We draw \(n = 1000\) students with \(\text{GPA} \sim U(0,4)\) and outcome \(Y = 10 + 1.5\,\text{GPA} + 2 \cdot \mathbb{1}\{\text{GPA} > 3\} + \varepsilon\) with \(\varepsilon \sim N(0,1)\). The cutoff is 3 and the true jump is 2. The running variable also has a direct effect on the outcome, with slope 1.5, which is what the local regression on each side has to absorb.
Code
Random.seed!(2024)GPA =rand(Uniform(0, 4), 1000)# Treatment is W = 1(GPA > 3), so the +2 jump must sit on the right# (above-cutoff) side to match the right-minus-left estimand above.future_success =10.+1.5.* GPA .+2.* (GPA .>3) .+rand(Normal(0, 1), 1000)plot_data_gpa =rdplot(future_success, GPA, c =3.0)fig2 =Figure()ax2 =Axis(fig2[1, 1], xlabel ="GPA", ylabel ="Future Success")scatter!(ax2, plot_data_gpa.vars_bins.rdplot_mean_x, plot_data_gpa.vars_bins.rdplot_mean_y, color =:gray, markersize =6)poly_gpa_l =filter(r -> r.rdplot_x <3.0, plot_data_gpa.vars_poly)lines!(ax2, poly_gpa_l.rdplot_x, poly_gpa_l.rdplot_y, color =:blue, linewidth =2)poly_gpa_r =filter(r -> r.rdplot_x >=3.0, plot_data_gpa.vars_poly)lines!(ax2, poly_gpa_r.rdplot_x, poly_gpa_r.rdplot_y, color =:blue, linewidth =2)vlines!(ax2, [3.0], color =:black, linestyle =:dash)fig2
Code
# a compact summary, like R's summary() of an rdrobust fitfunctionrd_summary(r)@printf("Bandwidth h = %.3f, b = %.3f; N = %d left, %d right; effective N = %d left, %d right\n", r.bws.h_left[1], r.bws.b_left[1], r.N[1], r.N[2], r.N_h[1], r.N_h[2])DataFrame(Method = r.coef.Method, Coef =round.(r.coef.Coeff, digits =4), SE =round.(r.se.StdErr, digits =4), p =round.(r.pv.PValue, sigdigits =3), CI_low =round.(r.ci.CILower, digits =3), CI_high =round.(r.ci.CIUpper, digits =3))end# estimate the sharp RDD modelrdd_gpa =rdrobust(future_success, GPA, c =3.0)rd_summary(rdd_gpa)
Bandwidth h = 0.373, b = 0.536; N = 736 left, 264 right; effective N = 94 left, 98 right
3×6 DataFrame
Row
Method
Coef
SE
p
CI_low
CI_high
String
Float64
Float64
Float64
Float64
Float64
1
Conventional
2.0776
0.3272
2.17e-10
1.436
2.719
2
Bias-Corrected
2.0456
0.3272
4.08e-10
1.404
2.687
3
Robust
2.0456
0.3925
1.88e-7
1.276
2.815
The estimated jump is 2.078 with a robust 95% interval of \([1.276, 2.815]\), covering the true 2. Note how little data the estimate uses: the MSE-optimal bandwidth is 0.373, so of the 1,000 observations only 94 on the left and 98 on the right are effective. A local estimator pays for its weak assumptions with a small effective sample, which is why the interval is 1.5 wide for a jump of 2.
17.3.4 Nonparametric Estimation
Now the same estimator on the Senate data, with the cutoff at a margin of zero.
Code
rdd_house =rdrobust(senate.vote, senate.margin, c =0.0)rd_summary(rdd_house)
Bandwidth h = 17.754, b = 28.028; N = 595 left, 702 right; effective N = 360 left, 323 right
3×6 DataFrame
Row
Method
Coef
SE
p
CI_low
CI_high
String
Float64
Float64
Float64
Float64
Float64
1
Conventional
7.4141
1.4587
3.72e-7
4.555
10.273
2
Bias-Corrected
7.5065
1.4587
2.66e-7
4.647
10.366
3
Robust
7.5065
1.7413
1.63e-5
4.094
10.919
The incumbency effect is 7.414 percentage points with a robust 95% interval of \([4.094, 10.919]\). Barely winning a Senate seat raises the party’s vote share in the next election for that seat by about 7 points. The bandwidth is 17.75 margin points, leaving 360 observations on the left and 323 on the right out of 1,297.
17.3.5 Fuzzy RDD
In fuzzy RDD, the treatment is assigned according to a threshold \(c\), but there exist non-compliance. This is similar to IV case.
For example, if food stamp eligibility is given to all households below a certain income, but not all households receive the food stamps. In other words, income does not solely determine the assignment. Cutoff point increases the probability of treatment but doesn’t completely determine treatment.
FRDD is IV.
17.3.6 FRDD Example
The main question of Fetter (2013) is how much of the increase in the home ownership rate in the midcentury US was due to mortgage subsidies given out by the government.
We’re using the running variable quarter of birth (qob), which has been centered on the quarter of birth you’d need to be to be eligible for a mortgage subsidy for fighting in the Korean War (qob_minus_kw). This determines whether you were a veteran of either the Korean War or World War II (vet_wwko).
Code
vet = CSV.read("data/mortgages.csv", DataFrame) # causaldata::mortgages# Create an "above-cutoff" variable as the instrumentvet.above =Float64.(vet.qob_minus_kw .>0)# Impose a bandwidth of 12 quarters on either sidevet = vet[abs.(vet.qob_minus_kw) .<12, :]# The running variable qob_minus_kw is exogenous, so it goes with the controls.# The endogenous regressors are veteran status and its interaction with the# running variable, instrumented by being above the cutoff and that interaction.vet.vet_inter = vet.qob_minus_kw .* vet.vet_wwkovet.above_inter = vet.qob_minus_kw .* vet.abovem =feiv(vet, @formula(home_ownership ~ nonwhite + qob_minus_kw +fe(bpl) +fe(qob)); endo = [:vet_wwko, :vet_inter], inst = [:above, :above_inter], vcov_type = Vcov.robust()) # heteroskedasticity-robust SEs
Panelest IV/2SLS Model
Number of obs: 56901
Endogenous: vet_wwko, vet_inter
Instruments: above, above_inter
────────────────────────────────────────────────────────
Estimate Std. Error z value Pr(>|z|)
────────────────────────────────────────────────────────
vet_wwko 0.170172 0.0459329 3.70 0.0002
vet_inter -0.00285263 0.00263744 -1.08 0.2794
nonwhite -0.190434 0.00689193 -27.63 <1e-99
qob_minus_kw -0.00715077 0.00177347 -4.03 <1e-04
────────────────────────────────────────────────────────
--- Diagnostics ---
First-stage F (vet_wwko): 315.7
First-stage F (vet_inter): 1861.18
Wu-Hausman: F(2, 56840) = 6.7536 [p = 0.0012]
The 2SLS estimate is 0.1702 with a heteroskedasticity-robust standard error of 0.0459: veteran status raises home ownership by 17 percentage points. The sample is 56,901 people within 12 quarters of the cutoff, with birthplace and quarter-of-birth fixed effects. The first-stage \(F\) statistics are 316 and 1,861, so the instruments are strong, and the Wu-Hausman test rejects exogeneity of veteran status at \(p = 0.001\). The interaction of veteran status with the running variable is not significant, so there is little evidence that the slope differs across the cutoff.
Now the same design estimated locally with rdrobust. We pass race and state of birth as covariates, but not quarter of birth. Quarter of birth is a function of the running variable, and the local window holds only three quarters on each side of the cutoff. There the quarter-of-birth dummies duplicate the local linear fits, and the jump is not identified with them in. rdrobust still returns a number, but the number is arbitrary: with the dummies included, R’s rdrobust gives 0.096 or 0.838, depending only on whether the covariate matrix carries an intercept column. RDRobust.jl gives a third value and warns that the estimate is not identified.
Code
# race and state of birth; quarter of birth is left out (see text)states =sort(unique(vet.bpl))conmatrix =hcat(Float64.(vet.nonwhite), [Float64.(vet.bpl .== s) for s in states[2:end]]...)m_rdd =rdrobust(vet.home_ownership, vet.qob_minus_kw, fuzzy = vet.vet_wwko, c =0.0, covs = conmatrix)rd_summary(m_rdd)
Bandwidth h = 2.612, b = 5.371; N = 28776 left, 28125 right; effective N = 6911 left, 6756 right
3×6 DataFrame
Row
Method
Coef
SE
p
CI_low
CI_high
String
Float64
Float64
Float64
Float64
Float64
1
Conventional
2.3684
4.9681
0.634
-7.369
12.106
2
Bias-Corrected
6.5115
4.9681
0.19
-3.226
16.249
3
Robust
6.5115
5.7613
0.258
-4.78
17.803
rdrobust returns a conventional estimate of 2.37 with a standard error of 4.97, and a bias-corrected estimate of 6.51 with a robust standard error of 5.76. The robust 95% interval runs from \(-4.78\) to 17.80. For an effect on a probability, that says nothing.
The reason is the first stage. A fuzzy RD divides the jump in the outcome by the jump in treatment at the cutoff. Here we estimate the second jump directly, with the same covariates and bandwidth.
Code
# first stage: the jump in veteran status at the cutofffs =rdrobust(Float64.(vet.vet_wwko), vet.qob_minus_kw, c =0.0, covs = conmatrix, h = m_rdd.bws.h_left[1])display(rd_summary(fs))# veteran share by quarter near the cutoffcombine(groupby(filter(:qob_minus_kw => q ->abs(q) <4, vet), :qob_minus_kw, sort =true),:vet_wwko => mean =>:vet_share)
Bandwidth h = 2.612, b = 2.612; N = 28776 left, 28125 right; effective N = 6911 left, 6756 right
3×6 DataFrame
Row
Method
Coef
SE
p
CI_low
CI_high
String
Float64
Float64
Float64
Float64
Float64
1
Conventional
-0.0102
0.0205
0.618
-0.05
0.03
2
Bias-Corrected
-0.0025
0.0205
0.904
-0.043
0.038
3
Robust
-0.0025
0.0332
0.941
-0.067
0.063
8×2 DataFrame
Row
qob_minus_kw
vet_share
Float64
Float64
1
-3.5
0.561224
2
-2.5
0.558109
3
-1.5
0.524569
4
-0.5
0.480088
5
0.5
0.417344
6
1.5
0.352348
7
2.5
0.2943
8
3.5
0.276429
Within 2.6 quarters of the cutoff, veteran status does not jump: the estimate is \(-0.010\) with a standard error of 0.021. The veteran share falls from 0.56 two and a half quarters before the cutoff to 0.29 two and a half quarters after, but it falls steadily across those quarters, with no break at zero. The fuzzy estimate divides a noisy jump in home ownership by a jump in treatment that is indistinguishable from zero.
2SLS finds a strong first stage because it fits one line on each side over 12 quarters and reads the jump off where the two lines meet. The steep decline near the cutoff then registers as a large jump. Its 0.17 rests on that linear specification. The local estimator drops the assumption, and the data near the cutoff then have nothing to say. The two estimates do not contradict each other. The local one is uninformative here.
17.3.7 A discrete running variable
Quarter of birth is coarse. The running variable takes 24 values in this sample, and inside the rdrobust bandwidth there are only three on each side, so continuity-based local polynomials have little to fit. Two other tools suit this design: a manipulation test (McCrary 2008; Cattaneo, Jansson, and Ma 2020) and local-randomization inference (Cattaneo, Titiunik, and Vazquez-Bare 2016); Kolesár and Rothe (2018) give honest intervals for discrete running variables. Their reference implementations are R packages, and the R companion runs them on these data. The density test shows no sorting (\(p = 0.61\)). In the window of one quarter on each side, veteran status is 0.063 lower to the right of the cutoff and home ownership 0.035 lower, but the veteran share falls by about 0.054 per quarter on its own, so that “first stage” is the trend, not a jump. With quarterly data no window is narrow enough to make the trend negligible.
17.4 Summary
An instrument recovers an effect when the confounder is unobserved. It must move the treatment (relevance), reach the outcome only through the treatment (exclusion) and be as good as random. With heterogeneous effects and no defiers, the Wald ratio identifies the LATE, the effect on compliers. Adding covariates linearly keeps that interpretation only under the rich-covariates condition, that the instrument’s conditional mean is linear in the covariates. A RESET test on the instrument checks it. Regression discontinuity replaces the instrument with a cutoff in a running variable and assumes continuity at the cutoff. Fuzzy RDD is IV at the cutoff.
In the simulation, OLS gives 1.3571, and 2SLS gives 0.9999 against a true 1. With a nonlinear instrument propensity, the true LATE is 0.617 and the linear 2SLS converges to 0.55. The Senate incumbency effect is 7.4 percentage points. In the Korean War example, 2SLS gives 0.1702 (0.0459). The local rdrobust estimate, 2.37 (4.97), is uninformative, because veteran status does not jump at the cutoff within the local window. The 2SLS first stage comes from linear fits over 12 quarters.
Angrist, Joshua D., and Jörn-Steffen Pischke. 2009. Mostly Harmless Econometrics: An Empiricist’s Companion. Princeton University Press.
Blandhol, Christine, John Bonney, Magne Mogstad, and Alexander Torgovitsky. 2025. “When Is TSLS Actually LATE?”
Cattaneo, Matias D., Michael Jansson, and Xinwei Ma. 2020. “Simple Local Polynomial Density Estimators.”Journal of the American Statistical Association 115 (531): 1449–55. https://doi.org/10.1080/01621459.2019.1635480.
Cattaneo, Matias D., Rocío Titiunik, and Gonzalo Vazquez-Bare. 2016. “Inference in Regression Discontinuity Designs Under Local Randomization.”The Stata Journal 16 (2): 331–67. https://doi.org/10.1177/1536867X1601600205.
Fetter, Daniel K. 2013. “How Do Mortgage Subsidies Affect Home Ownership? Evidence from the Mid-Century GI Bills.”American Economic Journal: Economic Policy 5 (2): 111–47. https://doi.org/10.1257/pol.5.2.111.
Kolesár, Michal, and Christoph Rothe. 2018. “Inference in Regression Discontinuity Designs with a Discrete Running Variable.”American Economic Review 108 (8): 2277–2304. https://doi.org/10.1257/aer.20160945.
Lee, David S. 2008. “Randomized Experiments from Non-Random Selection in U.S. House Elections.”Journal of Econometrics 142 (2): 675–97.
McCrary, Justin. 2008. “Manipulation of the Running Variable in the Regression Discontinuity Design: A Density Test.”Journal of Econometrics 142 (2): 698–714. https://doi.org/10.1016/j.jeconom.2007.05.005.
Ramsey, J. B. 1969. “Tests for Specification Errors in Classical Linear Least-Squares Regression Analysis.”Journal of the Royal Statistical Society, Series B 31 (2): 350–71.
Słoczyński, Tymon. 2024. “When Should We (Not) Interpret Linear IV Estimands as LATE?”Quantitative Economics.