rd_covariate_balance.RdTests covariate balance at the RD cutoff by running
rdrobust with each covariate as the outcome
variable. If the RD design is valid, predetermined covariates should not
exhibit a discontinuity at the cutoff.
rd_covariate_balance(
data,
covariates,
x,
c = 0,
bw = NULL,
kernel = "tri",
p = 1,
conf_level = 0.95,
theme_use = causalverse::ama_theme()
)A data frame containing the covariates and running variable.
Character vector. Names of covariate columns to test.
Character string. Name of the running variable.
Numeric. The cutoff value for the RD design. Default is 0.
Numeric or NULL. Bandwidth to use for all tests. If
NULL (the default), rdrobust selects the MSE-optimal
bandwidth separately for each covariate.
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:
tableA data frame with columns: covariate,
estimate, std_error, ci_lower, ci_upper,
p_value, bandwidth, n_left, n_right,
significant.
plotA ggplot2 coefficient plot showing the estimate and CI for each covariate.
Lee, D. S. and Lemieux, T. (2010). "Regression Discontinuity Designs in Economics." Journal of Economic Literature, 48(2), 281-355.
if (FALSE) { # \dontrun{
set.seed(42)
n <- 1000
x <- runif(n, -1, 1)
df <- data.frame(
x = x,
age = 30 + 5 * x + rnorm(n),
inc = 50000 + 10000 * x + rnorm(n, sd = 5000),
edu = 12 + 2 * x + rnorm(n, sd = 1.5)
)
result <- rd_covariate_balance(
data = df,
covariates = c("age", "inc", "edu"),
x = "x",
c = 0
)
result$plot
result$table
} # }