| rd2d.dist | R Documentation |
rd2d.dist implements distance-based local polynomial boundary regression discontinuity (RD) point estimators with robust bias-corrected pointwise confidence intervals and
uniform confidence bands, developed in Cattaneo, Titiunik and Yu (2025a) with a companion software article Cattaneo, Titiunik and Yu (2025b). For robust bias-correction, see Calonico, Cattaneo, Titiunik (2014).
Companion commands are: rdbw2d.dist for data-driven bandwidth selection.
For other packages of RD designs, visit https://rdpackages.github.io/
rd2d.dist(
Y,
D,
h = NULL,
b = NULL,
p = 1,
q = 2,
kink = c("off", "on"),
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
level = 95,
cbands = TRUE,
side = c("two", "left", "right"),
repp = 1000,
bwselect = c("mserd", "imserd", "msetwo", "imsetwo", "user provided"),
vce = c("hc1", "hc0", "hc2", "hc3"),
rbc = c("on", "off"),
bwcheck = 50 + p + 1,
masspoints = c("check", "adjust", "off"),
C = NULL,
scaleregul = 1,
cqt = 0.5
)
Y |
Dependent variable; a numeric vector of length |
D |
Distance-based scores |
h |
Bandwidth(s); if |
b |
Optional evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order for point estimation. Default is |
q |
Polynomial order for bias-corrected estimation. Must satisfy |
kink |
Logical; whether to apply kink adjustment. Options: |
kernel |
Kernel function to use. Options are |
level |
Nominal confidence level for intervals/bands, between 0 and 100 (default is 95). |
cbands |
Logical. If |
side |
Type of confidence interval. Options: |
repp |
Number of bootstrap repetitions used for critical value simulation. Default is |
bwselect |
Bandwidth selection strategy. Options:
|
vce |
Variance-covariance estimator for standard errors. Options:
|
rbc |
Logical. Whether to apply robust bias correction. Options: |
bwcheck |
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least |
masspoints |
Strategy for handling mass points in the running variable. Options:
|
C |
Cluster ID variable used for cluster-robust variance estimation. Default is |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is |
cqt |
Constant controlling subsample fraction for initial bias estimation. Default is |
MSE bandwidth selection for geometrical RD design
An object of class "rd2d.dist", a list containing:
resultsA data frame with point estimates, variances, p-values, confidence intervals, confidence bands, and bandwidths at each evaluation point.
b1First coordinate of the evaluation point.
b2Second coordinate of the evaluation point.
Est.pPoint estimate of \widehat{\tau}_{\text{dist},p}(\mathbf{b}) with polynomial order p.
Se.pStandard error of \widehat{\tau}_{\text{dist},p}(\mathbf{b}).
Est.qBias-corrected estimate \widehat{\tau}_{\text{dist},q}(\mathbf{b}) with polynomial order q.
Se.qStandard error of \widehat{\tau}_{\text{dist},q}(\mathbf{b}).
pvalueTwo-sided p-value based on T_{\text{dist},q}(\mathbf{b}).
CI.lowerLower bound of confidence interval.
CI.upperUpper bound of confidence interval.
CB.lowerLower bound of uniform confidence band (if cbands=TRUE).
CB.upperUpper bound of uniform confidence band (if cbands=TRUE).
h0Bandwidth used for control group (D_i(\mathbf{b}) < 0).
h1Bandwidth used for treatment group (D_i(\mathbf{b}) \geq 0).
Nh0Effective sample size for control group.
Nh1Effective sample size for treatment group.
results.A0Same structure as results but for control group outcomes.
results.A1Same structure as results but for treatment group outcomes.
tau.hatVector of point estimates \widehat{\tau}_p(\mathbf{b}).
se.hatStandard errors corresponding to \widehat{\tau}_p(\mathbf{b}).
cbConfidence intervals and uniform bands.
cov.qCovariance matrix for bias-corrected estimates \widehat{\tau}_{\text{dist},q}(\mathbf{b}) for all point evaluations \mathbf{b}.
optList of options used in the function call.
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Calonico, S., Cattaneo, M. D., Titiunik, R. (2014) Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs
rdbw2d.dist, rd2d, print.rd2d.dist, summary.rd2d.dist
set.seed(123)
n <- 5000
# Generate running variables x1 and x2
x1 <- rnorm(n)
x2 <- rnorm(n)
# Define treatment assignment: treated if x1 >= 0
d <- as.numeric(x1 >= 0)
# Generate outcome variable y with some treatment effect
y <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * d + rnorm(n, sd = 0.5)
# Define evaluation points (e.g., at the origin and another point)
eval <- data.frame(x.1 = c(0, 0), x.2 = c(0, 1))
# Compute Euclidean distances to evaluation points
dist.a <- sqrt((x1 - eval$x.1[1])^2 + (x2 - eval$x.2[1])^2)
dist.b <- sqrt((x1 - eval$x.1[2])^2 + (x2 - eval$x.2[2])^2)
# Combine distances into a matrix
D <- as.data.frame(cbind(dist.a, dist.b))
# Assign positive distances for treatment group, negative for control
d_expanded <- matrix(rep(2 * d - 1, times = ncol(D)), nrow = nrow(D), ncol = ncol(D))
D <- D * d_expanded
# Run the rd2d.dist function
result <- rd2d.dist(y, D, b = eval)
# View the estimation results
print(result)
summary(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.