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.
Interestingly, multimediate
can also accommodate
exposure-mediator interactions because the counterfactual framework
enables so.
variables_y <- paste0("Surv(ridageyr,peryr.age.8yr,cvd.8yr==1) ~ const(wv.gr.2) +
const(log.cr.ucd)+const(log.bpb) + const(wv.gr.2*log.cr.ucd) +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.cr.ucd ~ wv.gr.2 + riagendr.2 + ridageyr + race.2 + race.3 +
race.4 + smoking.2 + smoking.3")
variables2 <- paste0("log.bpb ~ 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 | -79.5085 | -143.4931 | -13.7257 | 0.018 |
PM(treat) | 0.4219 | 0.0531 | 1.2139 | 0.020 |
ACME.joint.control | -86.7132 | -144.5966 | -26.8414 | 0.006 |
PM(control) | 0.4236 | 0.1185 | 0.9782 | 0.008 |
ACME.treat.log.cr.ucd | -20.9532 | -65.4880 | 21.5909 | 0.354 |
PM(treat).log.cr.ucd | 0.1017 | -0.1043 | 0.4388 | 0.354 |
ACME.control.log.cr.ucd | -28.1579 | -48.6183 | -7.5227 | 0.006 |
PM(control).log.cr.ucd | 0.1420 | 0.0311 | 0.4004 | 0.006 |
ACME.treat.log.bpb | -58.5553 | -110.9135 | -6.8066 | 0.024 |
PM(treat).log.bpb | 0.3046 | 0.0206 | 0.7632 | 0.028 |
ACME.control.log.bpb | -58.5553 | -110.9135 | -6.8066 | 0.024 |
PM(control).log.bpb | 0.3046 | 0.0206 | 0.7632 | 0.028 |
ADE.treat | -145.3458 | -291.4826 | -0.3968 | 0.050 |
ADE.control | -152.5505 | -316.6510 | 22.3366 | 0.090 |
Total Effect | -232.0590 | -365.0424 | -85.0617 | 0.002 |
The results suggest that at the cadmium exposure levels observed in NHANES 1999-2004, the association of cadmium with cardiovascular mortality might be weaker compared to the association at cadmium exposure levels observed in 1988-1994. The interaction p-value in the outcome model, however, is suggestive (equal to 0.09).
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.