Mediation Analysis
Mediation analysis is a decomposition of causal effects with mediation.
Background
Mediation looks like the following diagram.
where the true causal effects are as follows:
direct effect of X on Y = β1
direct effect of X on M = β2
direct effect of M on Y = β3
indirect effect of X on Y = β2*β3
total effect of X on Y = β1 + (β2*β3)
Description
Sobel Test
The Sobel test is a common approach for identifying and decomposing the mediated effects.
This example uses the multilevel package:
library(multilevel) sorel(data$X, data$M, data$Y)
This displays:
- the component models, including the estimated coefficients and intercepts
- the indirect effect
- the pooled standard error
- the calculated Z statistic
Bootstrapping
A bootstrapping approach is more accurate.
This example also uses the mediation package:
XonY <- lm(Y ~ X, data = data) XonM <- lm(M ~ X, data = data) XMonY <- lm(Y ~ X + M, data = data) library(mediation) mediate(XonM, XMonY, treat='X', mediator='M', boot=TRUE, sims=500)
This displays:
the average causal mediation effects (ACME), the key measure of this bootstrapping method
if significantly different than 0, then there is a significant mediation effect
the average direct effects (ADE)
- the total effect
total effect = ACME + ADE
- the proportion of the total effect that was mediated
prop = ACME / total effect