rdbw2d implements bandwidth selector for bivariate 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: rd2d for point estimation and inference procedures.
For other packages of RD designs, visit https://rdpackages.github.io/
rdbw2d(
Y,
X,
t,
b,
p = 1,
deriv = c(0, 0),
tangvec = NULL,
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
kernel_type = c("prod", "rad"),
bwselect = c("mserd", "imserd", "msetwo", "imsetwo"),
method = c("dpi", "rot"),
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 50 + p + 1,
masspoints = c("check", "adjust", "off"),
C = NULL,
scaleregul = 1,
scalebiascrct = 1,
stdvars = TRUE
)A list of class "rdbw2d" containing:
bwsData frame of estimated bandwidths for each evaluation point:
b1First coordinate of the evaluation point.
b2Second coordinate of the evaluation point.
h01Estimated bandwidth for \(X_{1i}\) in the control group (\(\mathcal{A}_0\)).
h02Estimated bandwidth for \(X_{2i}\) in the control group (\(\mathcal{A}_0\)).
h11Estimated bandwidth for \(X_{1i}\) in the treatment group (\(\mathcal{A}_1\)).
h12Estimated bandwidth for \(X_{2i}\) in the treatment group (\(\mathcal{A}_1\)).
mseconstsData frame of intermediate quantities used in bandwidth calculation:
Nh0Effective sample size for the control group \(\mathcal{A}_0\).
Nh1Effective sample size for the treatment group \(\mathcal{A}_1\).
bias.0Bias constant estimate for the control group.
bias.1Bias constant estimate for the treatment group.
var.0Variance constant estimate for the control group.
var.1Variance constant estimate for the treatment group.
reg.bias.0Bias correction adjustment for the control group.
reg.bias.1Bias correction adjustment for the treatment group.
reg.var.0Variance of the bias estimate for the control group.
reg.var.1Variance of the bias estimate for the treatment group.
optList containing:
pPolynomial order used for estimation.
kernelKernel function used.
kernel_typeType of kernel (product or radial).
stdvarsLogical indicating if standardization was applied.
bwselectBandwidth selection strategy used.
methodBandwidth estimation method.
vceVariance estimation method.
scaleregulScaling factor for regularization.
scalebiascrctScaling factor for bias correction.
NTotal sample size \(N\).
Dependent variable; a numeric vector of length \(N\), where \(N\) is the sample size.
Bivariate running variable (a.k.a score variable); a numeric matrix or data frame of dimension \(N \times 2\), with each row \(\mathbf{X}_i = (X_{1i}, X_{2i})\).
Treatment indicator; a logical or binary vector indicating treatment assignment (\(t_i = 1\) if treated, \(t_i = 0\) otherwise).
Evaluation points; a matrix or data frame specifying boundary points \(\mathbf{b}_j = (b_{1j}, b_{2j})\), of dimension \(J \times 2\).
Polynomial order of local polynomial estimator.
The order of the derivatives of the regression functions to be estimated; a numeric vector of length 2 specifying the number of derivatives in each coordinate (e.g., \(c(1,2)\) corresponds to \(\partial_1 \partial_2^2\)).
Tangent vectors; a matrix or data frame of dimension \(J \times 2\) specifying directional derivatives. Overrides deriv if provided.
Kernel function to use. Options are "unif", "uniform" (uniform), "triag", "triangular" (triangular, default), and "epan", "epanechnikov" (Epanechnikov).
Kernel structure. Either "prod" for product kernels (default) or "rad" for radial kernels.
Bandwidth selection strategy. Options:
"mserd". One common MSE-optimal bandwidth selector for the boundary RD treatment effect estimator for each evaluation point (default).
"imserd". IMSE-optimal bandwidth selector for the boundary RD treatment effect estimator based on all evaluation points.
"msetwo". Two different MSE-optimal bandwidth selectors (control and treatment) for the boundary RD treatment effect estimator for each evaluation point.
"imsetwo". Two IMSE-optimal bandwidth selectors (control and treatment) for the boundary RD treatment effect estimator based on all evaluation points.
"user provided". User-provided bandwidths. If h is not NULL, then bwselect is overwritten to "user provided".
Bandwidth selection method for bias estimator based on local polynomials. Either "dpi" (default) for data-driven plug-in MSE optimal bandwidth selector or "rot" for rule-of-thumb bandwidth selector.
Variance-covariance estimation method. Options are:
"hc0": heteroskedasticity-robust plug-in residual variance estimator without small-sample adjustment.
"hc1": heteroskedasticity-robust plug-in residual variance estimator with HC1 small-sample adjustment (default).
"hc2": heteroskedasticity-robust plug-in residual variance estimator with HC2 adjustment.
"hc3": heteroskedasticity-robust plug-in residual variance estimator with HC3 adjustment.
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least bwcheck observations are used. If masspoints == "adjust", ensure at least bwcheck unique observations are used. The program stops with “not enough observations” if sample size \(N\) < bwcheck. Default is 50 + p + 1.
Handling of mass points in the running variable. Options are:
"check": detects presence of mass points and reports the number of unique observations (default).
"adjust": adjusts preliminary bandwidths to ensure a minimum number of unique observations within each side of the cutoff.
"off": ignores presence of mass points.
Cluster ID variable used for cluster-robust variance estimation. Default is C = NULL.
Scaling factor for the regularization term in bandwidth selection. Default is 3.
Scaling factor used for bias correction based on higher order expansions. Default is 1.
Logical. If TRUE, the running variables \(X_{1i}\) and \(X_{2i}\) are standardized before computing the bandwidths. Default is TRUE. Standardization only affects automatic bandwidth selection if bandwidths are not manually provided via h.
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
rd2d, print.rdbw2d, summary.rdbw2d
# Simulated example
set.seed(123)
n <- 5000
X1 <- rnorm(n)
X2 <- rnorm(n)
t <- as.numeric(X1 > 0)
Y <- 3 + 2 * X1 + 1.5 * X2 + t + rnorm(n)
X <- cbind(X1, X2)
b <- matrix(c(0, 0, 0, 1), ncol = 2)
# MSE optimal bandwidth for rd2d
bws <- rdbw2d(Y, X, t, b)
# View the bandwidth selection results
print(bws)
summary(bws)
Run the code above in your browser using DataLab