I am wondering if anyone knows of a way to run a multiple mediation model in R. I know the mediation package allows for multiple simple mediation models, but I want to run one model that evaluates multiple mediation models simultaneously.
I am assuming I can do this in an SEM framework (path analysis), but was wondering if anyone new of a package that computed statistics typical of mediation analysis for multiple mediators (indirect effects, Proportion of Total Effect via Mediation, etc.), and could utilize bootstrapping. I know this is a long-shot, but thought I should ask before investing time developing from scratch.
Since asking this question a couple of years ago, I have learned to use the wonderful R package lavaan to do multiple mediation.
here is example code:
model <- ' # outcome model outcomeVar ~ c*xVar + b1*medVar1 + b2*medVar2 # mediator models medVar1 ~ a1*xVar medVar2 ~ a2*xVar # indirect effects (IDE) medVar1IDE := a1*b1 medVar2IDE := a2*b2 sumIDE := (a1*b1) + (a2*b2) # total effect total := c + (a1*b1) + (a2*b2) medVar1 ~~ medVar2 # model correlation between mediators '
Note that a1,a2,b1,b2, and c are labels. Then run the model:
fit <- sem(model, data=dataframe)
And look at output:
summary(fit, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE)
Finally, generate bootstrap confidence intervals:
boot.fit <- parameterEstimates(fit, boot.ci.type="bca.simple")
See the lavaan website for more details: http://lavaan.ugent.be/