multimediate packageWe provide a short toy example that allows interested readers to
reproduce the analysis from Ruiz-Hernandez et al.
(2017) using the multimediate package which
implements counterfactual multiple mediation analysis in the setting of
additive survival.
We first download and install the package:
Now, we load the needed packages. We can verify that the package
correctly uploaded by running
packageVersion("multimediate"). Which should return
[1] ‘0.1.4’.
suppressPackageStartupMessages(library(multimediate))
packageVersion("multimediate")
suppressPackageStartupMessages(library(timereg))The toy dataset provided in this vignette is a subset of the study population used in the manuscript by Ruiz-Hernandez et al. (2017). The original dataset included imputation of missing completely at random urine cadmium values and blood lead values below the detection limit (for a deeper understanding of the imputation, see Ruiz-Hernandez et al. (2017). Here we provided the subset of actually measured (i.e. unimputed) urine cadmium values. Also we extended the followup for mortality data collection to 10 years.
Interestingly, multimediate can also accommodate
exposure-mediator interactions because the counterfactual framework
enables so.
variables_y <- paste0("Surv(ridageyr,peryr.age.10yr,cvd.10yr==1) ~ const(wv.gr.2) +
const(log.bpb) + const(log.cr.ucd)+const(wv.gr.2*log.bpb) +const(race.2)+
const(race.3)+ const(race.4)+ const(diab)+ const(bmi_cat)+ const(riagendr.2)+
const(smoking.2)+const(smoking.3)+ const(lbxtc_cat)+const(lowhdl)+const(cholmed)+
const(hbp)+const(sedent)")
model.y = aalen(as.formula(variables_y),start.time=40,
weights=nhanes$wtshm12yr, data = nhanes, robust=T)
# Warning: at the current moment multimediate only takes one exposure-mediator
# interaction at a time (work in progress to accomodate more). Note that the first
# mediator model in the lmodel.m list must be the one with the interaction, and this
# ordering must be consistent with the order mediators have been included in the outcome
# model.
variables1 <- paste0("log.bpb ~ wv.gr.2 + riagendr.2 + ridageyr + race.2 + race.3 +
race.4 + smoking.2 + smoking.3")
variables2 <- paste0("log.cr.ucd ~ wv.gr.2 + riagendr.2 + ridageyr + race.2 + race.3 +
race.4 + smoking.2 + smoking.3")
modM1 = lm(variables1, data = nhanes)
modM2 = lm(variables2, data = nhanes)
lmodel.m=list(modM1, modM2)
multim=multimediate(lmodel.m,correlated=TRUE,model.y,treat="wv.gr.2",treat.value=1,
control.value=0,J=1000,conf.level=0.95,data=nhanes)
sum <- suppressWarnings(summary(multim, option='navg'))Note the option option='navg' for obtaining average
mediation effects in the presence of exposure-mediator interactions.
Now, we obtain different mediation effects estimates for both NHANES
periods.
| . | Estimation | IC.inf | IC.sup | P.val |
|---|---|---|---|---|
| ACME.joint.treat | -58.3744 | -143.3592 | 24.1236 | 0.140 |
| PM(treat) | 0.3390 | -0.0947 | 1.0828 | 0.140 |
| ACME.joint.control | -119.7350 | -170.3306 | -67.5683 | 0.000 |
| PM(control) | 0.6118 | 0.2874 | 1.2170 | 0.000 |
| ACME.treat.log.bpb | -30.1140 | -108.2133 | 47.5489 | 0.476 |
| PM(treat).log.bpb | 0.1542 | -0.2536 | 0.6806 | 0.476 |
| ACME.control.log.bpb | -91.4746 | -141.8467 | -40.3954 | 0.000 |
| PM(control).log.bpb | 0.4674 | 0.1645 | 1.0498 | 0.000 |
| ACME.treat.log.cr.ucd | -28.2603 | -47.8338 | -9.0230 | 0.002 |
| PM(treat).log.cr.ucd | 0.1508 | 0.0399 | 0.3480 | 0.002 |
| ACME.control.log.cr.ucd | -28.2603 | -47.8338 | -9.0230 | 0.002 |
| PM(control).log.cr.ucd | 0.1508 | 0.0399 | 0.3480 | 0.002 |
| ADE.treat | -97.2185 | -217.6141 | 22.8343 | 0.126 |
| ADE.control | -158.5790 | -333.0215 | 7.8943 | 0.072 |
| Total Effect | -216.9534 | -337.8046 | -100.3597 | 0.000 |
The estimated mediation effects are similar as in the model not including the interaction. Indeed, the interaction p-value in the outcome model is far from being statistically significant (equal to 0.96). Thus, our results do not suppor exposure-mediator interaction for cadmium models.
multimediate can do more!Note that multimediate can also accommodate continuous
and binary outcome models, as well as categorical or continuous
exposures/treatments (Jérolon et al.
(2020)). We could also think of modeling a non linear single
mediator, by treating the mediator’s main and spline terms as correlated
mediators. For the moment, multimediate should only be used
for continuous mediators, but we have work in progress to accommodate
categorical mediators and both.