Skip to contents

Runs rdrobust over a grid of bandwidths and plots point estimates with confidence intervals against bandwidth values. This helps assess how sensitive the RD treatment effect estimate is to the choice of bandwidth.

Usage

rd_bandwidth_sensitivity(
  data,
  y,
  x,
  c = 0,
  bw_multiples = seq(0.5, 2, 0.1),
  kernel = "tri",
  p = 1,
  conf_level = 0.95,
  theme_use = causalverse::ama_theme()
)

Arguments

data

A data frame containing the outcome and running variable.

y

Character string. Name of the outcome variable.

x

Character string. Name of the running variable.

c

Numeric. The cutoff value for the RD design. Default is 0.

bw_multiples

Numeric vector. Multipliers applied to the MSE-optimal bandwidth from rdrobust. Default is seq(0.5, 2, 0.1).

kernel

Character string. Kernel function for rdrobust. Default is "tri" (triangular).

p

Integer. Order of the local polynomial. Default is 1.

conf_level

Numeric. Confidence level for intervals. Default is 0.95.

theme_use

A ggplot2 theme to apply to the plot. Default is causalverse::ama_theme().

Value

A list with components:

results

A data frame with columns: bandwidth, bw_multiple, estimate, std_error, ci_lower, ci_upper, p_value, n_left, n_right.

plot

A ggplot2 object showing estimates and CIs across bandwidths.

optimal_bw

The MSE-optimal bandwidth from rdrobust.

References

Calonico, S., Cattaneo, M. D., and Titiunik, R. (2014). "Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs." Econometrica, 82(6), 2295-2326.

Examples

if (FALSE) { # \dontrun{
set.seed(42)
n <- 1000
x <- runif(n, -1, 1)
y <- 3 + 2 * (x >= 0) + 0.5 * x + rnorm(n)
df <- data.frame(y = y, x = x)

result <- rd_bandwidth_sensitivity(
  data = df,
  y = "y",
  x = "x",
  c = 0,
  bw_multiples = seq(0.5, 2, 0.25)
)

result$plot
result$results
result$optimal_bw
} # }