| Title: | Causal Mediation Analysis in Presence of Multiple Mediators Uncausally Related |
|---|---|
| Description: | Estimates key quantities in causal mediation analysis - including average causal mediation effects (indirect effects), average direct effects, total effects, and proportions mediated - in the presence of multiple uncausally related mediators. Methods are described by Jerolon et al., (2021) <doi:10.1515/ijb-2019-0088> and extended to accommodate survival outcomes as described by Domingo-Relloso et al., (2024) <doi:10.1101/2024.02.16.24302923>. |
| Authors: | Allan Jerolon [aut], Arce Domingo-Relloso [aut], Samara Kiihl [cre, aut], Maria Tellez-Plaza [aut] |
| Maintainer: | Samara Kiihl <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.6 |
| Built: | 2026-05-22 17:19:59 UTC |
| Source: | https://github.com/samarafk/multimediate |
A toy dataset for causal mediation analysis with 3 uncausally related mediators.
data("data1")data("data1")
A data frame with 1000 observations on the following 8 variables.
Treatmenta factor with levels 0 1
C1a factor with levels 0 1
C2a factor with levels 0 1
C3a factor with levels 0 1
M1a numeric vector
M2a numeric vector
M3a numeric vector
Outcomea numeric vector
A toy dataset for causal mediation analysis with 3 uncausally related mediators.
data("data2")data("data2")
A data frame with 1000 observations on the following 8 variables.
Treatmenta factor with levels 0 1
C1a factor with levels 0 1
C2a factor with levels 0 1
C3a factor with levels 0 1
M1a numeric vector
M2a numeric vector
M3a numeric vector
Outcomea factor with levels FALSE TRUE
A toy dataset for causal mediation analysis with 3 uncausally related mediators.
data("data3")data("data3")
A data frame with 1000 observations on the following 8 variables.
Treatmenta factor with levels 0 1
C1a factor with levels 0 1
C2a factor with levels 0 1
C3a factor with levels 0 1
M1a numeric vector
M2a numeric vector
M3a numeric vector
Outcomea factor with levels 0 1 2 3
A toy dataset for causal mediation analysis with 3 uncausally related mediators.
data("data4")data("data4")
A data frame with 1000 observations on the following 8 variables.
Treatmenta numeric vector
C1a factor with levels 0 1
C2a factor with levels 0 1
C3a factor with levels 0 1
M1a numeric vector
M2a factor with levels 0 1
M3a factor with levels 0 1 2 3
Outcomea numeric vector
A toy dataset for causal mediation analysis with 3 uncausally related mediators and survival outcome.
data("data5")data("data5")
A data frame with 3000 observations on the following 8 variables.
Exposurea numeric vector
M1a numeric vector
M2a numeric vector
M3a numeric vector
eventevent
surv_timetime before event
multimediate estimates several quantities in causal mediation analysis, including the average causal mediation effect (indirect effect), average direct effect, proportion mediated, and total effect, in the presence of multiple uncausally related mediators.
multimediate( lmodel.m, correlated = FALSE, model.y, treat, treat.value = 1, control.value = 0, J = 1000, conf.level = 0.95, fun = mean, data = NULL, peryr = 1e+05, verbose = TRUE )multimediate( lmodel.m, correlated = FALSE, model.y, treat, treat.value = 1, control.value = 0, J = 1000, conf.level = 0.95, fun = mean, data = NULL, peryr = 1e+05, verbose = TRUE )
lmodel.m |
list of fitted models object for mediators. Can be of class |
correlated |
a logical value. if |
model.y |
a fitted model object for the outcome. Can be of class |
treat |
a character string indicating the name of the treatment variable used in the models. The treatment can be either binary (integer or a two-valued factor) or continuous (numeric). |
treat.value |
value of the treatment variable used as the treatment condition. Default is 1. |
control.value |
value of the treatment variable used as the control condition. Default is 0. |
J |
number of Monte Carlo draws for quasi-Bayesian approximation. |
conf.level |
level of the returned two-sided confidence intervals. Default is to return the 2.5 and 97.5 percentiles of the simulated quantities. |
fun |
the function used to compute the point estimate of the effects of interest from its empirical distribution. The function |
data |
dataset with all variables used in the mediator and outcome models |
peryr |
the number of person-years to multiply the additive estimator to obtain results in scale of cases per person-years (only applicable to the survival outcome) |
verbose |
Logical. If |
For binary outcomes, it also estimates average causal mediation effects on the odds ratio (OR) and log-odds (logOR) scales.
For survival outcomes, multimediate additionally estimates average causal mediation effects on cases per person-year scale.
multimediate returns an object of class mm, a list that contains at least the components listed below.
The function summary (i.e., summary.mm) can be used to obtain a table of the results.
model.y: the fitted outcome model.
model.m: a list of fitted mediator models, one for each mediator.
treatment: a character string indicating the name of the treatment variable used in the models.
treat.value: value of the treatment variable used as the treatment condition.
control.value: value of the treatment variable used as the control condition.
sims: the number of Monte Carlo draws for quasi-Bayesian approximation.
# Load example data data(data1) summary(data1) # Fit mediator models M1reg <- lm(M1 ~ Treatment + C1 + C2, data = data1) M2reg <- lm(M2 ~ Treatment + C1 + C3, data = data1) M3reg <- lm(M3 ~ Treatment + C1, data = data1) # Fit outcome model Yreg <- lm(Outcome ~ Treatment + M1 + M2 + M3 + C1 + C2 + C3, data = data1) # Perform multiple mediation analysis (may take some time) med.analysis <- multimediate( lmodel.m = list(M1reg, M2reg, M3reg), correlated = TRUE, model.y = Yreg, treat = "Treatment", treat.value = 1, control.value = 0, J = 100, conf.level = 0.95, verbose = FALSE ) summary(med.analysis, opt = "avg")# Load example data data(data1) summary(data1) # Fit mediator models M1reg <- lm(M1 ~ Treatment + C1 + C2, data = data1) M2reg <- lm(M2 ~ Treatment + C1 + C3, data = data1) M3reg <- lm(M3 ~ Treatment + C1, data = data1) # Fit outcome model Yreg <- lm(Outcome ~ Treatment + M1 + M2 + M3 + C1 + C2 + C3, data = data1) # Perform multiple mediation analysis (may take some time) med.analysis <- multimediate( lmodel.m = list(M1reg, M2reg, M3reg), correlated = TRUE, model.y = Yreg, treat = "Treatment", treat.value = 1, control.value = 0, J = 100, conf.level = 0.95, verbose = FALSE ) summary(med.analysis, opt = "avg")
summary.mm is used to display the results of the mediation analyzes done with multimediate.
## S3 method for class 'mm' summary(object, opt = "navg", logit = "all", ...)## S3 method for class 'mm' summary(object, opt = "navg", logit = "all", ...)
object |
element of the class |
opt |
a character string indicating the details of the analysis "navg" for the average causal effects for t=0,1 and "avg" for the average causal effects. |
logit |
a character string indicating, when the outcome is binary, the scale of the average causal effects. "effects" for average causal effects, " OR" average causal effects on OR scale, "logOR" average causal effects on logOR scale and "all" for all scale. |
... |
additional arguments affecting the summary produced |
table summarizing the causal analysis