Math for Causal Inference

Day 73. Sharp Regression Discontinuity

When treatment switches on at a known threshold of a running variable, units just above and just below are comparable. The jump in the outcome at the cutoff identifies the effect there, under one assumption: potential outcomes are continuous in the running variable.

Video coming soon
Learning outcomes
  • ●Define the sharp RD estimand and state the continuity assumption.
  • ●Estimate the jump with separate linear fits on each side and explain why a raw difference in means is biased.
  • ●Prove identification and explain why the effect is local to the cutoff.
  • ●Apply RD to drinking age, incumbency, scholarships and Medicare eligibility.
2-HOUR SESSION PLAN
Theory 25′Warm-up (1–5) 20′Proofs (6–10) 35′Applied (11–15) 25′Python & Lab 15′
Colab notebook (.ipynb) Jump to the simulator

Theory

Design

A running variable XX (age, test score, vote margin, income) determines treatment by a rule: D=1[X≥c]D = \mathbf 1[X \ge c]. There is no overlap: every unit with X≥cX \ge c is treated and every unit below is not. Units cannot be compared at the same XX, but they can be compared arbitrarily close to cc.

Estimand and assumption

τSRD=lim⁡x↓cE[Y∣X=x]−lim⁡x↑cE[Y∣X=x].\tau_{SRD} = \lim_{x \downarrow c}E[Y \mid X = x] - \lim_{x \uparrow c}E[Y \mid X = x].

Continuity: E[Y(0)∣X=x]E[Y(0) \mid X = x] and E[Y(1)∣X=x]E[Y(1) \mid X = x] are continuous at x=cx = c. Then

τSRD=E[Y(1)−Y(0)∣X=c].\tau_{SRD} = E[Y(1) - Y(0) \mid X = c].

Continuity fails if something else also changes at the cutoff (another policy at age 21), or if units manipulate XX to land on the desired side (Day 77).

Estimation

Fit E[Y∣X]E[Y \mid X] separately on each side near cc and take the difference of the two fitted values at cc. The standard choice is local linear regression within a bandwidth hh (Days 74–75):

Yi=α+τDi+β1(Xi−c)+β2Di(Xi−c)+εi,∣Xi−c∣≤h.Y_i = \alpha + \tau D_i + \beta_1(X_i - c) + \beta_2 D_i(X_i - c) + \varepsilon_i, \qquad |X_i - c| \le h.

A raw difference in means within [c−h,c+h][c - h, c + h] is biased whenever E[Y∣X]E[Y \mid X] has a slope; high-order global polynomials fitted to the whole range give erratic estimates and should be avoided (Gelman and Imbens).

What RD identifies

The effect for units at the cutoff, an extreme form of locality. Away from cc the data say nothing without further assumptions. Heterogeneity in effects along XX can be studied only with extrapolation or multiple cutoffs.

Two views

  • Continuity: limits of conditional expectations, estimated by local polynomials.
  • Local randomisation: within a small window, treatment is as good as random (for instance when XX includes a random component that units cannot control precisely); analyse as an experiment.

Part 1 · Warm-up

Exercise 1 · A jump

At the cutoff, the fitted line from the left reaches 90 and the fitted line from the right starts at 98. Estimate the effect.

Show solution

Step 1. τ^=98−90=8\hat\tau = 98 - 90 = 8.

Exercise 2 · Find the design

Name the running variable, cutoff and treatment: (a) Medicare eligibility; (b) a merit scholarship; (c) the effect of being the incumbent party; (d) a class-size cap of 40 pupils.

Show solution

Step 1. (a) Age, 65, Medicare coverage.

Step 2. (b) Exam score, the qualifying score, receiving the scholarship.

Step 3. (c) Vote margin in the previous election, 0, holding the seat.

Step 4. (d) Enrolment, 41 (and 81, ...), being split into smaller classes (fuzzy in practice, Day 76).

Exercise 3 · Separate lines

Left of the cutoff the fitted line is 50+2(x−c)50 + 2(x - c); right of it, 55+1.5(x−c)55 + 1.5(x - c). Estimate the effect and say whether the effect varies with xx.

Show solution

Step 1. At x=cx = c: 55−50=555 - 50 = 5.

Step 2. The slopes differ, but RD identifies only the jump at cc; the difference in slopes does not reveal how the effect varies away from cc without extra assumptions.

Exercise 4 · Bias of a difference in means

E[Y∣X]=a+s(x−c)+τ1[x≥c]E[Y \mid X] = a + s(x - c) + \tau\mathbf 1[x \ge c], with XX uniform near cc. What does the difference in means between [c,c+h][c, c + h] and [c−h,c)[c - h, c) estimate?

Show solution

Step 1. Right mean: a+τ+sh/2a + \tau + sh/2. Left mean: a−sh/2a - sh/2.

Step 2. Difference: τ+sh\tau + sh.

Answer: biased by shsh; with slope 2 and h=1h = 1, by 2. Local linear fits remove this bias.

Exercise 5 · Local effect

An RD at a scholarship cutoff finds an effect on college completion of 10 points. Does a policy lowering the cutoff by 50 points have the same effect?

Show solution

Step 1. The estimate applies to students scoring at the current cutoff.

Step 2. Students 50 points lower may benefit more (or less); the design does not tell us.

Answer: not necessarily; extrapolation needs assumptions or other evidence.

Part 2 · Proofs

Exercise 6 · Identification

Prove τSRD=E[Y(1)−Y(0)∣X=c]\tau_{SRD} = E[Y(1) - Y(0) \mid X = c] under continuity.

Show solution

Step 1. For x≥cx \ge c, E[Y∣X=x]=E[Y(1)∣X=x]E[Y \mid X = x] = E[Y(1) \mid X = x]; for x<cx < c, E[Y∣X=x]=E[Y(0)∣X=x]E[Y \mid X = x] = E[Y(0) \mid X = x].

Step 2. By continuity, lim⁡x↓cE[Y(1)∣X=x]=E[Y(1)∣X=c]\lim_{x \downarrow c}E[Y(1) \mid X = x] = E[Y(1) \mid X = c] and lim⁡x↑cE[Y(0)∣X=x]=E[Y(0)∣X=c]\lim_{x \uparrow c}E[Y(0) \mid X = x] = E[Y(0) \mid X = c].

Step 3. Subtract. ■\blacksquare

Exercise 7 · The general bias of a window comparison

Let μd(x)=E[Y(d)∣X=x]\mu_d(x) = E[Y(d) \mid X = x] be differentiable with slope μd′(c)\mu_d'(c) at cc and XX uniform near cc. Show that, to first order, the window difference in means is τ+h2(μ1′(c)+μ0′(c))\tau + \frac h2(\mu_1'(c) + \mu_0'(c)).

Show solution

Step 1. Right mean ≈μ1(c)+μ1′(c) h/2\approx \mu_1(c) + \mu_1'(c)\,h/2; left mean ≈μ0(c)−μ0′(c) h/2\approx \mu_0(c) - \mu_0'(c)\,h/2.

Step 2. Subtract: τ+h2(μ1′(c)+μ0′(c))\tau + \frac h2(\mu_1'(c) + \mu_0'(c)). ■\blacksquare

Exercise 8 · Separate regressions

Show that the pooled regression Y=α+τD+β1(X−c)+β2D(X−c)Y = \alpha + \tau D + \beta_1(X - c) + \beta_2 D(X - c) within the window gives the same τ^\hat\tau as fitting separate lines on each side and differencing their intercepts at cc.

Show solution

Step 1. The pooled regression has a separate intercept and slope for each side (α,β1\alpha, \beta_1 left; α+τ,β1+β2\alpha + \tau, \beta_1 + \beta_2 right).

Step 2. With no shared parameters, the least-squares problem splits into two separate problems.

Step 3. τ^\hat\tau is the difference of the two fitted intercepts at X=cX = c. ■\blacksquare

Exercise 9 · No extrapolation without assumptions

Construct two models consistent with the same observed E[Y∣X]E[Y \mid X] but with different effects at x=c+1x = c + 1.

Show solution

Step 1. Observed: E[Y∣X]=xE[Y \mid X] = x for x<cx < c and x+5x + 5 for x≥cx \ge c.

Step 2. Model A: μ0(x)=x\mu_0(x) = x everywhere, μ1(x)=x+5\mu_1(x) = x + 5: effect 5 at all xx.

Step 3. Model B: μ0(x)=x\mu_0(x) = x for x<cx < c and x+2(x−c)x + 2(x - c) for x≥cx \ge c (unobserved there); μ1(x)=x+5\mu_1(x) = x + 5: effect 5−2(x−c)5 - 2(x - c), which is 3 at c+1c + 1.

Answer: both match the data; μ0\mu_0 is never observed right of cc. ■\blacksquare

Exercise 10 · Covariates do not change the estimand

Let WW be a pre-treatment covariate with E[W∣X]E[W \mid X] continuous at cc. Explain why adding WW linearly to the local linear regression leaves the estimand unchanged (in large samples) but can reduce variance.

Show solution

Step 1. Including WW changes τ^\hat\tau by its coefficient times the jump in E[W∣X]E[W \mid X] at cc (FWL).

Step 2. Continuity of E[W∣X]E[W \mid X] makes that jump zero in the limit.

Step 3. WW explains outcome variance, shrinking residuals and the standard error.

Answer: same estimand, possibly more precision; a jump in WW would instead signal a violation (Day 77). ■\blacksquare

Part 3 · Applied

Mortality of young adults (deaths per 100,000 person-years) approaches 94 from below age 21 and 103 from above. Estimate the effect of legal access to alcohol and state the key assumption.

Show solution

Step 1. τ^=103−94=9\hat\tau = 103 - 94 = 9 deaths per 100,000, about 9.6%.

Step 2. Assumption: nothing else that affects mortality changes discontinuously at 21.

Answer: about 9 extra deaths per 100,000 (mostly motor-vehicle accidents and suicides in studies of this design); only age-21-specific changes (for example, casino access in some states) would threaten it.

Exercise 12 · The incumbency advantage

In US House elections, the Democratic vote share in the next election approaches 0.47 for districts where Democrats lost narrowly and 0.55 where they won narrowly. Estimate and interpret.

Show solution

Step 1. τ^=0.55−0.47=0.08\hat\tau = 0.55 - 0.47 = 0.08.

Step 2. Bare winners and bare losers are similar; winning confers incumbency.

Answer: incumbency raises the next-election vote share by about 8 points for marginal seats.

Exercise 13 · A merit scholarship

College enrolment approaches 0.60 just below the qualifying score and 0.68 just above. Estimate the effect, and say for whom.

Show solution

Step 1. τ^=0.08\hat\tau = 0.08.

Answer: an 8-point rise in enrolment for students scoring at the threshold, typically above-average students; effects for students far below the threshold are not identified.

Exercise 14 · Medicare at 65

Insurance coverage rises from 88% to 97% at age 65, and hospital admissions jump by 8%. Is this a sharp RD for "having insurance"? What can be estimated?

Show solution

Step 1. Medicare eligibility is sharp at 65, but insurance coverage jumps only from 88% to 97%: for coverage, the design is fuzzy.

Step 2. The sharp RD estimates the effect of eligibility (reaching 65) on admissions: +8%.

Answer: the effect of insurance itself requires scaling by the jump in coverage (Day 76), and must account for changes in the type of coverage (secondary insurance), not just its presence.

Exercise 15 · Global polynomials

In the simulation below, compare the local linear estimate within a bandwidth with a global fourth-order polynomial and with a raw window difference in means. Which behaves badly and why?

Show solution

Step 1. The local linear estimate is close to the true jump on average.

Step 2. The window difference in means is biased by the slope (Exercise 4).

Step 3. The global quartic is roughly unbiased here but noisier (SD about 1.0 versus 0.7): it puts large weight on observations far from the cutoff and is sensitive to the polynomial order.

Answer: prefer local linear (or local quadratic) fits with a data-driven bandwidth (Day 75).

Verify in Python

import numpy as np

rng = np.random.default_rng(73)
c, tau = 0.0, 5.0
mu0 = lambda x: 50 + 8 * x + 6 * x ** 2 - 4 * x ** 3          # smooth untreated outcome
def sample(n=1000):
    x = rng.uniform(-1, 1, n); y = mu0(x) + tau * (x >= c) + rng.normal(0, 3, n)
    return x, y
def local_linear(x, y, h):
    m = np.abs(x - c) <= h; d = (x >= c).astype(float)
    X = np.column_stack([np.ones(m.sum()), d[m], x[m] - c, d[m] * (x[m] - c)])
    return np.linalg.lstsq(X, y[m], rcond=None)[0][1]
def window_means(x, y, h):
    return y[(x >= c) & (x <= c + h)].mean() - y[(x < c) & (x >= c - h)].mean()
def global_poly(x, y, p=4):
    d = (x >= c).astype(float)
    X = np.column_stack([np.ones_like(x), d] + [x ** k for k in range(1, p + 1)] + [d * x ** k for k in range(1, p + 1)])
    return np.linalg.lstsq(X, y, rcond=None)[0][1]
res = {"local linear h=0.3": [], "window means h=0.3": [], "global quartic": []}
for _ in range(1000):
    x, y = sample()
    res["local linear h=0.3"].append(local_linear(x, y, .3))
    res["window means h=0.3"].append(window_means(x, y, .3))
    res["global quartic"].append(global_poly(x, y))
for k, v in res.items():
    print(f"{k:20s} mean {np.mean(v):6.2f}  sd {np.std(v):5.2f}  (truth {tau})")
print("Ex 4 bias s*h:", 2 * 1, " | Ex 11:", 103 - 94, f"({(103 - 94) / 94:.1%})")

Key takeaways

  • Sharp RD identifies the effect at the cutoff as the jump in E[Y∣X]E[Y \mid X], assuming potential outcomes are continuous there.
  • Estimate with local linear fits on each side; raw window means are biased by the slope, global polynomials are fragile.
  • The effect is local; extrapolating away from the cutoff needs extra assumptions.

Simulation Lab: Sharp Regression Discontinuity

Open full screen →

Local linear fits versus window means and global polynomials at a scholarship cutoff.

506070-1-0.500.51running variable (score − cutoff)outcome
estimated jump
4.27
truth
5.00

Scholarship-style data: treatment switches on at x = 0. Local linear fits within the bandwidth (left and right) estimate the jump; a raw comparison of means inside the window is biased by the slope; global fourth-order polynomials use the whole range and are noisier. The true jump is set by the slider.

Day 72Day 74