
Local-randomisation RDD via permutation in a fixed window
Source:R/rdd.R
morie_rdd_local_randomisation.RdLocal-randomisation RDD via permutation in a fixed window
Usage
morie_rdd_local_randomisation(
data,
outcome,
running,
cutoff = 0,
window = 1,
n_permutations = 1000,
seed = 42,
alpha = 0.05
)Arguments
- data
A
data.frameholding the outcome, running variable, treatment, and any covariates referenced by name.- outcome
Character; column name of the response variable in
data.- running
Character; column name of the running (forcing) variable in
data.- cutoff
Numeric scalar; the threshold on
running. Default0(the canonical normalisation).- window
Numeric; half-width of the local randomisation window.
- n_permutations
Integer; permutation count for the randomisation-based inference.
- seed
Integer; RNG seed for permutation / bootstrap routines.
- alpha
Significance level (default
0.05).
Value
A named list with elements estimate, std_error, p_value, ci_lower, ci_upper, n_obs, method, details.
Examples
set.seed(1)
x <- runif(400, -1, 1)
y <- 0.3 * x + 1.0 * (x >= 0) + rnorm(400, sd = 0.3)
d <- data.frame(x, y)
res <- morie_rdd_local_randomisation(d, "y", "x", window = 0.3,
n_permutations = 200L, seed = 1)
res$p_value
#> [1] 0