plot.rdhte: Plot rdhte heterogeneous treatment effects

View source: R/plot.rdhte.R

plot.rdhteR Documentation

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)

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