from qte.bootstrap import BootstrapConfig, BootstrapMultiplierConfig
from qte.datasets import load_ddk_2011
from qte.rdd import (
LocalPolynomialConfig,
RunningVariableConfig,
estimate_rdd_distribution_effects,
plot_rdd_design,
plot_rdd_treatment,
)
QS = [0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90]
BOOTSTRAP = BootstrapConfig(n_iter=200, seed=42, n_workers=4)
UNIFORM_BOOTSTRAP = BootstrapMultiplierConfig(n_draws=1000, seed=42)Regression Discontinuity Design
This page demonstrates how to use the py-qte package to obtain quantile treatment effects in the context of the regression-discontinuity design (RDD). The point estimator follows Frandsen, Frölich & Melly 2012 and targets quantile treatment effect for local compliers at the cutoff. It handles both sharp and fuzzy RDDs.
Under the standard RD assumptions, the distribution of the treated potential outcome among compliers at the cutoff is identified through the following Wald ratio
\[ F_{Y(1)\mid C}(y) = \frac{ \lim_{r\downarrow c} E[1(Y \le y) D \mid R = r] - \lim_{r\uparrow c} E[1(Y \le y) D \mid R = r] }{ \lim_{r\downarrow c} E[D \mid R = r] - \lim_{r\uparrow c} E[D \mid R = r] }, \]
and the control counterpart is the reverse side difference of \(1(Y \le y)(1-D)\). The quantile treatment effect is then the difference between the inverses of these two complier distribution functions.
Standard errors can be obtained via the case or the multiplier-bootstrap. The multiplier-bootstrap allows for the computation of uniform confidence bands, i.e. confidence bands that apply to all quantiles jointly.
The multiplier-bootstrap uniform band follows the constant-width convention of Chiang, Hsu & Sasaki 2019 and Stata’s rdqte package. The R package QTE.RD of Qu & Yoon 2025 also served as a reference point.
A bandwidth must be supplied. The estimator, as of now, does not select one internally. outcome_grid is either the number of weighted-quantile points used for the distribution regressions or an explicit sequence of outcome values.
The Data
The data are from Duflo, Dupas & Kremer 2011, a randomized evaluation of tracking in Kenyan primary schools. The paper asks whether separating students into high- and low-ability sections (“tracking”) improves learning, and how peer composition and teacher incentives, both changing with tracking, shape that answer. The authors have access to control schools without tracking. The setting, however, lends itself also to an RDD since within the tracking schools students where assigned to a track based on a cutoff in a baseline test score. The RDD setup, thus, can speak to a question regarding the effect of placing a marginal student into the track of better performing students. It is the empirical example in Qu & Yoon 2025
The main variables are:
percentile: the student’s baseline test percentile, the running variable.highstream: assignment to the upper-ability section in a tracking school.ts_std: the standardized endline test score, the outcome.tracking: whether the school was sampled for tracking.
We keep the 2,980 tracking-school students with non-missing outcome and running variable, set the cutoff at 50, and define treatment sharply as being at or above the median percentile. The raw highstream variable is not perfectly deterministic at the cutoff, so the sharp definition keeps the demonstration focused on assignment at the cutoff. The dataset is the one distributed with the R package QTE.RD; the Stata benchmark uses the same sample and cutoff.
DDK = (
load_ddk_2011()
.filter(pl.col("tracking") == 1)
.drop_nulls(["ts_std", "percentile"])
.with_columns((pl.col("percentile") >= 50.0).cast(pl.Int64).alias("treatment"))
)
print(f"{DDK.height:,} students in tracking schools")
print(f"{DDK['treatment'].sum():,} at or above the median percentile")2,980 students in tracking schools
1,524 at or above the median percentile
Descriptives
The figures show the outcome and the treatment probability against the running variable. Binned means are plotted separately on either side of the cutoff, together with local-linear fits inside the estimation window.
show_chart(
plot_rdd_design(
DDK,
"ts_std",
RunningVariableConfig("percentile", 50.0),
n_bins=20,
local_polynomial_config=LocalPolynomialConfig(bandwidth=20.0),
)
)Figure 1 reflects the substantive finding in Qu & Yoon 2025: the outcome jump at the cutoff is small, so students just above the median do not appear to gain from being assigned to the better section.
show_chart(
plot_rdd_treatment(
DDK,
"treatment",
RunningVariableConfig("percentile", 50.0),
n_bins=20,
local_polynomial_config=LocalPolynomialConfig(bandwidth=20.0),
)
)Figure 2 shows the sharp assignment rule: treatment jumps from zero to one at the median percentile.
Estimation
We estimate the complier quantile treatment effects at the cutoff with a local-linear distribution regression and a bandwidth of 20 percentile points.
res = estimate_rdd_distribution_effects(
DDK,
outcome="ts_std",
treatment="treatment",
running_variable=RunningVariableConfig("percentile", 50.0),
qs=QS,
local_polynomial_config=LocalPolynomialConfig(bandwidth=20.0),
outcome_grid=200,
bootstrap_config=BOOTSTRAP,
)Table 1 and Figure 3 show the results in tabular and graphical form.
res.tabulate()| Quantile & Average Treatment Effects | ||||
|---|---|---|---|---|
Outcome : ts_std Treatment : treatment Running : percentile Cutoff : 50.0 Bandwidth : 20.0 Kernel : epanechnikov Degree : 1 Inference : bootstrap First Stage : 1.000 Observations : 2,980 Confidence Lvl : 0.95 |
||||
| Quantile | Effect Estimate | Std. Error | Lower CI | Upper CI |
| Quantile Treatment Effects | ||||
| 0.10 | −0.11 | 0.11 | −0.33 | 0.11 |
| 0.20 | −0.09 | 0.11 | −0.31 | 0.14 |
| 0.30 | −0.07 | 0.10 | −0.28 | 0.13 |
| 0.40 | −0.14 | 0.12 | −0.38 | 0.10 |
| 0.50 | −0.21 | 0.13 | −0.48 | 0.05 |
| 0.60 | −0.11 | 0.15 | −0.40 | 0.18 |
| 0.70 | −0.02 | 0.21 | −0.42 | 0.38 |
| 0.80 | −0.04 | 0.22 | −0.47 | 0.38 |
| 0.90 | 0.29 | 0.27 | −0.24 | 0.82 |
| Average Treatment Effects | ||||
| - | −0.04 | 0.11 | −0.26 | 0.17 |
show_chart(res.plot())The first stage is one because treatment is defined sharply at the cutoff. While our results look similar to Qu & Yoon 2025 at lower quantiles (in terms of the point estimate and the confidence band), their results do not include the somewhat sharp uptick at the 0.9 quantile. Notice that they generally implement a different estimator.
Uniform Bands
The RDD distribution estimator is the first and only design in py-qte that implements the multiplier boostrap, and therefore the only one that supports uniform confidence bands.
A pointwise interval covers the QTE at one quantile at a time:
\[ P\left(\widehat{\mathrm{QTE}}(\tau)-z_{1-\alpha/2}\,\widehat{se}(\tau) \le \mathrm{QTE}(\tau)\le \widehat{\mathrm{QTE}}(\tau)+z_{1-\alpha/2}\,\widehat{se}(\tau)\right)=1-\alpha. \]
A uniform band covers the entire quantile curve simultaneously:
\[ P\left(\sup_{\tau\in\mathcal{T}} \left|\widehat{\mathrm{QTE}}(\tau)-\mathrm{QTE}(\tau)\right| \le c_{1-\alpha}\right)=1-\alpha. \]
This is the relevant object when the whole QTE process is inspected, because it accounts for the joint variation across quantiles. The multiplier draws approximate the distribution of that process; the critical value is taken from the supremum across quantiles and draws.
Passing a BootstrapMultiplierConfig switches to multiplier draws. With degree=2 this is the CHS-style local-quadratic fit. The pointwise SEs and the uniform critical value come from the same draws. band="sup-t" uses the studentised sup-t critical value; band="uniform" uses the CHS/Stata constant-width band.
uniform_res = estimate_rdd_distribution_effects(
DDK,
outcome="ts_std",
treatment="treatment",
running_variable=RunningVariableConfig("percentile", 50.0),
qs=QS,
local_polynomial_config=LocalPolynomialConfig(bandwidth=20.0, degree=2),
outcome_grid=200,
bootstrap_config=UNIFORM_BOOTSTRAP,
)
uniform_res.uniform_sup_t_critical_value(0.95)2.5683164678158694
References
- Frandsen, B. R., Frölich, M., & Melly, B. (2012). Quantile treatment effects in the regression discontinuity design. Journal of Econometrics, 168(2), 382–395. doi:10.1016/j.jeconom.2012.02.004
- Chiang, H. D., Hsu, Y.-C., & Sasaki, Y. (2019). Robust uniform inference for quantile treatment effects in regression discontinuity designs. Journal of Econometrics, 211(2), 589–618. doi:10.1016/j.jeconom.2019.03.006
- Duflo, E., Dupas, P., & Kremer, M. (2011). Peer effects, teacher incentives, and the impact of tracking: Evidence from a randomized evaluation in Kenya. American Economic Review, 101(5), 1739–1774. doi:10.1257/aer.101.5.1739
- Qu, Z., & Yoon, J. (2025). QTE.RD: An R package for quantile treatment effects in regression-discontinuity designs. The R Journal, 17(3), 69–88. doi:10.32614/RJ-2025-024