Day 75. Bandwidth Selection & Bias Correction
The bandwidth trades bias against variance. The MSE-optimal bandwidth balances them so well that the bias is no longer negligible relative to the standard error, and conventional confidence intervals under-cover. Robust bias-corrected inference fixes this by subtracting an estimate of the bias and accounting for its uncertainty.
- ●Derive the MSE-optimal bandwidth and its n^(−1/5) rate.
- ●Show that at the MSE-optimal bandwidth the bias is half the standard error, and compute the resulting coverage loss.
- ●Explain robust bias-corrected (RBC) confidence intervals and why conventional standard errors are too small after bias correction.
- ●Design a bandwidth robustness analysis for an RD study.
Theory
The trade-off
For a local linear RD estimator with bandwidth and sample size ,
where depends on the curvature of near the cutoff and on the outcome variance and the density of at .
MSE-optimal bandwidth
Minimising gives
Data-driven selectors (Imbens–Kalyanaraman; Calonico–Cattaneo–Titiunik, CCT) estimate (using a pilot local quadratic fit) and , then plug in. Different bandwidths can be used on each side.
The inference problem
At , squared bias equals one quarter of the variance, so
A conventional 95% interval then covers only about 92% of the time, and less when bias is underestimated.
Fixes
- Undersmoothing: use a smaller bandwidth than so bias is negligible; the point estimate becomes noisier and the right amount of undersmoothing is unclear.
- Robust bias correction (Calonico, Cattaneo and Titiunik, 2014): estimate the bias with a local quadratic fit (pilot bandwidth ), subtract it, and compute a standard error that includes the variability of the bias estimate. With , the bias-corrected estimator coincides with the local quadratic estimator, and RBC inference is local quadratic inference at bandwidth .
Current practice: report the local linear estimate at with the RBC confidence interval; show sensitivity to halving and doubling the bandwidth. Coverage-error-optimal bandwidths (smaller than ) are an alternative for inference.
Part 1 · Warm-up
Exercise 1 · An optimal bandwidth
With , and , compute .
Show solution
Step 1. .
Step 2. ; divided by 5: 1.66; .
Answer: about 0.19 units of the running variable.
Exercise 2 · More data
If the sample grows 32-fold, how does change?
Show solution
Step 1. ; .
Answer: it halves.
Exercise 3 · Coverage at the optimum
With bias equal to half the SE, what is the coverage of a nominal 95% interval?
Show solution
Step 1. The t-statistic is around the truth.
Step 2. Coverage .
Answer: about 92%.
Exercise 4 · Undersmoothing
To make the bias at most 10% of the SE, by what factor must the bandwidth shrink relative to ?
Show solution
Step 1. Bias/SE .
Step 2. We need the ratio to fall from 0.5 to 0.1: factor 5, so shrinks by .
Answer: use roughly half the MSE-optimal bandwidth; the SE then rises by .
Exercise 5 · Ingredients of RBC
List what is estimated in robust bias-corrected inference.
Show solution
Step 1. The local linear estimate with bandwidth .
Step 2. The bias from a local quadratic fit with pilot bandwidth .
Step 3. A standard error for that includes the variance of and its covariance with .
Part 2 · Proofs
Exercise 6 · Deriving the optimal bandwidth
Minimise over .
Show solution
Step 1. Derivative: .
Step 2. , so .
Step 3. The second derivative : a minimum.
Exercise 7 · Bias is half the SE
Show that at , .
Show solution
Step 1. From Exercise 6, , so .
Step 2. The left side is ; the right side is .
Exercise 8 · The convergence rate
Show that at the root mean squared error is of order , slower than the parametric .
Show solution
Step 1. with .
Step 2. and .
Step 3. . RD uses only data near the cutoff, so it learns more slowly than an experiment.
Exercise 9 · Why bias correction needs a new SE
Let . Show and explain why using alone is wrong.
Show solution
Step 1. Variance of a difference.
Step 2. is estimated from the same (or overlapping) data with a curvature estimate, which is noisy: is not negligible in large samples when is of the same order as .
Answer: ignoring it understates uncertainty; RBC uses the full variance.
Exercise 10 · Choosing the bandwidth by eye
Explain why picking the bandwidth that gives the most significant estimate invalidates inference.
Show solution
Step 1. Estimates at different bandwidths are noisy, and some will be significant by chance.
Step 2. Choosing the most significant inflates the probability of rejecting a true null above 5% (specification searching).
Answer: pre-specify a data-driven bandwidth and report sensitivity across bandwidths, not the best one.
Part 3 · Applied
Exercise 11 · A scholarship RD bandwidth
A pilot local quadratic fit suggests (enrolment probability per squared score unit, in standardised score units), the variance constant is , and there are students. Compute , and the bandwidth after a 50% undersmoothing.
Show solution
Step 1. .
Step 2. ; ; .
Answer: sd of the score; undersmoothed about 0.10.
Exercise 12 · Coverage in a simulation
In the simulation below (true jump 5, curved regression function, 1,000 observations), compare the coverage of conventional local linear intervals with local quadratic (RBC with ) intervals at bandwidths 0.15, 0.3 and 0.5.
Show solution
Step 1. Small : both cover about 92–93%; the local quadratic interval is wider.
Step 2. At , the local linear estimate is biased (about +0.5) and its interval covers only about 86%.
Step 3. The local quadratic interval keeps coverage near 94% at every bandwidth.
Answer: robust bias correction protects inference when the bandwidth is large enough for bias to matter.
Exercise 13 · A bandwidth robustness table
For an RD on the effect of a pension eligibility age on retirement, outline a robustness table.
Show solution
Step 1. Rows: , , , and the coverage-error-optimal bandwidth.
Step 2. Columns: point estimate, RBC 95% CI, number of observations on each side.
Step 3. Also: local quadratic fits, triangular versus uniform kernel.
Answer: stable estimates across rows support the result; strong sensitivity signals curvature or too few observations near the cutoff.
Exercise 14 · Different bandwidths on each side
Mortality data around a very-low-birth-weight cutoff have many more observations above than below the threshold, and curvature differs. Why might separate bandwidths help?
Show solution
Step 1. Each side's MSE depends on its own density, variance and curvature.
Step 2. Separate bandwidths use more data where it is plentiful and the function is flat, less where it curves.
Answer: lower overall MSE for the jump estimate; CCT-style selectors provide side-specific bandwidths.
Exercise 15 · Few observations near the cutoff
An RD on a school-entry age cutoff has only 60 children within a month of the cutoff. What alternative to continuity-based inference is appropriate?
Show solution
Step 1. Asymptotic local polynomial inference may be unreliable with so few observations.
Step 2. Local randomisation: treat children born within a narrow window as if randomly assigned, check covariate balance, and use Fisher randomisation inference (Day 37).
Answer: a local-randomisation analysis in a small window, reported alongside the continuity-based estimate.
Verify in Python
import numpy as np
from scipy.stats import norm
print("Ex 1 h_MSE:", round((4 / (4 * 4 * 1000)) ** .2, 3), " Ex 11:", round((2 / (4 * .25 * 5000)) ** .2, 3),
" Ex 3 coverage:", round(norm.cdf(1.96 - .5) - norm.cdf(-1.96 - .5), 3), " Ex 4 factor:", round(5 ** .4, 2))
rng = np.random.default_rng(75)
mu0 = lambda x: 50 + 8 * x + 30 * x ** 2 - 20 * x ** 3
def side(x, y, h, p):
w = np.clip(1 - np.abs(x) / h, 0, None); m = w > 0
X = np.column_stack([x[m] ** k for k in range(p + 1)]); W = w[m]
A = np.linalg.inv(X.T @ (W[:, None] * X)); b = A @ (X.T @ (W * y[m])); r = y[m] - X @ b
V = A @ (X.T @ ((W ** 2 * r ** 2)[:, None] * X)) @ A # heteroskedasticity-robust
return b[0], V[0, 0]
def rd(x, y, h, p):
r = x >= 0
a, va = side(x[r], y[r], h, p); b, vb = side(-x[~r], y[~r], h, p)
return a - b, np.sqrt(va + vb)
print(" h LL bias LL sd LL cover | LQ bias LQ sd LQ cover")
for h in (.15, .3, .5):
out = {1: [], 2: []}; cov = {1: 0, 2: 0}
for _ in range(1000):
x = rng.uniform(-1, 1, 1000); y = mu0(x) + 5 * (x >= 0) + rng.normal(0, 3, 1000)
for p in (1, 2):
t, s = rd(x, y, h, p); out[p].append(t); cov[p] += abs(t - 5) < 1.96 * s
print(f"{h:4.2f} {np.mean(out[1]) - 5:7.2f} {np.std(out[1]):5.2f} {cov[1] / 1000:7.3f} | "
f"{np.mean(out[2]) - 5:7.2f} {np.std(out[2]):5.2f} {cov[2] / 1000:7.3f}")
Key takeaways
- The MSE-optimal bandwidth shrinks like n^(−1/5) and leaves a bias equal to half the standard error.
- Conventional intervals at that bandwidth under-cover; robust bias-corrected intervals subtract the estimated bias and account for its variance.
- Pre-specify a data-driven bandwidth, report RBC intervals, and show sensitivity to the bandwidth.
Simulation Lab: Bandwidth & Robust Bias Correction
Open full screen →Bias, SD and RMSE across bandwidths, and coverage of conventional versus robust bias-corrected intervals.
120 simulated RD studies at each bandwidth (true jump 5). Left: bias, SD and RMSE of the local linear estimate; the RMSE is smallest at an intermediate bandwidth. Right: coverage of conventional local linear 95% intervals versus robust bias-corrected intervals (local quadratic at the same bandwidth). Raise curvature to see conventional coverage collapse at wide bandwidths.