Causal Mediation Analysis for Estimating Interventional Effects Mapped to A Target Trial
medRCT.Rd
medRCT
is used to estimate interventional effects that map to a target trial evaluating hypothetical mediator interventions
of interest. It can handle any number of potentially correlated mediators, including mediators that are not of primary
interest but that are intermediate (exposure-induced) mediator-outcome confounders.
Arguments
- dat
A
data.frame
containing the dataset for analysis. It should include variables for the exposure, outcome, mediators, (baseline) confounders, and intermediate (exposure-induced) mediator-outcome confounders specified in the analysis.- exposure
A
character
string specifying the name of the exposure variable in the dataset. The exposure variable must be categorical, with0
explicitly denoting the unexposed (or control) group, which is taken as the reference group. Other values represent different, non-reference exposure categories.- outcome
A
character
string specifying the name of the outcome variable in the dataset. The outcome variable can be binary or continuous.- mediators
A
character
vector specifying the names of the variables in the dataset corresponding to the mediators of interest. The mediators can be binary or continuous. When estimating the effect type"shift_k_order"
, the order of mediators in the vector is important and must correspond to the assumed causal ordering of the mediators.- intermediate_confs
A
character
vector specifying the names of the variables in the dataset corresponding to intermediate confounders. The intermediate confounders can be binary or continuous. IfNULL
, no intermediate confounders are specified.- confounders
A
character
vector listing the names of the variables in the dataset corresponding to the baseline confounders.- interactions_XC
A
character
string specifying the two-way interactions between exposure and baseline confounders to include in the regression models in the estimation procedure. The default value,"all"
, includes all two-way exposure-confounder interactions but excludes confounder-confounder interactions. Specify"none"
to exclude all two-way interactions between exposure and baseline confounders.- intervention_type
A
character
string indicating the type of interventional effect to be estimated. Options include:"all"
(default): Estimates all three types of interventional indirect effects."shift_all"
: Estimates an interventional indirect effect mapped to a target trial assessing the impact of shifting the joint distribution of all mediators in the exposed to match the corresponding distribution in the unexposed."shift_k"
: Estimates an interventional indirect effect mapped to a target trial assessing the impact of shifting the distribution of a specific mediator (k
) in the exposed to match the corresponding distribution in the unexposed."shift_k_order"
: Estimates an interventional indirect effect mapped to a target trial assessing the impact of shifting the distribution of a specific mediator (k
) in the exposed to match the corresponding distribution in the unexposed while accounting for the flow-on effects on causally descendant mediators.
- mcsim
An
integer
specifying the number of Monte Carlo simulations to perform. The default is 200. It is recommended to run analysis with no fewer than 200 Monte Carlo simulations.- bootstrap
A
logical
value indicating whether bootstrapping should be performed. IfTRUE
(default), bootstrapping is conducted using theboot
function from theboot
package.- boot_args
A
list
of arguments for bootstrapping. The default settings are:R
: Number of bootstrap replicates (default: 100).stype
: Specifies the statistic type passed to theboot
function (default:"i"
).ci.type
: Specifies the type of confidence interval to compute (default:"norm"
).
- ...
Additional arguments passed to the
boot
function from theboot
package.
Details
Before conducting the mediation analysis, users are encouraged to assess the models fitted by the algorithm
using the interactive Shiny application, which can be launched by running the function medRCT_shiny
.
The Shiny app provides a user-friendly interface to review model summaries and identify potential warnings and errors,
ensuring that the models are appropriately specified before proceeding with the analysis.
If issues with model fitting are detected, users are encouraged to adjust the exposure-confounder interaction term as needed. However, mediators or confounders must not be selected based on model fitting results.
Examples
if (FALSE) { # \dontrun{
# Define confounders for the analysis
confounders <- c("child_sex", "child_atsi", "mat_cob", "mat_engl", "mat_age")
# Define intermediate confounders
intermediate_confs <- "fam_stress"
# Estimate interventional indirect effects for various
# hypothetical interventions
med_res <- medRCT(
dat = LSACdata,
exposure = "sep",
outcome = "child_mh",
mediators = c("parent_mh", "preschool_att"),
intermediate_confs = intermediate_confs,
confounders = confounders,
interactions_XC = "all",
intervention_type = "all",
bootstrap = TRUE,
boot_args = list(R = 100, stype = "i", ci.type = "norm"),
mcsim = 100
)
# Summarise the results
summary(med_res)
} # }