rd_bandwidth_sensitivity.RdRuns 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.
A data frame containing the outcome and running variable.
Character string. Name of the outcome variable.
Character string. Name of the running variable.
Numeric. The cutoff value for the RD design. Default is 0.
Numeric vector. Multipliers applied to the MSE-optimal
bandwidth from rdrobust. Default is seq(0.5, 2, 0.1).
Character string. Kernel function for rdrobust.
Default is "tri" (triangular).
Integer. Order of the local polynomial. Default is 1.
Numeric. Confidence level for intervals. Default is
0.95.
A ggplot2 theme to apply to the plot. Default is
causalverse::ama_theme().
A list with components:
resultsA data frame with columns: bandwidth,
bw_multiple, estimate, std_error, ci_lower,
ci_upper, p_value, n_left, n_right.
plotA ggplot2 object showing estimates and CIs across bandwidths.
optimal_bwThe MSE-optimal bandwidth from rdrobust.
Calonico, S., Cattaneo, M. D., and Titiunik, R. (2014). "Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs." Econometrica, 82(6), 2295-2326.
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
} # }