Implements the empirical test introduced by Yu, Ge, and Elwert
(2025)
ria.test implements the empirical test introduced by Yu, Ge, and
Elwert (2025) for detecting when
randomized interventional analogues should not be interpreted as natural
mediation effects. The test estimates TE - TE^R, the difference
between the total effect and its randomized interventional analogue.
Rejecting TE - TE^R = 0 falsifies the composite null that the natural
indirect and direct effects equal their randomized interventional
analogues. The procedure remains valid in settings where the natural
effects themselves are not identified, and |TE - TE^R| provides a
lower bound on the total divergence between the natural and randomized
interventional decompositions. The estimation uses a Riesz-regression
approach.
ria.test is derived from the crumble package with various adaptations. {ria.test} uniquely enables statistical inference for the estimated TE − TER. Separately, {ria.test} also makes improvements in terms of reproducibility, efficiency, and the handling of edge cases.
install.packages("ria.test")
The default ensemble uses the LightGBM and MARS wrappers from
mlr3extralearners. Install these once before running the example
below. If you use learners = "glm", you can skip this step.
install.packages("mlr3extralearners",
repos = c("https://mlr-org.r-universe.dev", "https://cloud.r-project.org"))
library(ria.test)
set.seed(123)
n <- 500
C <- rnorm(n)
D <- rbinom(n, 1, plogis(C))
L <- rnorm(n, D + C)
M <- rnorm(n, D + L + C)
Y <- rnorm(n, D + L + M + C)
dat <- data.frame(C, D, L, M, Y)
test_fit <- ria.test(
data = dat,
trt = "D",
out = "Y",
med = "M",
pre = "C",
post = "L",
d0 = \(data, trt) rep(0, nrow(data)),
d1 = \(data, trt) rep(1, nrow(data)),
control = ria.test.control(torch_seed = 123L)
)
tidy(test_fit)