| Title: | Testing Equality of Natural Mediation Effects and Their Randomized Interventional Analogues |
|---|---|
| Description: | 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. |
| Authors: | Ang Yu [aut, cre, cph] (Author and copyright holder of ria.test-specific extensions), Nicholas Williams [aut, cph] (ORCID: <https://orcid.org/0000-0002-1378-4831>, Author and copyright holder of code derived from crumble), Richard Liu [ctb] (Contributor to code derived from crumble), Iván Díaz [aut, cph] (ORCID: <https://orcid.org/0000-0001-9056-2047>, Author and copyright holder of code derived from crumble) |
| Maintainer: | Ang Yu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.1 |
| Built: | 2026-07-22 08:46:16 UTC |
| Source: | https://github.com/ang-yu/ria.test |
Estimate the total effect, its randomized interventional analogue (RIA),
their difference, and the randomized interventional indirect and direct effects.
is the test statistic for the composite null
and .
ria.test( data, trt, outcome, mediators, pre, post, obs = NULL, id = NULL, d0 = NULL, d1 = NULL, weights = rep(1, nrow(data)), learners = "glm", nn_module = sequential_module(), control = ria.test.control() )ria.test( data, trt, outcome, mediators, pre, post, obs = NULL, id = NULL, d0 = NULL, d1 = NULL, weights = rep(1, nrow(data)), learners = "glm", nn_module = sequential_module(), control = ria.test.control() )
data |
[ |
trt |
[ |
outcome |
[ |
mediators |
[ |
pre |
[ |
post |
[ |
obs |
[ |
id |
[ |
d0 |
[ |
d1 |
[ |
weights |
[ |
learners |
[ |
nn_module |
[ |
control |
[ |
A ria.test object containing , ,
, , and , along with the matched call.
if (torch::torch_is_installed()) { set.seed(123) n <- 200 w <- rnorm(n) a <- rbinom(n, 1, plogis(w)) l <- rnorm(n, a + w) m <- rnorm(n, a + l + w) y <- rnorm(n, a + l + m + w) dat <- data.frame(w, a, l, m, y) res <- ria.test( data = dat, trt = "a", outcome = "y", mediators = "m", pre = "w", post = "l", d0 = \(data, trt) rep(0, nrow(data)), d1 = \(data, trt) rep(1, nrow(data)), control = ria.test.control( crossfit_folds = 1L, mlr3superlearner_folds = 2L, zprime_folds = 2L, epochs = 2L, torch_seed = 123L ) ) print(res) tidy(res) }if (torch::torch_is_installed()) { set.seed(123) n <- 200 w <- rnorm(n) a <- rbinom(n, 1, plogis(w)) l <- rnorm(n, a + w) m <- rnorm(n, a + l + w) y <- rnorm(n, a + l + m + w) dat <- data.frame(w, a, l, m, y) res <- ria.test( data = dat, trt = "a", outcome = "y", mediators = "m", pre = "w", post = "l", d0 = \(data, trt) rep(0, nrow(data)), d1 = \(data, trt) rep(1, nrow(data)), control = ria.test.control( crossfit_folds = 1L, mlr3superlearner_folds = 2L, zprime_folds = 2L, epochs = 2L, torch_seed = 123L ) ) print(res) tidy(res) }
ria.test control parameters
ria.test.control( crossfit_folds = 10L, mlr3superlearner_folds = 10L, zprime_folds = 1L, epochs = 100L, learning_rate = 0.01, batch_size = 64, device = c("cpu", "cuda", "mps"), torch_seed = NULL )ria.test.control( crossfit_folds = 10L, mlr3superlearner_folds = 10L, zprime_folds = 1L, epochs = 100L, learning_rate = 0.01, batch_size = 64, device = c("cpu", "cuda", "mps"), torch_seed = NULL )
crossfit_folds |
[ |
mlr3superlearner_folds |
[ |
zprime_folds |
[ |
epochs |
[ |
learning_rate |
[ |
batch_size |
[ |
device |
[ |
torch_seed |
[ |
A list of control parameters
if (torch::torch_is_installed()) ria.test.control(crossfit_folds = 5)if (torch::torch_is_installed()) ria.test.control(crossfit_folds = 5)
Sequential neural network module function factory
sequential_module(layers = 1, hidden = 20, dropout = 0.1)sequential_module(layers = 1, hidden = 20, dropout = 0.1)
layers |
[numeric(1)] |
|
[numeric(1)] |
|
dropout |
[numeric(1)] |
A function that returns a sequential neural network module.
if (torch::torch_is_installed()) sequential_module()if (torch::torch_is_installed()) sequential_module()
Tidy a ria.test object
## S3 method for class 'ria.test' tidy(x, ...)## S3 method for class 'ria.test' tidy(x, ...)
x |
A 'ria.test' object produced by a call to [ria.test::ria.test()]. |
... |
Unused, included for generic consistency only. |
A data frame summarizing the requested effect estimates.
if (torch::torch_is_installed()) { set.seed(123) n <- 200 w <- rnorm(n) a <- rbinom(n, 1, plogis(w)) l <- rnorm(n, a + w) m <- rnorm(n, a + l + w) y <- rnorm(n, a + l + m + w) dat <- data.frame(w, a, l, m, y) res <- ria.test( data = dat, trt = "a", outcome = "y", mediators = "m", pre = "w", post = "l", d0 = \(data, trt) rep(0, nrow(data)), d1 = \(data, trt) rep(1, nrow(data)), control = ria.test.control( crossfit_folds = 1L, mlr3superlearner_folds = 2L, zprime_folds = 2L, epochs = 2L, torch_seed = 123L ) ) print(res) tidy(res) }if (torch::torch_is_installed()) { set.seed(123) n <- 200 w <- rnorm(n) a <- rbinom(n, 1, plogis(w)) l <- rnorm(n, a + w) m <- rnorm(n, a + l + w) y <- rnorm(n, a + l + m + w) dat <- data.frame(w, a, l, m, y) res <- ria.test( data = dat, trt = "a", outcome = "y", mediators = "m", pre = "w", post = "l", d0 = \(data, trt) rep(0, nrow(data)), d1 = \(data, trt) rep(1, nrow(data)), control = ria.test.control( crossfit_folds = 1L, mlr3superlearner_folds = 2L, zprime_folds = 2L, epochs = 2L, torch_seed = 123L ) ) print(res) tidy(res) }