Skip to main content

Regression Discontinuity: Does Winning by a Hair Help You Win Again?

Regression discontinuity in R on 1,390 elections to the US Senate: why a narrow win is like a coin toss, comparing means in a window, local linear regression by hand with the triangular kernel, the same numbers as rdrobust, how the bandwidth trades bias against noise, robust bias-corrected intervals and what they are, the density test by hand and with rddensity, placebo outcomes, placebo cutoffs and the donut, why global polynomials are a bad idea, a simulation of the coverage of the intervals, what the number means, and APA reporting.

The question: a win by a hair

A party that holds a seat has a better chance to keep it. Is that because it holds the seat: more press, more donations, more favors? Or because it holds the seat where people like the party anyway? The states that the Democrats won and the states that they lost differ in everything. Comparing them says nothing about the seat itself.

But some elections were very close. A party that won by 0.3 points and a party that lost by 0.3 points had about the same voters, the same year and the same kind of candidates. Rain in one city, and the result would have been the other way round. At the cutoff of zero, winning is close to a coin toss. So compare those who just won with those who just lost (Lee, 2008).

The design is called regression discontinuity (RD). It works whenever a treatment is given by a threshold in a running variable (score, age, income, votes) that nobody controls exactly. Thistlethwaite and Campbell (1960) invented it to find out what a certificate of merit, given to pupils above a test score, does for their further way.

Code
library(ggplot2)
library(rdrobust)    # rdrobust(): local polynomial estimation with robust intervals
library(rddensity)   # rddensity(): does the density of the running variable jump?
# also used, with package::function: sandwich (robust variances)

# number formats for the text
f1   <- function(x) formatC(x, format = "f", digits = 1, big.mark = ",")
f2   <- function(x) formatC(x, format = "f", digits = 2, big.mark = ",")
pval <- function(p) {
  ifelse(p < .001, "< .001", paste("=", sub("^0", "", formatC(p, format = "f", digits = 3))))
}
num  <- function(x) trimws(format(x, big.mark = ","))
pct  <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")

1. The data

Code
senate <- read.csv(
  "https://raw.githubusercontent.com/rdpackages/rdrobust/master/R/rdrobust_senate.csv"
)
str(senate)
'data.frame':   1390 obs. of  8 variables:
 $ state      : int  1 1 1 1 1 1 1 1 1 1 ...
 $ year       : int  1914 1916 1922 1926 1928 1932 1934 1938 1944 1952 ...
 $ vote       : num  36.1 45.5 45.6 48.5 51.7 ...
 $ margin     : num  -7.69 -3.92 -6.87 -27.67 -8.26 ...
 $ class      : int  3 1 1 3 1 3 1 3 3 1 ...
 $ termshouse : int  3 0 0 0 0 4 1 0 0 0 ...
 $ termssenate: int  6 4 7 3 1 1 1 1 1 2 ...
 $ population : int  1233000 1294000 1431000 1531000 1577000 1637000 1650000 1684000 1778000 2081000 ...
Code
senate$won <- as.numeric(senate$margin >= 0)
s <- subset(senate, !is.na(vote))
c(elections = nrow(senate), with_next_election = nrow(s), democrat_won = sum(s$won))
         elections with_next_election       democrat_won 
              1390               1297                702 

The elections to the US Senate from 1914 to 2010 (Cattaneo et al., 2015; the file comes with the R package rdrobust). For every election:

  • margin: the running variable, the vote share of the Democratic candidate minus the share of the strongest opponent, in percentage points. Above 0 the Democrat won.
  • vote: the outcome, the Democratic share in the next election for the same seat, normally six years later. It is missing for 93 elections.
  • termshouse, termssenate: earlier terms of the Democratic candidate in the House and in the Senate. population: of the state. class: which third of the Senate the seat belongs to.

2. Look at the data

Code
bins <- function(d, width) {
  b <- floor(d$margin / width)
  data.frame(
    margin = tapply(d$margin, b, mean),
    vote = tapply(d$vote, b, mean),
    n = as.numeric(table(b))
  )
}
near <- subset(s, abs(margin) < 50); bm <- bins(near, 2.5)
ggplot(near, aes(margin, vote)) +
  geom_point(alpha = 0.15, size = 0.8) +
  geom_point(data = bm, aes(size = n), colour = "#2a78d6") +
  geom_vline(xintercept = 0, linetype = "dashed") +
  geom_smooth(
    data = subset(near, margin < 0),
    method = "loess",
    formula = y ~ x,
    se = FALSE,
    colour = "#eb6834"
  ) +
  geom_smooth(
    data = subset(near, margin >= 0),
    method = "loess",
    formula = y ~ x,
    se = FALSE,
    colour = "#eb6834"
  ) +
  scale_size_area(max_size = 5, guide = "none") +
  labs(
    title = "Democratic share in the next election against the margin now",
    subtitle = "Blue: means of bins 2.5 points wide. Orange: a smooth curve on each side",
    x = "margin of the Democratic candidate (points)",
    y = "next share (%)"
  ) +
  theme_bw()

Rd plot – 2. Look at the data

Code
naive <- t.test(vote ~ won, s)
c(
  mean_lost = naive$estimate[[1]],
  mean_won = naive$estimate[[2]],
  difference = diff(naive$estimate)[[1]]
)
 mean_lost   mean_won difference 
  40.92053   62.62170   21.70118 

Seats that the Democrats won have 21.7 points more in the next election than seats they lost. That number mixes the effect of holding the seat with the color of the state. The curves rise on both sides, as they must. What we want is the jump at zero.


3. The model step by step, with formulas

Step 1: what is estimated

Write \(Y(1)\) for the next share if the party wins now, \(Y(0)\) if it loses, and \(X\) for the margin. If both average curves are continuous at the cutoff, then

\[\tau = E[Y(1) - Y(0) \mid X = 0] = \lim_{x \downarrow 0} E[Y \mid X = x] - \lim_{x \uparrow 0} E[Y \mid X = x]\]

Nothing is assumed about the rest of the line. The effect is for elections at the cutoff.

Step 2: a window

The simplest answer: take the elections with a margin below 1 point (or 2, or 5) and compare the two groups with a t test.

Code
windows <- do.call(
  rbind,
  lapply(c(0.5, 1, 2, 3, 5, 10), function(k) {
    z <- subset(s, abs(margin) < k)
    t <- t.test(vote ~ won, z)
    data.frame(
      window = k,
      lost = sum(z$won == 0),
      won = sum(z$won),
      difference = diff(t$estimate)[[1]],
      low = -t$conf.int[2],
      high = -t$conf.int[1]
    )
  })
)
print(round(windows, 2), row.names = FALSE)
 window lost won difference  low  high
    0.5    9  14      10.37 3.39 17.35
    1.0   18  25      10.46 5.79 15.13
    2.0   49  47      10.17 6.36 13.98
    3.0   76  65       9.21 6.07 12.36
    5.0  128 117       7.79 5.49 10.08
   10.0  245 206       9.62 7.87 11.37

The narrower the window, the more alike the two groups, and the fewer the elections. In the wide windows the slope of the curves gets into the comparison: winners by 8 points are in other states than losers by 8 points.

Step 3: a line on each side

Better than a narrow window: allow for the slope. Fit a straight line on each side, only with the elections within a bandwidth \(h\), and give more weight to those near the cutoff (triangular kernel):

\[\min \sum_i w_i \left(y_i - \alpha - \tau D_i - \beta x_i - \gamma D_i x_i\right)^2, \qquad w_i = \max(0,\ 1 - |x_i|/h)\]

\(D\) is 1 for a win, and \(\tau\) is the jump. The package chooses \(h\); we take its value (Step 4) and do the rest by hand:

Code
fit_rd <- rdrobust(s$vote, s$margin)
h <- fit_rd$bws["h", "left"]
local <- function(h, p, d = s) {
  # weighted least squares on each side, p: degree; returns the jump and its robust (HC0) SE
  side <- function(keep) {
    X <- outer(d$margin[keep], 0:p, "^")
    w <- 1 - abs(d$margin[keep]) / h
    A <- solve(crossprod(X, w * X))
    b <- A %*% crossprod(X, w * d$vote[keep])
    e <- drop(d$vote[keep] - X %*% b)
    V <- A %*% crossprod(X * (w * e)) %*% A
    c(b[1], V[1, 1])
  }
  l <- side(d$margin < 0 & d$margin > -h)
  r <- side(d$margin >= 0 & d$margin < h)
  c(jump = r[1] - l[1], SE = sqrt(l[2] + r[2]))
}
z <- subset(s, abs(margin) < h); z$w <- 1 - abs(z$margin) / h
wls <- lm(vote ~ won * margin, z, weights = w)
rbind(
  by_hand = local(h, 1),
  lm_with_weights = c(coef(wls)[["won"]], sqrt(sandwich::vcovHC(wls, type = "HC0")["won", "won"])),
  rdrobust_hc0 = with(
    rdrobust(s$vote, s$margin, h = h, vce = "hc0"),
    c(coef["Conventional", 1], se["Conventional", 1])
  )
)
                    jump       SE
by_hand         7.414131 1.455029
lm_with_weights 7.414131 1.455029
rdrobust_hc0    7.414131 1.455029

Three times the same: a jump of 7.4 points. The line through the points on the left ends at 45.2%, the one on the right starts at 52.6%.

Step 4: how wide?

A wide bandwidth uses many elections (little noise), but the curve may bend, and the straight line misses the edge (bias). A narrow one is the reverse. The error is roughly

\[\text{MSE}(h) \approx h^4 B^2 + \frac{V}{n h},\]

with \(B\) from the curvature at the cutoff and \(V\) from the scatter there. The best \(h\) is proportional to \((V/(B^2 n))^{1/5}\). rdrobust() estimates \(B\) and \(V\) from the data and finds h = 17.8 points, which keeps 683 elections.

Code
hs  <- seq(4, 60, by = 1); bw <- t(sapply(hs, function(v) c(local(v, 1), local(v, 2))))
bwd <- rbind(
  data.frame(h = hs, est = bw[, 1], se = bw[, 2], fit = "straight lines"),
  data.frame(h = hs, est = bw[, 3], se = bw[, 4], fit = "quadratic curves")
)
bwd$fit <- factor(bwd$fit, levels = c("straight lines", "quadratic curves"))
ggplot(subset(bwd, h >= 6), aes(h, est)) +
  geom_ribbon(aes(ymin = est - 1.96 * se, ymax = est + 1.96 * se), fill = "#2a78d6", alpha = 0.2) +
  geom_line(colour = "#2a78d6", linewidth = 0.9) +
  geom_vline(xintercept = h, linetype = "dashed") +
  geom_hline(yintercept = 0) +
  facet_wrap(~fit) +
  labs(
    title = "Estimated jump for every bandwidth",
    subtitle = "Dashed: the bandwidth chosen by rdrobust",
    x = "bandwidth (points of margin)",
    y = "jump in the next share"
  ) +
  theme_bw()

Bandwidth chart – Step 4: how wide?

With straight lines the estimate lies between 6.1 and 8.0 for all bandwidths from 10 to 60. The interval never includes 0.

Step 5: the interval that knows about the bias

The best bandwidth for the estimate leaves a bias: at the minimum of the formula above it is exactly half a standard error. So the usual interval (estimate ± 1.96 SE) is centered at the wrong place, and contains the truth in 92% instead of 95% of the samples. Calonico et al. (2014) subtract an estimate of the bias, and add the noise of that estimate to the standard error: the robust bias-corrected interval. It sounds complicated and has a simple core: if the bias is estimated with the same bandwidth, it is exactly the local quadratic fit.

Code
rb <- rdrobust(s$vote, s$margin, h = h, b = h, vce = "hc0")
rbind(
  local_quadratic_by_hand = local(h, 2),
  rdrobust_robust_same_bandwidth = c(rb$coef["Robust", 1], rb$se["Robust", 1])
)
                                   jump       SE
local_quadratic_by_hand        8.321204 2.057432
rdrobust_robust_same_bandwidth 8.321204 2.057432

By default rdrobust() uses a larger bandwidth for the bias (28.0 points), which is less noisy.


4. Reading the output

Code
summary(fit_rd)
Call: rdrobust

Sharp RD estimates using local polynomial regression.

Number of Obs.                 1297
BW type                       mserd
Kernel                   Triangular
VCE method                       NN

                               Left        Right
Number of Obs.                  595          702
Eff. Number of Obs.             360          323
Order est. (p)                    1            1
Order bias (q)                    2            2
BW est. (h)                  17.754       17.754
BW bias (b)                  28.028       28.028
rho (h/b)                     0.633        0.633
Unique Obs.                     595          665

=====================================================================
                   Point    Robust Inference
                Estimate         z     P>|z|      [ 95% C.I. ]       
---------------------------------------------------------------------
     RD Effect     7.414     4.311     0.000     [4.094 , 10.919]    
=====================================================================
Code
res <- data.frame(
  estimate = fit_rd$coef[, 1],
  SE = fit_rd$se[, 1],
  low = fit_rd$ci[, 1],
  high = fit_rd$ci[, 2]
)
round(res, 2)
               estimate   SE  low  high
Conventional       7.41 1.46 4.56 10.27
Bias-Corrected     7.51 1.46 4.65 10.37
Robust             7.51 1.74 4.09 10.92
Code
ci <- fit_rd$ci["Robust", ]
  • Estimate: 7.4 percentage points. This is the local linear estimate, and it is what one reports as the effect.
  • Interval: the robust one, [4.1, 10.9]. It is not centered at the estimate. That is on purpose.
  • Standard errors are by default of the nearest-neighbor type (they compare each election with its neighbors instead of the line), so they differ slightly from ours.

A party that just wins a seat gets about 7.4 points more in the next election than a party that just loses it.


5. Can we believe it?

The assumption (continuity) cannot be tested directly. Four checks come close.

Could someone steer the margin?

If candidates could just push themselves over the line, there would be too few narrow losses and too many narrow wins (McCrary, 2008). Count:

Code
counts <- do.call(
  rbind,
  lapply(c(0.5, 1, 2, 3, 5, 10), function(k) {
    l <- sum(s$margin < 0 & s$margin > -k)
    r <- sum(s$margin >= 0 & s$margin < k)
    data.frame(within = k, lost = l, won = r, p = binom.test(r, l + r)$p.value)
  })
)
print(transform(counts, p = round(p, 3)), row.names = FALSE)
 within lost won     p
    0.5    9  14 0.405
    1.0   18  25 0.360
    2.0   49  47 0.919
    3.0   76  65 0.400
    5.0  128 117 0.523
   10.0  245 206 0.073
Code
dens <- suppressWarnings(rddensity(s$margin))
c(T = dens$test$t_jk, p = dens$test$p_jk)
         T          p 
-0.7599917  0.4472596 
Code
ggplot(subset(s, abs(margin) < 30), aes(margin, fill = margin >= 0)) +
  geom_histogram(breaks = seq(-30, 30, by = 2), colour = "white") +
  scale_fill_manual(values = c("#eb6834", "#2a78d6"), guide = "none") +
  labs(
    title = "Number of elections by margin",
    subtitle = "A jump at zero would be suspicious",
    x = "margin (points)",
    y = "elections"
  ) +
  theme_bw()

Density – Could someone steer the margin?

No sign of steering: for example 18 narrow losses and 25 narrow wins within 1 point (p = .360), and the density test of Cattaneo et al. (2020) has p = .447. (Simple counts are for narrow windows only. Within 10 points there are 245 losses and 206 wins, and the slope of the distribution begins to matter; the density test allows for it.)

Do things jump that cannot be affected?

What was fixed before the election must not jump at the cutoff. We have the state’s population, the terms of the candidate, the year, and, best of all, the result of the previous election for the same seat (made from the file itself):

Code
o <- order(senate$state, senate$class, senate$year); sorted <- senate[o, ]
key <- paste(sorted$state, sorted$class)
lag1 <- function(v) ave(v, key, FUN = function(x) c(NA, head(x, -1)))
sorted$previous_margin <- ifelse(sorted$year - lag1(sorted$year) == 6, lag1(sorted$margin), NA)
sorted$log_population <- log(sorted$population)
placebo <- do.call(
  rbind,
  lapply(c("previous_margin", "termshouse", "termssenate", "log_population", "year"), function(v) {
    m <- rdrobust(sorted[[v]], sorted$margin)
    data.frame(
      variable = v,
      jump = m$coef["Conventional", 1],
      low = m$ci["Robust", 1],
      high = m$ci["Robust", 2],
      p = m$pv["Robust", 1],
      bandwidth = m$bws["h", "left"],
      n = sum(m$N_h)
    )
  })
)
print(data.frame(placebo[1], round(placebo[2:6], 3), n = placebo$n), row.names = FALSE)
        variable   jump    low   high     p bandwidth   n
 previous_margin  0.714 -7.047 10.906 0.674    17.825 577
      termshouse -0.173 -1.269  0.689 0.561    15.657 539
     termssenate -0.192 -1.555  1.368 0.900    16.443 558
  log_population -0.112 -0.517  0.290 0.581    18.472 747
            year  2.771 -6.594 13.560 0.498    16.891 693

None of the five jumps is significant. The margin of the previous election jumps by 0.7 points, with an interval from -7.0 to 10.9: not zero for certain, but no pattern either.

Placebo cutoffs and the donut

At other values of the margin nobody wins or loses anything, so there should be no jump. And the result should not depend on the few elections right at the edge:

Code
cuts <- do.call(
  rbind,
  lapply(c(-20, -15, -10, -5, 0, 5, 10, 15, 20), function(k) {
    zz <- if (k < 0) {
      subset(s, margin < 0)
    } else if (k > 0) {
      subset(s, margin >= 0)
    } else {
      s
    }
    m <- rdrobust(zz$vote, zz$margin, c = k)
    data.frame(
      cutoff = k,
      jump = m$coef["Conventional", 1],
      low = m$ci["Robust", 1],
      high = m$ci["Robust", 2],
      p = m$pv["Robust", 1],
      n = sum(m$N_h)
    )
  })
)
print(round(cuts, 3), row.names = FALSE)
 cutoff    jump     low   high     p   n
    -20   6.620  -3.017 17.845 0.164 142
    -15  -6.893 -19.112  4.660 0.233 144
    -10 -23.216 -42.861 -7.857 0.005  59
     -5  -0.177 -12.809  8.871 0.722 210
      0   7.414   4.094 10.919 0.000 683
      5   3.321  -4.719  7.311 0.673 238
     10   2.915  -1.087 11.037 0.108 145
     15  -1.218 -13.861  8.620 0.648 110
     20  -0.250 -12.847 14.721 0.894 111
Code
donut <- do.call(
  rbind,
  lapply(c(0, 0.25, 0.5, 1, 2), function(k) {
    zz <- subset(s, abs(margin) >= k)
    m <- rdrobust(zz$vote, zz$margin)
    data.frame(
      left_out_within = k,
      removed = nrow(s) - nrow(zz),
      jump = m$coef["Conventional", 1],
      low = m$ci["Robust", 1],
      high = m$ci["Robust", 2]
    )
  })
)
print(round(donut, 2), row.names = FALSE)
 left_out_within removed jump  low  high
            0.00       0 7.41 4.09 10.92
            0.25       9 6.94 3.31 10.45
            0.50      23 7.09 3.20 10.83
            1.00      43 6.58 2.19 10.60
            2.00      96 4.70 0.21  8.95
Code
ggplot(cuts, aes(cutoff, jump)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  geom_linerange(aes(ymin = low, ymax = high, colour = cutoff == 0), linewidth = 0.8) +
  geom_point(aes(colour = cutoff == 0), size = 2.6) +
  scale_colour_manual(values = c("#2a78d6", "#eb6834"), guide = "none") +
  scale_x_continuous(breaks = cuts$cutoff) +
  labs(
    title = "The jump at the real cutoff (orange) and at eight false ones",
    subtitle = "Robust 95% intervals",
    x = "cutoff (points of margin)",
    y = "jump"
  ) +
  theme_bw()

Placebo cutoffs and the donut

Code
false_cuts <- subset(cuts, cutoff != 0); odd <- subset(false_cuts, p < .05)

Of the eight false cutoffs, 1 has p < .05: at -10 a “jump” of -23.2 points, from 59 elections. Among eight tests that happens by chance in about a third of the cases (\(1 - 0.95^8\) = 0.34), and here the interval is very wide. We report it all the same. Without the elections within 0.5 points (23 of them) the effect is 7.1, without those within 1 point 6.6; without those within 2 points it is 4.7, and the interval begins near zero.


6. What not to do: a global polynomial

Before local regression became common, people fitted a high polynomial in the running variable to all data and read off the jump:

Code
global <- do.call(
  rbind,
  lapply(1:6, function(p) {
    m <- lm(vote ~ won * poly(margin, p, raw = TRUE), s)
    data.frame(
      degree = p,
      jump = coef(m)[["won"]],
      SE = sqrt(sandwich::vcovHC(m, type = "HC1")["won", "won"])
    )
  })
)
print(round(global, 2), row.names = FALSE)
 degree jump   SE
      1 6.04 0.89
      2 4.93 1.13
      3 7.32 1.40
      4 9.41 1.66
      5 7.96 1.97
      6 6.63 2.29

The answer goes from 4.9 to 9.4 with the degree, and each has a small standard error that knows nothing of the choice. A polynomial lets elections that were won by 80 points have a say about the edge (Gelman & Imbens, 2019). Local lines do not.


7. Are the intervals right? A simulation

We make a population that looks like ours: the curve is a polynomial of degree 4 on each side (so the true jump is known), the margins come from the data, the noise is normal. Draw 500 samples and let rdrobust() do everything, bandwidth included.

Code
sim_rd <- function(degree, reps = 500) {
  ml <- lm(vote ~ poly(margin, degree, raw = TRUE), s, subset = won == 0)
  mr <- lm(vote ~ poly(margin, degree, raw = TRUE), s, subset = won == 1)
  mu <- ifelse(s$won == 1, predict(mr, s), predict(ml, s))
  truth <- coef(mr)[[1]] - coef(ml)[[1]]
  sigma <- sd(s$vote - mu)
  r <- replicate(reps, {
    i <- sample(nrow(s), replace = TRUE)
    m <- rdrobust(mu[i] + rnorm(nrow(s), 0, sigma), s$margin[i], masspoints = "off")
    c(
      m$coef["Conventional", 1],
      m$ci["Conventional", 1] < truth & truth < m$ci["Conventional", 2],
      m$ci["Robust", 1] < truth & truth < m$ci["Robust", 2],
      m$bws["h", "left"]
    )
  })
  data.frame(
    degree = degree,
    true_jump = truth,
    mean_estimate = mean(r[1, ]),
    mean_bandwidth = mean(r[4, ]),
    coverage_usual = mean(r[2, ]),
    coverage_robust = mean(r[3, ])
  )
}
set.seed(221); sims <- do.call(rbind, lapply(3:5, sim_rd))
print(round(sims, 3), row.names = FALSE)
 degree true_jump mean_estimate mean_bandwidth coverage_usual coverage_robust
      3     7.319         7.052         19.631          0.952           0.960
      4     9.407         8.735         16.498          0.910           0.950
      5     7.958         7.950         17.866          0.948           0.948

The usual interval contains the truth in 91.0% to 95.2% of the samples, depending on how much the curve bends at the edge. The robust interval has 94.8% to 96.0%. Where the true curve bends strongly at the edge, the local linear estimate is too low on average (degree 4: 8.7 instead of 9.4), and the robust interval is what saves us.


8. What the number means

  • It is the effect at the cutoff, for elections that were nearly tied. A safe seat may be different.
  • It is the advantage of the party that holds the seat, not of the person: the candidate in the next election may be a new one.
  • What about winning again? The same design with the outcome “the Democrat gets more than half of the votes next time”:
Code
s$wins_next <- as.numeric(s$vote > 50)
win <- rdrobust(s$wins_next, s$margin); clustered <- rdrobust(s$vote, s$margin, cluster = s$state)
c(
  jump_in_the_probability_to_win = win$coef["Conventional", 1],
  low = win$ci["Robust", 1],
  high = win$ci["Robust", 2]
)
jump_in_the_probability_to_win                            low                           high 
                     0.3301591                      0.1847127                      0.4604589 
Code
cbind(
  value = c(
    effect_on_the_share_clustered_by_state = clustered$coef["Conventional", 1],
    low = clustered$ci["Robust", 1],
    high = clustered$ci["Robust", 2]
  )
)
                                           value
effect_on_the_share_clustered_by_state  7.394838
low                                     3.984970
high                                   11.024943

A narrow win raises the probability of a majority next time by 33.0 percentage points, 95% CI [18.5, 46.0]. (With more than two candidates more than half is stricter than winning.) With standard errors clustered by state, the interval for the share is [4.0, 11.0]: no important change.


9. Things to keep in mind

  • Draw the plot first. If you cannot see the jump, be careful with the number.
  • Know the rule. Is the threshold applied strictly? Do other things change at the same threshold (another law at age 18)? Then the jump is the effect of all of them.
  • Fuzzy RD: when crossing the threshold only raises the probability of treatment, divide the jump in the outcome by the jump in the treatment. That is instrumental variables at the cutoff: rdrobust(y, x, fuzzy = treatment).
  • Discrete running variables (age in years, whole test points): there is no “just above”; the methods need care.
  • Control variables are not needed. They can shorten the interval (covs =), and must be fixed before the treatment.
  • Report the bandwidth, its selection, the kernel, the number of observations on each side within it, and the robust interval. Show other bandwidths.
  • Power is low: only the observations near the edge count. Here 683 of 1,297.

10. Reporting the results in APA style

A report (APA 7th edition) needs the rule and the running variable, the cutoff, the estimator (degree, kernel, bandwidth and how it was chosen), the numbers of observations on each side within the bandwidth, the estimate with a robust interval, and the checks. The numbers come from the R objects:

Code
line <- function(label, m, scale = 1) {
  data.frame(
    Outcome = label,
    n = paste(m$N_h, collapse = " / "),
    h = f1(m$bws["h", "left"]),
    jump = f2(scale * m$coef["Conventional", 1]),
    ci = paste0("[", f2(scale * m$ci["Robust", 1]), ", ", f2(scale * m$ci["Robust", 2]), "]"),
    p = sub("= ", "", pval(m$pv["Robust", 1]))
  )
}
pm <- function(v) rdrobust(sorted[[v]], sorted$margin)
apa_table <- rbind(
  line("Share in the next election (%)", fit_rd),
  line("Majority in the next election (percentage points)", win, 100),
  line("Margin of the previous election (placebo)", pm("previous_margin")),
  line("Earlier terms in the House (placebo)", pm("termshouse")),
  line("Earlier terms in the Senate (placebo)", pm("termssenate")),
  line("Log population (placebo)", pm("log_population"))
)

Method (data analysis):

The effect of holding a US Senate seat on the party’s share in the next election was estimated with a sharp regression discontinuity design (Lee, 2008), using 1,297 elections between 1914 and 2004 (Cattaneo et al., 2015). The running variable was the Democratic margin of victory, with a cutoff of zero. We fitted local linear regressions with a triangular kernel on each side of the cutoff, with the bandwidth that minimizes the mean squared error, and report robust bias-corrected 95% confidence intervals (Calonico et al., 2014; R package rdrobust). The assumption that parties could not steer the margin was examined with the density test of Cattaneo et al. (2020), and the continuity assumption with predetermined outcomes, false cutoffs, and the removal of the elections nearest the cutoff. Analyses were conducted in R (Version 4.6.2; R Core Team, 2026).

Results:

A narrow win raised the party’s share in the next election by 7.4 percentage points, robust 95% CI [4.1, 10.9], p < .001 (bandwidth 17.8 points; 360 elections below and 323 above the cutoff; Table 1), and the probability of a majority by 33.0 percentage points, 95% CI [18.5, 46.0]. There was no evidence of a discontinuity in the density of the margin (T = -0.76, p = .447) or in the predetermined variables (p ≥ .498). Of eight false cutoffs, 1 showed a jump with p < .05. Estimates for bandwidths between 10 and 60 points ranged from 6.1 to 8.0.

Table 1

Discontinuities at a Margin of Zero

Outcome n below / above Bandwidth Jump Robust 95% CI p
Share in the next election (%) 360 / 323 17.8 7.41 [4.09, 10.92] < .001
Majority in the next election (percentage points) 467 / 439 28.4 33.02 [18.47, 46.05] < .001
Margin of the previous election (placebo) 298 / 279 17.8 0.71 [-7.05, 10.91] .674
Earlier terms in the House (placebo) 282 / 257 15.7 -0.17 [-1.27, 0.69] .561
Earlier terms in the Senate (placebo) 291 / 267 16.4 -0.19 [-1.56, 1.37] .900
Log population (placebo) 392 / 355 18.5 -0.11 [-0.52, 0.29] .581

Note. Local linear regression, triangular kernel, bandwidth chosen to minimize the mean squared error separately for each outcome. n: elections within the bandwidth.

Points to remember:

  • Report the estimate of the local linear fit and the robust interval.
  • Give the bandwidth, and the number of observations on each side of it.
  • Show the plot, the density test and the placebo outcomes.
  • Say that the effect is for the units at the cutoff.

11. Summary

When A treatment is given by a threshold in a running variable that nobody controls exactly
The effect The jump of the regression function at the cutoff
Estimator Weighted lines on each side, within a bandwidth: lm(y ~ D * x, weights = triangle)
Bandwidth Minimizes the mean squared error (rdrobust)
Interval Robust bias-corrected (with the same bandwidth for the bias: the local quadratic fit)
How (R) rdrobust(y, x, c = 0), rddensity(x), rdplot(y, x)
Checks Density, placebo outcomes, false cutoffs, donut, other bandwidths
Not Global polynomials
Related pages Instrumental variables, LOESS, simple regression

References

Calonico, S., Cattaneo, M. D., & Titiunik, R. (2014). Robust nonparametric confidence intervals for regression-discontinuity designs. Econometrica, 82(6), 2295–2326. https://doi.org/10.3982/ECTA11757

Cattaneo, M. D., Frandsen, B. R., & Titiunik, R. (2015). Randomization inference in the regression discontinuity design: An application to party advantages in the U.S. Senate. Journal of Causal Inference, 3(1), 1–24. https://doi.org/10.1515/jci-2013-0010

Cattaneo, M. D., Jansson, M., & Ma, X. (2020). Simple local polynomial density estimators. Journal of the American Statistical Association, 115(531), 1449–1455. https://doi.org/10.1080/01621459.2019.1635480

Gelman, A., & Imbens, G. (2019). Why high-order polynomials should not be used in regression discontinuity designs. Journal of Business & Economic Statistics, 37(3), 447–456. https://doi.org/10.1080/07350015.2017.1366909

Lee, D. S. (2008). Randomized experiments from non-random selection in U.S. House elections. Journal of Econometrics, 142(2), 675–697. https://doi.org/10.1016/j.jeconom.2007.05.004

McCrary, J. (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

Thistlethwaite, D. L., & Campbell, D. T. (1960). Regression-discontinuity analysis: An alternative to the ex post facto experiment. Journal of Educational Psychology, 51(6), 309–317. https://doi.org/10.1037/h0044319