Testing Equality of Natural Mediation Effects and Their Randomized Interventional Analogues

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 package estimates natural effects, their randomized interventional analogues, and 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 package is built on 'crumble', authored by Nicholas Williams, Richard Liu, and Iván Díaz.


ria.test

Lifecycle:experimental License: GPL v3 CRANdownloads

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.

Installation

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"))

Usage

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)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ria.test")

0.4.0 by Ang Yu, 14 days ago


https://github.com/ang-yu/ria.test


Report a bug at https://github.com/ang-yu/ria.test/issues


Browse source code at https://github.com/cran/ria.test


Authors: Ang Yu [aut, cre, cph]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports checkmate, Matrix, origami, torch, Rsymphony, purrr, cli, S7, data.table, coro, generics, mlr3superlearner, lightgbm, earth, nnet, progressr, ife

Suggests mlr3extralearners, testthat


See at CRAN