rdbwhte: Data-Driven Optimal Bandwidth Selection for RD Heterogeneous...

View source: R/rdbwhte.R

rdbwhteR Documentation

Data-Driven Optimal Bandwidth Selection for RD Heterogeneous Treatment Effects Estimation

Description

rdbwhte computes MSE- and CER-optimal bandwidths for estimating RD heterogeneous treatment effects based on covariates (Calonico, Cattaneo, Farrell, Palomba and Titiunik, 2025a).

Companion commands: rdhte for RD HTE estimation and inference, and rdhte_lincom for testing linear restrictions of parameters.

A detailed introduction to the software is given in Calonico, Cattaneo, Farrell, Palomba and Titiunik (2025b). Related software packages for analysis and interpretation of RD designs and related methods are available in: https://rdpackages.github.io/.

For background methodology, see Calonico, Cattaneo, Farrell, and Titiunik (2019), Calonico, Cattaneo and Farrell (2020), and Cattaneo and Titiunik (2022).

Usage

rdbwhte(
  y,
  x,
  c = 0,
  covs.hte = NULL,
  covs.eff = NULL,
  p = 1,
  q = NULL,
  kernel = "tri",
  weights = NULL,
  vce = "hc3",
  cluster = NULL,
  bwselect = "mserd",
  bw.joint = FALSE,
  subset = NULL,
  data = NULL
)

Arguments

y

Outcome variable.

x

Running variable.

c

RD cutoff in x; default is c = 0.

covs.hte

covariates for heterogeneous treatment effects. Factor variables can be used to distinguish between continuous and categorical variables, select reference categories, specify interactions between variables, and include polynomials of continuous variables.

covs.eff

additional covariates to be used for efficiency improvements.

p

order of the local polynomial used to construct the point estimator (default = 1).

q

order of the local polynomial used to construct the bias correction. If NULL (default), q is set to p + 1.

kernel

kernel function used to construct the RD estimators. Options are triangular (default option), epanechnikov and uniform.

weights

variable used for optional weighting of the bandwidth-selection procedure. The unit-specific weights multiply the kernel function.

vce

character string specifying the variance-covariance matrix estimator type. Without cluster: "hc0", "hc1", "hc2", "hc3" (default "hc3"). With cluster: "cr1" (default), "cr2", "cr3". Legacy aliases: "hc0"/"hc1" + cluster are remapped to "cr1" with a warning; "hc2" -> "cr2" and "hc3" -> "cr3" similarly. "cr1", "cr2", "cr3" without cluster fall back to "hc1", "hc2", "hc3" with a warning.

cluster

variable indicating the clustering of observations.

bwselect

bandwidth selection procedure to be used. Options are: mserd one common MSE-optimal bandwidth selector for the RD treatment effect estimator. msetwo two different MSE-optimal bandwidth selectors (below and above the cutoff) for the RD treatment effect estimator. msesum one common MSE-optimal bandwidth selector for the sum of regression estimates (as opposed to difference thereof). msecomb1 for min(mserd,msesum). msecomb2 for median(msetwo,mserd,msesum), for each side of the cutoff separately. cerrd one common CER-optimal bandwidth selector for the RD treatment effect estimator. certwo two different CER-optimal bandwidth selectors (below and above the cutoff) for the RD treatment effect estimator. cersum one common CER-optimal bandwidth selector for the sum of regression estimates (as opposed to difference thereof). cercomb1 for min(cerrd,cersum). cercomb2 for median(certwo,cerrd,cersum), for each side of the cutoff separately. Note: MSE = Mean Square Error; CER = Coverage Error Rate. Default is bwselect=mserd.

bw.joint

logical. If TRUE, forces all bandwidths to be the same across groups (default is bw.joint = FALSE). When covs.hte is continuous (rather than a factor or 0/1 indicator), a single joint bandwidth is always used regardless of this argument.

subset

optional vector specifying a subset of observations to be used.

data

optional data frame. When supplied, y, x, covs.hte, covs.eff, weights, cluster, and subset may be given as bare variable names referring to columns of data.

Value

A list with the following named elements:

W.lev

Group-level identifiers, or NULL for continuous covs.hte.

W.names

Display labels for the rows of h (prefixed with the covs.hte expression for categorical covs.hte).

covs.hte_chr

Character representation of the covs.hte argument.

kernel

Kernel type used.

vce

Variance estimator display label.

vce_select

Canonical lowercase variance-estimator name.

c

Cutoff value.

h

An n.lev x 2 matrix of left/right bandwidths, one row per group.

p

Order of the polynomial used for estimation.

q

Order of the polynomial used for bias correction.

bwselect

Bandwidth selection procedure used.

N

Length-2 vector c(N_left, N_right) of pre-bandwidth sample sizes.

Nh

An n.lev x 2 matrix of effective sample sizes (per group, per side).

covs.cont

Logical; TRUE for continuous covs.hte (or no covs.hte), FALSE for factor.

rdmodel

Human-readable model description string.

Author(s)

Sebastian Calonico, University of California, Davis scalonico@ucdavis.edu.

Matias D. Cattaneo, Princeton University matias.d.cattaneo@gmail.com.

Max H. Farrell, University of California, Santa Barbara mhfarrell@gmail.com.

Filippo Palomba, Princeton University filippo.palomba19@gmail.com.

Rocio Titiunik, Princeton University rocio.titiunik@gmail.com.

References

Calonico, Cattaneo, Farrell, Palomba and Titiunik (2025): rdhte: Conditional Average Treatment Effects in RD Designs. Working paper.

Calonico, Cattaneo, Farrell, Palomba and Titiunik (2025): Treatment Effect Heterogeneity in Regression Discontinuity Designs. Working paper.

Cattaneo and Titiunik. 2022. Regression Discontinuity Designs. Annual Review of Economics, 14: 821-851.

Calonico, Cattaneo, and Farrell. 2020. Optimal Bandwidth Choice for Robust Bias Corrected Inference in Regression Discontinuity Designs. Econometrics Journal, 23(2): 192-210.

Calonico, Cattaneo, Farrell, and Titiunik. 2019. Regression Discontinuity Designs using Covariates. Review of Economics and Statistics, 101(3): 442-451.

Calonico, Cattaneo, and Titiunik. 2014a. Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs. Econometrica 82(6): 2295-2326.

Granzier, Pons, and Tricaud. 2023. Coordination and Bandwagon Effects: How Past Rankings Shape the Behavior of Voters and Candidates. American Economic Journal: Applied Economics, 15(4): 177-217.

See Also

rdhte, rdhte_lincom

Examples

set.seed(123)
n <- 5000
X <- runif(n, -1, 1)
W <- rbinom(n, 1, 0.5)
Y <- 3 + 2*X + 1.5*X^2 + 0.5*X^3 + sin(2*X) + 3*W*(X>=0) + rnorm(n)
rdbwhte.1 = rdbwhte(y=Y, x=X, covs.hte=factor(W))
summary(rdbwhte.1)

## Not run: 
data(rdhte_dataset)
with(rdhte_dataset, {
  summary(rdbwhte(y = y, x = x, covs.hte = factor(w_ideology),
                  cluster = cluster_var))
  summary(rdbwhte(y = y, x = x, covs.hte = factor(w_ideology),
                  cluster = cluster_var, bw.joint = TRUE))
  summary(rdbwhte(y = y, x = x, covs.hte = w_strength,
                  cluster = cluster_var))
})

## End(Not run)

rdhte documentation built on May 27, 2026, 1:06 a.m.