Testing Equality of Natural Mediation Effects and Their Randomized Interventional Analogues

Implements the empirical test introduced by Yu, Ge, and Elwert (2026) 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.


ria.test

Lifecycle: experimental License: GPL v3

ria.test implements the empirical test introduced by Yu, Ge, and Elwert (2026) 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 implementation uses Riesz-regression machinery adapted from the upstream mediation-estimation codebase for the total-effect contrast and associated uncertainty estimates.

ria.test is derived from the crumble package. Attribution identifies authorship of incorporated code and does not imply endorsement of this package or its modifications.

Installation

remotes::install_github("ang-yu/ria.test")

Usage

Notation: D denotes treatment (trt), C baseline covariates (pre), and L post-treatment confounders (post). L′ is the matched donor copy of L used for the randomized interventional analogues. Set lprime_folds in ria.test.control() to control the matching batches.

library(ria.test)

# `set.seed()` controls R-level randomness; `torch_seed` controls Torch.
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",
  outcome = "Y",
  mediators = "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.3.0 by Ang Yu, 2 months 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] (Author and copyright holder of ria.test-specific extensions) , Nicholas Williams [aut, cph] (ORCID: , Author and copyright holder of code derived from crumble) , Richard Liu [ctb] (Contributor to code derived from crumble) , Iván Díaz [aut, cph] , Author and copyright holder of code derived from crumble)


Documentation:   PDF Manual  


GPL (>= 3) license


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

Suggests testthat


See at CRAN