[Mediation-information] moderated mediation

Teppei Yamamoto teppei at MIT.EDU
Thu Oct 11 16:26:41 CEST 2012


Hello list,

Patrick Forscher sent us the following question about "moderated
mediation" in our package:

===
One thing that's still a little ambiguous to me from examining section
3.2 of the vignette is how we would obtain a direct test of the
interaction between the mediation effect and the covariate of interest.
 For example, in 3.2 of the vignette, it looks like you observe how the
mediation effect of the treatment on the probability of sending a letter
to congress (through anxiety) might change depending on the age of the
participant.  It looks like you essentially obtain point estimates of
the mediation effect at age 20 and 60.  However, I'm having trouble
figuring out how you would obtain a direct estimate of the magnitude of
the change in the mediation relationship per extra year of age and a
test of this relationship against 0.  One could, theoretically,
calculate the magnitude of the coefficient for the mediation effect *
age interaction by, for example, setting the age covariate to 20 in the
first model and 21 in the second.  However, manually calculating the
appropriate standard error for this coefficient would be much harder.
===

We don't have a built-in option or command to directly compute the
difference in two conditional average causal mediation effects along its
uncertainty estimate, but it's fairly simple to do. Below is a little
example code snippet and its output; it's a modified version of what we
have as part of example(mediate).

> library(mediation)
Loading required package: MASS
Loading required package: Matrix
Loading required package: lattice
Loading required package: lpSolve
mediation: R Package for Causal Mediation Analysis
Version: 4.1.2

> data(jobs)
>
> b.int <- lm(job_seek ~ treat*age + econ_hard + sex, data=jobs)
> d.int <- lm(depress2 ~ treat*job_seek*age + econ_hard + sex, data=jobs)
>
> set.seed(1)
> contcont.age20 <- mediate(b.int, d.int, sims=1000, treat="treat",
mediator="job_seek", covariates = list(age = 20), long = T)
>
> set.seed(1)
> contcont.age70 <- mediate(b.int, d.int, sims=1000, treat="treat",
mediator="job_seek", covariates = list(age = 70), long = T)
> d1.diff <- contcont.age70$d1.sims - contcont.age20$d1.sims
> d0.diff <- contcont.age70$d0.sims - contcont.age20$d0.sims
>
> # Point estimate for the difference
> (contcont.age70$d1 - contcont.age20$d1)
[1] 0.03794978
> (contcont.age70$d0 - contcont.age20$d0)
[1] 0.05439293
>
> quantile(d1.diff, c(0.025, 0.975))
       2.5%       97.5%
-0.07538785  0.15124192
> quantile(d0.diff, c(0.025, 0.975))
      2.5%      97.5%
-0.1073592  0.2160822
====

The key trick is to set the randomness seed to the same value before
each of the mediate run.

Teppei

-- 
====================================
Teppei Yamamoto
Assistant Professor
Department of Political Science
Massachusetts Institute of Technology
http://web.mit.edu/teppei/www/
====================================


More information about the Mediation-information mailing list