| Type: | Package |
| Title: | Testing Equality of Natural Mediation Effects and Their Randomized Interventional Analogues |
| Version: | 0.4.0 |
| Maintainer: | Ang Yu <ang_yu@outlook.com> |
| Copyright: | Ang Yu (ria.test extensions), Nicholas Williams and Iván Díaz (code derived from crumble). |
| Description: | Implements the empirical test introduced by Yu, Ge, and Elwert (2025) <doi:10.48550/arXiv.2407.02671> 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. |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.2.0) |
| URL: | https://github.com/ang-yu/ria.test |
| BugReports: | https://github.com/ang-yu/ria.test/issues |
| Additional_repositories: | https://mlr-org.r-universe.dev |
| Imports: | checkmate, Matrix, origami, torch, Rsymphony, purrr, cli, S7, data.table, coro, generics, mlr3superlearner (≥ 0.1.2), lightgbm, earth, nnet, progressr, ife (≥ 0.2.5) |
| Suggests: | mlr3extralearners, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-17 05:50:47 UTC; Ang |
| Author: | Ang Yu |
| Repository: | CRAN |
| Date/Publication: | 2026-11-17 08:50:02 UTC |
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- generics
Estimate randomized interventional analogues and their falsification test statistic
Description
Estimate the total effect, its randomized interventional analogue (RIA),
their difference, and the randomized interventional indirect and direct effects.
TE - TE^R is the test statistic for the composite null
NIE = NIE^R and NDE = NDE^R.
Usage
ria.test(
data,
trt,
out,
med,
pre,
post,
obs = NULL,
id = NULL,
d0 = NULL,
d1 = NULL,
weights = rep(1, nrow(data)),
learners = list("lightgbm", "mean", "earth", list("nnet", decay = 0.001)),
nn_module = sequential_module(),
control = ria.test.control()
)
Arguments
data |
[ |
trt |
[ |
out |
[ |
med |
[ |
pre |
[ |
post |
[ |
obs |
[ |
id |
[ |
d0 |
[ |
d1 |
[ |
weights |
[ |
learners |
[ |
nn_module |
[ |
control |
[ |
Value
A ria.test object containing TE, TE^R,
TE - TE^R, NIE^R, and NDE^R, along with the matched call.
Examples
if (torch::torch_is_installed()) {
set.seed(123)
n <- 200
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)
res <- 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)),
learners = "glm",
control = ria.test.control(
crossfit_folds = 2L,
mlr3superlearner_folds = 2L,
lprime_folds = 2L,
epochs = 2L,
torch_seed = 123L
)
)
tidy(res)
}
ria.test control parameters
Description
ria.test control parameters
Usage
ria.test.control(
crossfit_folds = 5L,
mlr3superlearner_folds = 10L,
lprime_folds = 2L,
epochs = 10L,
learning_rate = 0.001,
batch_size = 64,
device = c("cpu", "cuda", "mps"),
torch_seed = 1L
)
Arguments
crossfit_folds |
[ |
mlr3superlearner_folds |
[ |
lprime_folds |
[ |
epochs |
[ |
learning_rate |
[ |
batch_size |
[ |
device |
[ |
torch_seed |
[ |
Value
A list of control parameters
Examples
if (torch::torch_is_installed()) ria.test.control(crossfit_folds = 5)
Sequential neural network module function factory
Description
Sequential neural network module function factory
Usage
sequential_module(layers = 1, hidden = 20, dropout = 0.2)
Arguments
layers |
[numeric(1)] |
|
[numeric(1)] | |
dropout |
[numeric(1)] |
Value
A function that returns a sequential neural network module.
Examples
if (torch::torch_is_installed()) sequential_module()
Tidy a ria.test object
Description
Tidy a ria.test object
Usage
## S3 method for class 'ria.test'
tidy(x, ...)
Arguments
x |
A 'ria.test' object produced by a call to [ria.test::ria.test()]. |
... |
Unused, included for generic consistency only. |
Value
A data frame summarizing the requested effect estimates.
Examples
if (torch::torch_is_installed()) {
set.seed(123)
n <- 200
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)
res <- 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)),
learners = "glm",
control = ria.test.control(
crossfit_folds = 2L,
mlr3superlearner_folds = 2L,
lprime_folds = 2L,
epochs = 2L,
torch_seed = 123L
)
)
tidy(res)
}