
RD Covariate Balance Test
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.
Usage
rd_covariate_balance(
data,
covariates,
x,
c = 0,
bw = NULL,
kernel = "tri",
p = 1,
conf_level = 0.95,
theme_use = causalverse::ama_theme()
)Arguments
- data
A data frame containing the covariates and running variable.
- covariates
Character vector. Names of covariate columns to test.
- x
Character string. Name of the running variable.
- c
Numeric. The cutoff value for the RD design. Default is
0.- bw
Numeric or
NULL. Bandwidth to use for all tests. IfNULL(the default),rdrobustselects the MSE-optimal bandwidth separately for each covariate.- 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:
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.
References
Lee, D. S. and Lemieux, T. (2010). "Regression Discontinuity Designs in Economics." Journal of Economic Literature, 48(2), 281-355.
Examples
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
} # }