Skip to main content
Log in

Causal moderated mediation analysis: Methods and software

  • Published:
Behavior Research Methods Aims and scope Submit manuscript

Abstract

Research questions regarding how, for whom, and where a treatment achieves its effect on an outcome have become increasingly valued in substantive research. Such questions can be answered by causal moderated mediation analysis, which assesses the heterogeneity of the mediation mechanism underlying the treatment effect across individual and contextual characteristics. Various moderated mediation analysis methods have been developed under the traditional path analysis/structural equation modeling framework. One challenge is that the definitions of moderated mediation effects depend on statistical models of the mediator and the outcome, and no solutions have been provided when either the mediator or the outcome is binary, or when the mediator or outcome model is nonlinear. In addition, it remains unclear to empirical researchers how to make causal arguments of moderated mediation effects due to a lack of clarifications of the underlying assumptions and methods for assessing the sensitivity to violations of the assumptions. This article overcomes the limitations by developing general definition, identification, estimation, and sensitivity analysis for causal moderated mediation effects under the potential outcomes framework. We also developed a user-friendly R package moderate.mediation (https://cran.r-project.org/web/packages/moderate.mediation/index.html) that allows applied researchers to easily implement the proposed methods and visualize the initial analysis results and sensitivity analysis results. We illustrated the application of the proposed methods and the package implementation with a re-analysis of the National Evaluation of Welfare-to-Work Strategies (NEWWS) Riverside data.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3

Similar content being viewed by others

Notes

  1. If a variable that moderates the mediation mechanism is posttreatment (i.e., affected by the treatment), it is essentially an additional mediator that interacts with the treatment and/or the focal mediator.

  2. \(Y_{t}(t^{\prime}, m)\) stands for the potential outcome if the treatment condition is at t′ and the potential mediator takes the value of m. A proof of why Assumptions 1 and 2 are needed for the identification of the conditional and moderated mediation effects can be found in Appendix A.

  3. For the notations, the subscript indicates the predictor that the coefficient corresponds to, and the superscript indicates the model that the predictor belongs to. This can avoid misreading especially when there are a lot of predictors and/or moderators in the model. Here \({\beta}_0^m\), \({\beta}_t^m\), \({\boldsymbol{\beta}}_x^m\), \({\beta}_0^y\), \({\beta}_t^y\), \({\beta}_m^y\), \({\beta}_{tm}^y\), and \({\boldsymbol{\beta}}_x^y\) respectively correspond to β0, β1, β2, θ0, θ1, θ2, θ3, and θ4 in VanderWeele (2015) and α2, β2, ξ2, α3, β3, γ, κ, and ξ3 in Imai et al. (2010a).

  4. This is because the sampling distribution of the regression coefficient estimates is asymptotically multivariate normal (King et al., 2000).

  5. We compute the final point estimates based on the mean rather than the median of the Q sets of point estimates as Imai et al. (2010a) did. This is because we found through simulations that the mean estimators are mostly less biased than the median estimators across different scenarios, especially when the sample size is relatively small. Simulations were conducted under the settings described in Appendix C. Simulation results are available upon request.

  6. We compute the final point estimates based on the mean rather than the median of the post-burn-in samples. This is because, similar to what Wang and Preacher (2015) reported, we found through simulations that the mean estimators are mostly less biased than the median estimators across different scenarios, especially when the sample size is relatively small. Simulations were conducted under the settings described in Appendix C. Simulation results are available upon request.

  7. Because U is generated from the frequentist perspective, this sensitivity analysis algorithm applies to the bootstrapping method and Monte Carlo method but does not directly apply to the Bayesian method. To implement the sensitivity analysis with the Bayesian method, U should be generated from the Bayesian perspective in Step 2.1.

  8. To obtain mediation effect estimates that are comparable across studies, some researchers reported mediation effect estimates in the standard deviation of the outcome in the control group (Kraft, 2020), or the standard deviation of the outcome  in the whole sample (e.g., Hong et al., ), while some fully standardized the mediation effects by standardizing all the variables (e.g., Preacher & Hayes, 2008). If a researcher would like to report such effect size measures in the following graphical summary and sensitivity analysis, they may run the analysis based on the data with the corresponding variables standardized in the desired way. We chose to report the estimates in the standard deviation of the outcome in the control group to eliminate the influence of the treatment on the standard deviation of the outcome. As Kraft (2020) argued on page 245, “it is preferable to use the standard deviation of the control group outcome rather than the pooled sample because the intervention may have affected the variation in outcomes among the treatment group”.

  9. It is inappropriate to simply plot \(\hat{\delta}_i\) predicted from Step 2.4 based on one replication against the moderator, because it ignores the uncertainty of \(\hat{\delta}_i\) when constructing the confidence band. The cost of the proposed approach is that it is more time-consuming. To speed up the calculation, the package allows parallel computing by setting the number of CPU cores via ncore. Its default value is 2. A progress bar is displayed as the program runs. An application of the above syntax to the NEWWS data took 2.5 minutes. In the cases when Step 2.5 does not involve a spline regression, it usually takes around 30 seconds with only one core.

  10. The default range is symmetric, and the upper limit of range.b.m (range.b.y) is twice the magnitude of the largest coefficient of the observed covariates in the standardized mediator (outcome) model.

  11. The sensitivity analysis plot looks similar to the L.O.V.E. method (Mauro, 1990; Cox et al., 2013), while we allow more scenarios (e.g., inclusion of the treatment-by-mediator interaction) for assessing sensitivity of conditional and moderated causal mediation effects.

References

  • Baron, R. M., & Kenny, D. A. (1986). The moderator–mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. Journal of Personality and Social Psychology, 51(6), 1173.

    PubMed  Google Scholar 

  • Bauer, D. J., Preacher, K. J., & Gil, K. M. (2006). Conceptualizing and testing random indirect effects and moderated mediation in multilevel models: New procedures and recommendations. Psychological Methods, 11, 142.

    PubMed  Google Scholar 

  • Carvalho, C., Feller, A., Murray, J., Woody, S., & Yeager, D. (2019). Assessing treatment effect variation in observational studies: Results from a data challenge. Observational Studies, 5(2), 21–35.

    Google Scholar 

  • Cohen, J. (1983). The cost of dichotomization. Applied Psychological Measurement, 7, 249–253.

    Google Scholar 

  • Cox, M. G., Kisbu-Sakarya, Y., Miočević, M., & MacKinnon, D. P. (2013). Sensitivity plots for confounder bias in the single mediator model. Evaluation Review, 37(5), 405–431.

    PubMed  Google Scholar 

  • Daniel, R. M., De Stavola, B. L., Cousens, S. N., & Vansteelandt, S. (2015). Causal mediation analysis with multiple mediators. Biometrics, 71(1), 1–14.

    PubMed  Google Scholar 

  • Edwards, J. R., & Lambert, L. S. (2007). Methods for integrating moderation and mediation: a general analytical framework using moderated path analysis. Psychological Methods, 12(1), 1.

    PubMed  Google Scholar 

  • Fairchild, A. J., & MacKinnon, D. P. (2009). A general model for testing mediation and moderation effects. Prevention Science, 10(2), 87–99.

    PubMed  PubMed Central  Google Scholar 

  • Friedman, J. H. (1991). Multivariate adaptive regression splines. The Annals of Statistics, 19(1), 1–67.

    Google Scholar 

  • Gelman, A., & Rubin, D. B. (1992). Inference from iterative simulation using multiple sequences. Statistical Science, 7, 457–472.

    Google Scholar 

  • Geweke, J. (1992). Evaluating the accuracy of sampling–based approaches to the calculation of posterior moments. In J. O. B. J. M. Bernado, A. P. Dawid, & A. F. M. Smith (Eds.), Bayesian statistics 4 (pp. 169–193). Clarendon.

    Google Scholar 

  • Grace, J. B., Johnson, D. J., Lefcheck, J. S., & Byrnes, J. E. (2018). Quantifying relative importance: computing standardized effects in models with binary outcomes. Ecosphere, 9(6), e02283.

    Google Scholar 

  • Hamilton, G., & Freedman, S. (2001). How effective are different welfare-to-work approaches? Five-year adult and child impacts for eleven programs. National Evaluation of Welfare-to-Work Strategies.

  • Hayes, A. F. (2015). An index and test of linear moderated mediation. Multivariate Behavioral Research, 50(1), 1–22.

    PubMed  Google Scholar 

  • Hayes, A. F. (2017). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach. Guilford Publications.

    Google Scholar 

  • Hong, G. (2010). Ratio of mediator probability weighting for estimating natural direct and indirect effects. Proceedings of the American Statistical Association, Biometrics Section (pp. 2401–2415). merican Statistical Association.

  • Hong, G. (2015). Causality in a social world: Moderation, mediation and spill-over. John Wiley.

    Google Scholar 

  • Hong, G., Deutsch, J., & Hill, H. D. (2015). Ratio-of-mediator-probability weighting for causal mediation analysis in the presence of treatment-by-mediator interaction. Journal of Educational and Behavioral Statistics, 40, 307–340.

    Google Scholar 

  • Hong, G., Qin, X., & Yang, F. (2018). Weighting-based sensitivity analysis in causal mediation studies. Journal of Educational and Behavioral Statistics, 43(1), 32–56.

    Google Scholar 

  • Hong, G., Yang, F., & Qin, X. (2023). Post-treatment confounding in causal mediation studies: A cutting-edge problem and a novel solution via sensitivity analysis. Biometrics , 79(2), 1042-1056.

  • Imai, K., Keele, L., & Tingley, D. (2010a). A general approach to causal mediation analysis. Psychological Methods, 15, 309.

    PubMed  Google Scholar 

  • Imai, K., Keele, L., & Yamamoto, T. (2010b). Identification, inference and sensitivity analysis for causal mediation effects. Statistical Science, 25, 51–71.

    Google Scholar 

  • James, L. R., & Brett, J. M. (1984). Mediators, moderators, and tests for mediation. Journal of Applied Psychology, 69(2), 307.

    Google Scholar 

  • King, G., Tomz, M., & Wittenberg, J. (2000). Making the most of statistical analyses: Improving interpretation and presentation. American Journal of Political Science, 44(2), 347–361.

    Google Scholar 

  • Loeys, T., Talloen, W., Goubert, L., Moerkerke, B., & Vansteelandt, S. (2016). Assessing moderated mediation in linear models requires fewer confounding assumptions than assessing mediation. British Journal of Mathematical and Statistical Psychology, 69(3), 352–374.

    PubMed  Google Scholar 

  • MacCallum, R. C., Zhang, S., Preacher, K. J., & Rucker, D. D. (2002). On the practice of dichotomization of quantitative variables. Psychological Methods, 7, 19–40.

    PubMed  Google Scholar 

  • MacKinnon, D. P. (2008). Introduction to statistical mediation analysis. Erlbaum.

    Google Scholar 

  • MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39(1), 99–128.

    PubMed  PubMed Central  Google Scholar 

  • Mauro, R. (1990). Understanding LOVE (left out variables error): A method for estimating the effects of omitted variables. Psychological Bulletin, 108(2), 314.

    Google Scholar 

  • Maxwell, S. E., & Delaney, H. D. (1993). Bivariate median splits and spurious statistical significance. Psychological Bulletin, 113, 181–190.

    Google Scholar 

  • McKelvey, R. D., & Zavoina, W. (1975). A statistical model for the analysis of ordinal level dependent variables. Journal of Mathematical Sociology, 4(1), 103–120.

    Google Scholar 

  • Michalopoulos, C., Schwartz, C., & Adams-Ciardullo, D. (2001). National evaluation of welfare-to-work strategies. What Works Best for Whom: Impacts of, 20.

  • Miočević, M., Gonzalez, O., Valente, M. J., & MacKinnon, D. P. (2018). A tutorial in Bayesian potential outcomes mediation analysis. Structural Equation Modeling: A Multidisciplinary Journal, 25(1), 121–136.

    PubMed  Google Scholar 

  • Morgan-Lopez, A. A., & MacKinnon, D. P. (2006). Demonstration and evaluation of a method for assessing mediated moderation. Behavior Research Methods, 38(1), 77–87.

    PubMed  Google Scholar 

  • Morris, P. A. (2008). Welfare program implementation and parents’ depression. Social Service Review, 82(4), 579–614.

    PubMed  Google Scholar 

  • Muller, D., Judd, C. M., & Yzerbyt, V. Y. (2005). When moderation is mediated and mediation is moderated. Journal of Personality and Social Psychology, 89(6), 852.

    PubMed  Google Scholar 

  • Muthén, B. O., Muthén, L. K., & Asparouhov, T. (2017). Regression and mediation analysis using Mplus. Muthén & Muthén.

    Google Scholar 

  • Neyman, J., & Iwaszkiewicz, K. (1935). Statistical problems in agricultural experimentation. Supplement to the Journal of the Royal Statistical Society, 2, 107–180.

    Google Scholar 

  • Pearl, J. (2001). Direct and indirect effects. In J. Breese & D. Koller (Eds.), Proceedings of the seventeenth conference on uncertainty in artificial intelligence (pp. 411–420). Morgan Kaufmann.

    Google Scholar 

  • Plummer, M., Best, N., Cowles, K., & Vines, K. (2006). CODA: convergence diagnosis and output analysis for MCMC. R news, 6(1), 7–11.

    Google Scholar 

  • Preacher, K. J., & Hayes, A. F. (2004). SPSS and SAS procedures for estimating indirect effects in simple mediation models. Behavior Research Methods, Instruments, & Computers, 36(4), 717–731.

    Google Scholar 

  • Preacher, K. J., & Hayes, A. F. (2008). Contemporary approaches to assessing mediation in communication research. In A. F. Hayes, M. D. Slater, & L. B. Snyder (Eds.), The Sage sourcebook of advanced data analysis methods for communication research (pp. 13–54). Sage.

    Google Scholar 

  • Preacher, K. J., Rucker, D. D., & Hayes, A. F. (2007). Addressing moderated mediation hypotheses: Theory, methods, and prescriptions. Multivariate Behavioral Research, 42(1), 185–227.

    PubMed  Google Scholar 

  • Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98.

    Google Scholar 

  • Qin, X. (2023). Sample Size and Power Calculations for Causal Mediation Analysis. Behavior Research Methods: In press.

    Google Scholar 

  • Qin, X., & Yang, F. (2022). Simulation-based sensitivity analysis for causal mediation studies. Psychological Methods. Advance online publication.

  • Robins, J. M., & Greenland, S. (1992). Identifiability and exchangeability for direct and indirect effects. Epidemiology, 3, 143–155.

    PubMed  Google Scholar 

  • Rubin, D. B. (1978). Bayesian inference for causal effects: The role of randomization. The Annals of Statistics, 6, 34–58.

    Google Scholar 

  • Rubin, D. B. (1980). Randomization analysis of experimental data: The fisher randomization test comment. Journal of the American Statistical Association, 75, 591–593.

    Google Scholar 

  • Rubin, D. B. (1986). Statistics and causal inference: Comment: Which ifs have causal answers. Journal of the American Statistical Association, 81, 961–962.

    Google Scholar 

  • Rubin, D. B. (1990). Formal mode of statistical inference for causal effects. Journal of Statistical Planning and Inference, 25, 279–292.

    Google Scholar 

  • Schomaker, M., & Heumann, C. (2018). Bootstrap inference when using multiple imputation. Statistics in Medicine, 37(14), 2252–2266.

    PubMed  PubMed Central  Google Scholar 

  • Steen, J., Loeys, T., Moerkerke, B., & Vansteelandt, S. (2017). medflex: An R Package for flexible mediation analysis using natural effect models. Journal of Statistical Software, 76, 1–46.

    Google Scholar 

  • Ten Have, T. R., Elliott, M. R., Joffe, M., Zanutto, E., & Datto, C. (2004). Causal models for randomized physician encouragement trials in treating primary care depression. Journal of the American Statistical Association, 99(465), 16–25.

    Google Scholar 

  • Tingley, D., Yamamoto, T., Hirose, K., Keele, L., & Imai, K. (2014). Mediation: R package for causal mediation analysis. Journal of Statistical Software, 59(5).

  • Valeri, L., & VanderWeele, T. J. (2013). Mediation analysis allowing for exposure– mediator interactions and causal interpretation: Theoretical assumptions and implementation with SAS and SPSS macros. Psychological Methods, 18(2), 137.

    PubMed  PubMed Central  Google Scholar 

  • VanderWeele, T. (2015). Explanation in causal inference: methods for mediation and interaction. Oxford University Press.

    Google Scholar 

  • VanderWeele, T. J., & Vansteelandt, S. (2009). Conceptual issues concerning mediation, interventions and composition. Statistics and Its Interface, 2, 457–468.

    Google Scholar 

  • VanderWeele, T. J., & Vansteelandt, S. (2010). Odds ratios for mediation analysis for a dichotomous outcome. American Journal of Epidemiology, 172, 1339–1348.

    PubMed  PubMed Central  Google Scholar 

  • Vansteelandt, S., Bekaert, M., & Lange, T. (2012). Imputation strategies for the estimation of natural direct and indirect effects. Epidemiologic Methods, 1(1), 131–158.

    Google Scholar 

  • Wang, L., & Preacher, K. J. (2015). Moderated mediation analysis using Bayesian methods. Structural Equation Modeling: A Multidisciplinary Journal, 22(2), 249–263.

    Google Scholar 

  • Yuan, Y., & MacKinnon, D. P. (2009). Bayesian mediation analysis. Psychological Methods, 14(4), 301.

    PubMed  PubMed Central  Google Scholar 

Download references

Acknowledgements

This study received support from Pitt Momentum Funds, a U.S. Department of Education Institute of Education Sciences Grant (R305D200031) an National Institutes of Health Grant (R01AG080590), and the 2022 National Academy of Education (NAEd)/Spencer Postdoctoral Fellowship Program. Lijuan Wang is grateful for the support from IES grant R305D210023 during the study. The authors thank Guanglei Hong and Fan Yang for their insightful comments on previous versions of the manuscript. In addition, comments from the Associate Editor and the reviewers have led to major improvements in this article.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Xu Qin.

Additional information

Open practices statement

The data and R package are available on CRAN: https://cran.r-project.org/web/packages/moderate.mediation/index.html. The data were not preregistered.

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary Information

ESM 1

(DOCX 1.88 mb)

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Qin, X., Wang, L. Causal moderated mediation analysis: Methods and software. Behav Res 56, 1314–1334 (2024). https://doi.org/10.3758/s13428-023-02095-4

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.3758/s13428-023-02095-4

Keywords

Navigation