Package {rdhte}


Title: Heterogeneous Treatment Effects in Regression Discontinuity Designs
Version: 0.2.0
Description: Understanding heterogeneous causal effects based on pretreatment covariates is a crucial step in modern empirical work in data science. Building on the recent developments in Calonico et al (2025) <doi:10.48550/arXiv.2503.13696>, this package provides tools for estimation and inference of heterogeneous treatment effects in Regression Discontinuity (RD) Designs. The package includes two main commands: 'rdhte' to conduct estimation and robust bias-corrected inference for conditional RD treatment effects (given choice of bandwidth parameter); 'rdbwhte', which implements automatic bandwidth selection methods; and 'rdhte_lincom' to test linear combinations of parameters.
License: GPL-3
Imports: rdrobust (≥ 4.0.0), sandwich, multcomp
Encoding: UTF-8
Suggests: broom, ggplot2, knitr, rmarkdown, testthat (≥ 3.0.0), xtable
Config/testthat/edition: 3
VignetteBuilder: knitr
Depends: R (≥ 3.5)
LazyData: true
NeedsCompilation: no
Packaged: 2026-05-26 16:50:59 UTC; ncalonic
Author: Sebastian Calonico [aut, cre], Matias D. Cattaneo [aut], Max H. Farrell [aut], Filippo Palomba [aut], Rocio Titiunik [aut]
Maintainer: Sebastian Calonico <scalonico@ucdavis.edu>
Repository: CRAN
Date/Publication: 2026-05-26 17:30:02 UTC

rdhte: RD Heterogeneous Treatment Effects Estimation and Inference

Description

Building on the recent developments in Calonico, Cattaneo, Farrell, Palomba, and Titiunik (2025), this package implements estimation and inference of heterogeneous treatment effects in RD designs. The package includes two main commands: rdhte conduct estimation and robust bias-corrected inference for conditional RD treatment effects, for a given choice of bandwidth parameter; and rdbwhte implements automatic bandwidth selection methods. We illustrate the methods implemented in the package rdhte using a canonical empirical application. We also demonstrate how the package rdhte complements, and in very specific cases recovers, the methods available in the packages rdrobust (Calonico, Cattaneo, Farrell, Titiunik (2017) and rdmulti, Cattaneo, Titiunik, VazquezBare (2020).

Commands: rdhte for estimation and inference. rdbwhte for data-driven bandwidth selection.

Related software packages useful for inference in regression discontinuity (RD) designs are described in the website: https://rdpackages.github.io/.

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.


Glance at a rdbwhte object

Description

broom-compatible glance() method. Returns a one-row summary of the bandwidth-selection call.

Usage

## S3 method for class 'rdbwhte'
glance(x, ...)

Arguments

x

A rdbwhte object.

...

ignored.

Value

A one-row data frame.


Glance at a rdhte object

Description

broom-compatible glance() method. Returns a one-row summary of the fit (sample sizes, polynomial orders, kernel, VCE, BW selector).

Usage

## S3 method for class 'rdhte'
glance(x, ...)

Arguments

x

A rdhte object.

...

ignored.

Value

A one-row data frame.


Plot rdhte heterogeneous treatment effects

Description

For an rdhte object fit with a categorical covs.hte, draw one point per group at the conventional point estimate (Estimate) with the robust bias-corrected confidence interval (ci.rb). A dashed horizontal line at zero gives a visual reference for the null effect.

Usage

## S3 method for class 'rdhte'
plot(x, sort = FALSE, point.size = 2.5,
                     errorbar.width = 0.2, zero.line = TRUE,
                     title = NULL, xlab = NULL, ylab = NULL, ...)

Arguments

x

An object of class rdhte returned by rdhte.

sort

Logical or character; if TRUE (or "effect"), reorder groups along the x-axis by point estimate. FALSE (default) keeps the original W.lev order.

point.size

Numeric; size of the point markers. Default 2.5.

errorbar.width

Numeric; width of the error-bar caps relative to the x-axis discrete unit. Default 0.2.

zero.line

Logical; if TRUE (default), draw a dashed horizontal line at y = 0.

title, xlab, ylab

Optional plot annotations. Defaults derived from the rdhte object (x$rdmodel, x$covs.hte_chr, "Treatment effect").

...

Currently unused.

Details

Continuous covs.hte (or no covs.hte) is not yet supported – the function errors with a clear message in those cases.

Requires the ggplot2 package. The intervals shown are the same robust bias-corrected CIs reported by print(x) and summary(x): they are centered on Estimate.bc (not Estimate) and use the robust standard error se.rb. Because the point and the CI center can differ slightly, the point may sit just inside or just outside the bar; this is the rdrobust convention and is not a plotting bug.

Value

Invisibly, a ggplot object.

Examples

## Not run: 
  set.seed(1)
  n <- 600
  x <- runif(n, -1, 1)
  W <- factor(sample(c("A", "B", "C"), n, replace = TRUE))
  y <- 0.5 + (x >= 0) * (W == "A") * 1.0 +
             (x >= 0) * (W == "B") * 2.0 +
             (x >= 0) * (W == "C") * 0.3 + rnorm(n)
  m <- rdhte(y = y, x = x, covs.hte = W)
  plot(m)
  plot(m, sort = TRUE)        # reorder by effect size

## End(Not run)

Internal function.

Description

Internal function.

Usage

## S3 method for class 'rdbwhte'
print(x, ...)

Arguments

x

Class rdhte objects.

Value

No return value, called for side effects.


Internal function.

Description

Internal function.

Usage

## S3 method for class 'rdhte'
print(x, ...)

Arguments

x

Class rdhte objects.

Value

No return value, called for side effects.


Internal function.

Description

Internal function.

Usage

## S3 method for class 'summary.rdbwhte'
print(x, ...)

Arguments

x

Class summary.rdbwhte object.

...

ignored.

Value

The input x returned invisibly; called for side effects.


Internal function.

Description

Internal function.

Usage

## S3 method for class 'summary.rdhte'
print(x, ...)

Arguments

x

Class summary.rdhte object returned by summary.rdhte.

...

ignored.

Value

The input x returned invisibly; called for side effects.


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)

RD Heterogeneous Treatment Effects Estimation and Inference

Description

rdhte provides estimation and inference for heterogeneous treatment effects in RD designs using local polynomial regressions, allowing for interactions with pretreatment covariates (Calonico, Cattaneo, Farrell, Palomba and Titiunik, 2025a). Inference is implemented using robust bias-correction methods (Calonico, Cattaneo, and Titiunik, 2014)

Companion commands: rdbwhte for data-driven bandwidth selection 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

rdhte(
  y,
  x,
  c = 0,
  covs.hte = NULL,
  covs.eff = NULL,
  p = 1,
  q = NULL,
  kernel = "tri",
  weights = NULL,
  h = NULL,
  h.l = NULL,
  h.r = NULL,
  vce = "hc3",
  cluster = NULL,
  level = 95,
  bwselect = "mserd",
  bw.joint = FALSE,
  subset = NULL,
  data = NULL,
  target.contrast = 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. If not specified, the RD Average Treatment Effect is computed.

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 estimation procedure. The unit-specific weights multiply the kernel function.

h

main bandwidth used to construct the RD estimator. If not specified, bandwidth h is computed by the companion command rdbwhte. More than one bandwidth can be specified for categorical covariates.

h.l

same as h, but only used for observations left of the cutoff c.

h.r

same as h, but only used for observations right of the cutoff c.

vce

character string specifying the variance-covariance matrix estimator type. Without cluster: "hc0", "hc1", "hc2", "hc3" (default "hc3"). With cluster: "cr1" (default; standard cluster-robust sandwich with small-sample correction), "cr2" (Bell-McCaffrey leverage-adjusted), "cr3" (block-jackknife). 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. It is based on the R function vcovCL.

cluster

variable indicating the clustering of observations.

level

confidence level for confidence intervals; default is level = 95.

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. covs.hte additionally accepts a one-sided formula (e.g. "~ z1 + z2") whose variables are looked up in data first.

target.contrast

(experimental, in-flight) optional contrast vector or matrix used to refit the bandwidth to be MSE-optimal for a particular contrast of the CATE vector. NULL (default) keeps the standard per-cell MSE-optimal bandwidth. API may change.

Value

A list with the following named elements:

Estimate

Vector of conventional local-polynomial RD estimates, one per group level (or per slope-coefficient for continuous covs.hte). Also available as coef.

Estimate.bc

Vector of bias-corrected estimates. Also available as coef.bc.

se.rb

Vector of robust bias-corrected standard errors.

ci.rb

Matrix (n.lev x 2) of robust bias-corrected confidence-interval bounds.

t.rb

Vector of asymptotic z-statistics (named t.rb for legacy reasons; the underlying inference is Gaussian).

pv.rb

Vector of two-sided p-values from the standard normal.

vcov

Group-level variance-covariance matrix of Estimate.bc.

coef.full

Full coefficient vector from the underlying joint local-polynomial regression (used by rdhte_lincom).

vcov.full

Full variance-covariance matrix of coef.full.

W.lev

Group-level identifiers (or coefficient names for continuous covs.hte).

W.names

Display labels for the rows of Estimate.

kernel

Kernel type used (e.g. "Triangular").

bwselect

Bandwidth selection procedure used.

vce

Variance estimator display label (e.g. "CR1", "HC3").

vce_select

Canonical lowercase variance-estimator name (e.g. "cr1", "hc3").

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.

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.

level

Confidence level used.

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

rdbwhte, rdhte_lincom

Examples

set.seed(123)
n <- 1000
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)
m1 = rdhte(y = Y, x = X, covs.hte = factor(W))
summary(m1)

## Not run: 
# Empirical examples using the bundled Granzier, Pons, and Tricaud data.
data(rdhte_dataset)
with(rdhte_dataset, {
  rd_left <- rdhte(y = y, x = x, covs.hte = factor(w_left),
                   cluster = cluster_var)
  summary(rd_left)
  rdhte_lincom(rd_left,
               linfct = "`factor(w_left)1` - `factor(w_left)0` = 0")

  summary(rdhte(y = y, x = x, covs.hte = factor(w_left),
                cluster = cluster_var, bw.joint = TRUE))
  summary(rdhte(y = y, x = x, covs.hte = factor(w_left):factor(w_strong),
                cluster = cluster_var))
  summary(rdhte(y = y, x = x, covs.hte = w_strength,
                kernel = "uni", cluster = cluster_var))
})

## End(Not run)

RD Heterogeneous Treatment Effects: contrast-targeted bandwidth

Description

rdhte_contrast refits an rdhte model at the MSE-optimal bandwidth for a single user-chosen linear combination of the Estimate vector and returns the resulting point estimate, robust bias-corrected estimate, standard error, p-value, and confidence interval.

Usage

rdhte_contrast(model, contrast, refit = TRUE, level = 95, tol = 1e-10)

Arguments

model

A fitted model returned by rdhte.

contrast

Numeric vector with length equal to nrow(model$Estimate). The user-facing linear combination of Estimate rows whose MSE is optimized.

refit

Logical. TRUE refits the model at the contrast-targeted bandwidth. FALSE projects the existing fit and returns inference under the model's current bandwidth.

level

Confidence level in percentage form, in [1, 100).

tol

Tolerance below which the estimated contrast bias is treated as zero and the contrast-targeted bandwidth is declared undefined.

Details

Use rdhte_lincom instead when you want joint Wald inference on several linear restrictions at one bandwidth.

Value

A list with the conventional estimate, robust bias-corrected estimate, robust standard error, z-statistic, p-value, confidence interval, selected bandwidth, pilot bandwidth, contrast diagnostics, and (when refit = TRUE) the refitted rdhte object.

See Also

rdhte, rdhte_lincom

Examples

## Not run: 
set.seed(123)
n <- 1000
X <- runif(n, -1, 1)
W <- rbinom(n, 1, 0.5)
Y <- 3 + 2 * X + 1.5 * X^2 + 3 * W * (X >= 0) + rnorm(n)
m <- rdhte(y = Y, x = X, covs.hte = factor(W))
rdhte_contrast(m, contrast = c(-1, 1))

## End(Not run)

Granzier-Pons-Tricaud Election Dataset for rdhte Illustrations

Description

A working extract of the data used in Granzier, Pons, and Tricaud (2023, AEJ: Applied), distributed with the rdhte package as a fixed-format example dataset for the package vignette and worked examples. The running variable x is the candidate's first-round margin against the threshold for advancing to the runoff; y is an indicator for advancing.

Usage

data("rdhte_dataset")

Format

A data frame with 39,534 observations on the following variables.

y

Outcome: indicator (0/1) for advancing to the runoff.

x

Running variable: first-round margin against the qualifying threshold (the cutoff is at zero).

cluster_var

Cluster identifier (district).

w_left

Binary: 1 if the candidate's party is left of center, 0 otherwise.

w_ideology

Unordered categorical (4 levels): party ideology bucket.

w_strength

Continuous: candidate's average prior national-level vote share, used as a proxy for ex-ante candidate strength.

w_strong

Binary: above-median strength (w_strength).

w_strength_qrt

Ordered categorical (4 levels): quartile bucket of w_strength.

Source

Granzier, R., V. Pons, and C. 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.

Examples

data(rdhte_dataset)
str(rdhte_dataset)

RD Heterogeneous Treatment Effects. Linear combinations of parameters

Description

rdhte_lincom computes point estimates, p-values, and robust bias-corrected confidence intervals for linear combinations of parameters after any estimation using rdhte (Calonico, Cattaneo, Farrell, Palomba and Titiunik, 2025a). Inference is implemented using robust bias-correction methods (Calonico, Cattaneo, and Titiunik, 2014). It is based on the R function glht.

Companion commands: rdhte for estimation and inference of RD-HTE and rdbwhte for data-driven bandwidth selection.

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

rdhte_lincom(model, linfct, level = 95, digits = 3)

Arguments

model

a fitted model returned by rdhte.

linfct

a specification of the linear hypotheses to be tested. Linear functions can be specified by either the matrix of coefficients or by symbolic descriptions of one or more linear hypotheses.

level

Confidence level for intervals (percentage form, in [1, 100)); default is level = 95. Passing the fraction form (e.g. 0.95) is rejected with a clear error.

digits

Number of decimal places to format numeric outputs (default 3).

Value

A list with two data frames:

individual

One row per hypothesis. Columns: hypothesis, estimate (conventional point estimate of the linear combination), z_stat (asymptotic z-statistic from the bias-corrected fit), p_value (two-sided p-value from the standard normal), conf.low, conf.high (robust bias-corrected CI bounds at the requested confidence level).

joint

One row. Columns: statistic (Wald chi-squared from the bias-corrected fit), df (number of restrictions), p_value.

Numeric columns are rounded to digits decimal places.

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, rdbwhte

Examples

set.seed(123)
n <- 1000
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)
m1 <- rdhte(y = Y, x = X, covs.hte = factor(W))
linfct <- c("`factor(W)0` - `factor(W)1` = 0")
rdhte_lincom(model = m1, linfct = linfct)

## Not run: 
data(rdhte_dataset)
with(rdhte_dataset, {
  rd_ideology <- rdhte(y = y, x = x, covs.hte = factor(w_ideology),
                       cluster = cluster_var)
  rdhte_lincom(rd_ideology,
               linfct = c("`factor(w_ideology)4` - `factor(w_ideology)3` = 0",
                          "`factor(w_ideology)4` = 0"))
})

## End(Not run)


Summary method for rdbwhte objects.

Description

Summary method for rdbwhte objects.

Usage

## S3 method for class 'rdbwhte'
summary(object, ...)

Arguments

object

Class rdbwhte object returned by rdbwhte.

...

ignored.

Value

An S3 object inheriting from rdbwhte with class summary.rdbwhte; printed by print.summary.rdbwhte.


Summary method for rdhte objects.

Description

Summary method for rdhte objects.

Usage

## S3 method for class 'rdhte'
summary(object, ...)

Arguments

object

Class rdhte object returned by rdhte.

...

ignored.

Value

An S3 object inheriting from rdhte with class summary.rdhte; printed by print.summary.rdhte.


Tidy a rdbwhte object

Description

broom-compatible tidy() method. Returns one row per heterogeneity subgroup (factor case) or one row labelled "Overall" (continuous).

Usage

## S3 method for class 'rdbwhte'
tidy(x, ...)

Arguments

x

A rdbwhte object.

...

ignored.

Value

A data frame with columns term, h.left, h.right.


Tidy a rdhte object

Description

broom-compatible tidy() method. Returns one row per heterogeneity subgroup (factor case) or per series term (continuous case).

Usage

## S3 method for class 'rdhte'
tidy(x, ...)

Arguments

x

A rdhte object.

...

ignored.

Value

A data frame with columns term, estimate (conventional), std.error (robust SE), statistic, p.value, conf.low, conf.high (robust BC CI), estimate.bc, h.left, h.right, n.eff.left, n.eff.right.