rdbw2d {rd2d} | R Documentation |
Bandwidth Selection for 2D Local Polynomial RD Design
Description
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/
Usage
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
)
Arguments
Y |
Dependent variable; a numeric vector of length |
X |
Bivariate running variable (a.k.a score variable); a numeric matrix or data frame of dimension |
t |
Treatment indicator; a logical or binary vector indicating treatment assignment ( |
b |
Evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order of local polynomial estimator. |
deriv |
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., |
tangvec |
Tangent vectors; a matrix or data frame of dimension |
kernel |
Kernel function to use. Options are |
kernel_type |
Kernel structure. Either |
bwselect |
Bandwidth selection strategy. Options:
|
method |
Bandwidth selection method for bias estimator based on local polynomials. Either |
vce |
Variance-covariance estimation method. Options are:
|
bwcheck |
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least |
masspoints |
Handling of mass points in the running variable. Options are:
|
C |
Cluster ID variable used for cluster-robust variance estimation. Default is |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is 3. |
scalebiascrct |
Scaling factor used for bias correction based on higher order expansions. Default is 1. |
stdvars |
Logical. If TRUE, the running variables |
Value
A list of class "rdbw2d"
containing:
bws
Data frame of estimated bandwidths for each evaluation point:
b1
First coordinate of the evaluation point.
b2
Second coordinate of the evaluation point.
h01
Estimated bandwidth for
X_{1i}
in the control group (\mathcal{A}_0
).h02
Estimated bandwidth for
X_{2i}
in the control group (\mathcal{A}_0
).h11
Estimated bandwidth for
X_{1i}
in the treatment group (\mathcal{A}_1
).h12
Estimated bandwidth for
X_{2i}
in the treatment group (\mathcal{A}_1
).
mseconsts
Data frame of intermediate quantities used in bandwidth calculation:
Nh0
Effective sample size for the control group
\mathcal{A}_0
.Nh1
Effective sample size for the treatment group
\mathcal{A}_1
.bias.0
Bias constant estimate for the control group.
bias.1
Bias constant estimate for the treatment group.
var.0
Variance constant estimate for the control group.
var.1
Variance constant estimate for the treatment group.
reg.bias.0
Bias correction adjustment for the control group.
reg.bias.1
Bias correction adjustment for the treatment group.
reg.var.0
Variance of the bias estimate for the control group.
reg.var.1
Variance of the bias estimate for the treatment group.
opt
List containing:
p
Polynomial order used for estimation.
kernel
Kernel function used.
kernel_type
Type of kernel (product or radial).
stdvars
Logical indicating if standardization was applied.
bwselect
Bandwidth selection strategy used.
method
Bandwidth estimation method.
vce
Variance estimation method.
scaleregul
Scaling factor for regularization.
scalebiascrct
Scaling factor for bias correction.
N
Total sample size
N
.
Author(s)
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
References
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
See Also
rd2d
, print.rdbw2d
, summary.rdbw2d
Examples
# 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)