When a programme or an office goes to everyone on one side of a threshold, such as a test score, an age or a vote share, the people or places just either side of it can be compared. This page estimates the jump in an outcome at the threshold the way the rdrobust package does: a local linear fit on each side, a bandwidth chosen to minimise mean squared error, and a confidence interval corrected for the bias that bandwidth leaves. It reproduces rdrobust's numbers on the data sets in its test. Nothing you load leaves your browser.
Data
Treatment is assumed for every observation at or above the cutoff. This page handles sharp designs only.
Bandwidth
Estimate at the cutoff
Loading the example.
The data near the cutoff
Dots are the mean outcome in evenly spaced bins of the running variable, and the lines are the local linear fits within h, weighted by a triangular kernel. The bins are for looking at; nothing is estimated from them.
How much the estimate depends on the bandwidth
Each row sets h to a multiple of the selected bandwidth and b equal to h, which is what rdrobust does when it is given h alone. That is why the row at 1 × h can differ from the estimate above, which uses the selected b. A wide band of estimates that keep their sign is reassuring; an estimate that appears only at one bandwidth is not.
How many observations sit near the cutoff
If people can place themselves just above the threshold, the number of observations jumps there and the comparison breaks down. This chart shows the counts in the plot's bins. It is a picture, not a test: the formal test is the density test of Cattaneo, Jansson and Ma (2020), in their rddensity package, which this page does not implement.
Method and limits
On each side of the cutoff c, the outcome is regressed on (x minus c) with weights from a triangular kernel, 1 minus |x minus c| divided by h, for points within h of the cutoff. The conventional estimate is the difference between the two intercepts. Its bias is estimated from a local quadratic fit with bandwidth b and subtracted, which gives the bias-corrected estimate. The robust standard error accounts for the extra variance the correction brings (Calonico, Cattaneo and Titiunik 2014). Variances use nearest-neighbour residuals with three matches.
h and b are chosen to minimise the mean squared error of the estimate, by rdrobust's three-step procedure with its regularisation term, on a standardised running variable and outcome. When at least a fifth of the observations on a side share a value with another, rdrobust widens the pilot bandwidths to cover ten distinct values, and so does this page; it says so above the estimate when that happens.
In the Lok Sabha example each seat appears twice, once for each leading party, with margins of opposite sign. The two rows of a seat are not independent, and rdrobust would cluster on the seat; clustering is not ported here. Where one leading party wins the other usually loses, so the two rows move in opposite directions, and intervals that treat them as independent are likely to be too narrow. A party that did not contest in 2024, because it had given the seat to an ally, counts as not having won it.
Ported: the sharp design with rdrobust's default options. Not ported: fuzzy designs, kink designs, covariates, clusters, weights, other kernels and other bandwidth selectors. For those, use rdrobust itself in R, Python or Stata. The ported path is checked against rdrobust 2.1.1 on seven data sets, including the Lok Sabha example and two with heavy ties, in tests/core.mjs.
Sources: Sebastian Calonico, Matias D. Cattaneo and Rocio Titiunik, "Robust nonparametric confidence intervals for regression-discontinuity designs", Econometrica 82(6), 2014, pages 2295 to 2326. Calonico, Cattaneo, Max H. Farrell and Titiunik, "rdrobust: Software for regression-discontinuity designs", The Stata Journal 17(2), 2017, pages 372 to 404. Election results: Election Commission of India, statistical report 33, Constituency Wise Detailed Result, for the general elections of 2019 and 2024. Cattaneo, Brigham R. Frandsen and Titiunik, "Randomization inference in the regression discontinuity design: an application to party advantages in the U.S. Senate", Journal of Causal Inference 3(1), 2015, pages 1 to 24.