crumble {crumble} | R Documentation |
Flexible and general mediation analysis
Description
General estimator for common mediation causal effects, including recanting twins, natural effects, organic effects, and randomized interventional effects. Interventions are specified using modified treatment policies. Nuisance parameters are estimated using the 'super learner' algorithm and 'Riesz learning'. Supports binary, categorical, and continuous exposures.
Usage
crumble(
data,
trt,
outcome,
mediators,
moc = NULL,
covar,
obs = NULL,
id = NULL,
d0 = NULL,
d1 = NULL,
effect = c("RT", "N", "RI", "O"),
weights = rep(1, nrow(data)),
learners = "glm",
nn_module = sequential_module(),
control = crumble_control()
)
Arguments
data |
[ |
trt |
[ |
outcome |
[ |
mediators |
[ |
moc |
[ |
covar |
[ |
obs |
[ |
id |
[ |
d0 |
[ |
d1 |
[ |
effect |
[ |
weights |
[ |
learners |
[ |
nn_module |
[ |
control |
[ |
Value
A crumble
object containing the following components:
estimates |
A list of parameter estimates. |
outcome_reg |
Predictions from the outcome regressions. |
alpha_n |
A list of density ratio estimates. |
alpha_r |
A list of density ratio estimates. |
fits |
A list of the fitted values from the outcome regressions. |
call |
The matched call. |
effect |
The estimated effect type. |
Examples
if (require("mma") && torch::torch_is_installed()) {
library(mma)
data(weight_behavior)
weight_behavior <- na.omit(weight_behavior)
res <- crumble(
data = weight_behavior,
trt = "sports",
outcome = "bmi",
covar = c("age", "sex", "tvhours"),
mediators = c("exercises", "overweigh"),
moc = "snack",
d0 = \(data, trt) factor(rep(1, nrow(data)), levels = c("1", "2")),
d1 = \(data, trt) factor(rep(2, nrow(data)), levels = c("1", "2")),
learners = c("mean", "glm"),
nn_module = sequential_module(),
control = crumble_control(crossfit_folds = 1L, zprime_folds = 5L, epochs = 10L)
)
print(res)
tidy(res)
}