Skip to main content
Log in

Sample size and power calculations for causal mediation analysis: A Tutorial and Shiny App

  • Published:
Behavior Research Methods Aims and scope Submit manuscript

A Correction to this article was published on 22 March 2024

This article has been updated

Abstract

When designing a study for causal mediation analysis, it is crucial to conduct a power analysis to determine the sample size required to detect the causal mediation effects with sufficient power. However, the development of power analysis methods for causal mediation analysis has lagged far behind. To fill the knowledge gap, I proposed a simulation-based method and an easy-to-use web application (https://xuqin.shinyapps.io/CausalMediationPowerAnalysis/) for power and sample size calculations for regression-based causal mediation analysis. By repeatedly drawing samples of a specific size from a population predefined with hypothesized models and parameter values, the method calculates the power to detect a causal mediation effect based on the proportion of the replications with a significant test result. The Monte Carlo confidence interval method is used for testing so that the sampling distributions of causal effect estimates are allowed to be asymmetric, and the power analysis runs faster than if the bootstrapping method is adopted. This also guarantees that the proposed power analysis tool is compatible with the widely used R package for causal mediation analysis, mediation, which is built upon the same estimation and inference method. In addition, users can determine the sample size required for achieving sufficient power based on power values calculated from a range of sample sizes. The method is applicable to a randomized or nonrandomized treatment, a mediator, and an outcome that can be either binary or continuous. I also provided sample size suggestions under various scenarios and a detailed guideline of app implementation to facilitate study designs.

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

Similar content being viewed by others

Change history

Notes

  1. The total indirect effect here is different from that known as the sum of multiple indirect effects in a mediation analysis with multiple mediators.

  2. These values are specified based on the theoretical relationship of the skewness and kurtosis that kurtosis ≥ skewness2 − 2 (Qu et al., 2020).

  3. By standardization, we mean the variable is standardized to have a mean of 0 and a standard deviation of 1 throughout the paper.

  4. To gain empirical knowledge about such a proportion from a pilot study or a reanalysis of data from previous studies, we can regress T on X and divide the variance explained by X by the variance of T. If T is binary, we can calculate the variance of T after predicting Tfrom a probit regression of T on X. The same idea applies to the proportions of the variances in the mediator and outcome explained by X. Note that power is calculated based on the assumption that X includes all the potential pretreatment confounders. Otherwise, the indirect and direct effect estimates would be biased. Therefore, the specification of \({R}_x^2\)’s should account for the variances explained by all the potential pretreatment confounders. If some pretreatment confounders are missing from the empirical data, the empirically calculated \({R}_x^2\)’s need to be incremented based on theoretical reasoning.

  5. I have verified through simulations that power depends on the number of covariates and \({R}_x^2\) contributed by the set of covariates as a whole, but is not affected by how much \({R}_x^2\) each specific covariate contributes and how the multiple covariates are correlated.

  6. The R package was developed based on Vale and Maurelli (1983), which extended Fleishman (1978) from generating data from a univariate nonnormal distribution to generating data from a multivariate nonnormal distribution. In order to use the package to generate a single nonnormal variable, we can simply generate two independent variables with the same mean, standard deviation, skewness, and kurtosis, and use either one of them.

  7. If I fix the number of covariates at 1 and rerun the simulations under each scenario, the relative change rate of the calculated sample size is less than 5%, which is due to the uncertainty of simulations. Therefore, a change rate of 22% when the number of covariates is increased from 1 to 10, which is much larger than 5%, indicates a nontrivial influence of the number of covariates.

  8. As explicated in step 1 in the section introducing the simulation-based approach, a standardized model standardizes each of the dependent variable and the independent variables to have a mean of 0 and a variance of 1. If the dependent variable is binary, its latent index is standardized instead (Grace et al., 2018). Hence, the intercepts of the standardized models, \({\beta}_0^m\) and \({\beta}_0^y\), are always 0.

References

  • Aldrich, J. H., & Nelson, F. D. (1984). Linear probability, logit, and probit models (Vol. No. 45). Sage.

  • 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.

    Article  PubMed  Google Scholar 

  • Bloom, H. S. (2008). The core analytics of randomized experiments for social research. The SAGE handbook of social research methods, 115–133.

  • Cohen, J. (1988). Statistical power analysis for the behavioral sciences. Lawrence Erlbaum Associates.

    Google Scholar 

  • Cohen, J. (1990). Things I have learned (so far). American Psychologist, 45, 1304–1312.

    Article  Google Scholar 

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

    Article  PubMed  Google Scholar 

  • Fleishman, A. I. (1978). A method for simulating non-normal distributions. Psychometrika, 43(4), 521–532.

    Article  Google Scholar 

  • Fossum, J., & Montoya, A. (2023). When to use different tests for power analysis and data analysis for between-subjects mediation. Under review.

    Google Scholar 

  • Fritz, M. S., & MacKinnon, D. P. (2007). Required sample size to detect the mediated effect. Psychological Science, 18(3), 233–239.

    Article  PubMed  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.

    Article  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.

    Article  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. In press.

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

    Article  PubMed  Google Scholar 

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

  • Kelcey, B., Dong, N., Spybrook, J., & Cox, K. (2017a). Statistical power for causally defined indirect effects in group-randomized trials with individual-level mediators. Journal of Educational and Behavioral Statistics, 42(5), 499–530.

    Article  Google Scholar 

  • Kelcey, B., Dong, N., Spybrook, J., & Shen, Z. (2017b). Experimental power for indirect effects in group-randomized studies with group-level mediators. Multivariate Behavioral Research, 52(6), 699–719.

    Article  PubMed  Google Scholar 

  • Kelley, K., & Maxwell, S. E. (2003). Sample size for multiple regression: Obtaining regression coefficients that are accurate, not simply significant. Psychological Methods, 8(3), 305.

    Article  PubMed  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.

    Article  Google Scholar 

  • Liu, X., & Wang, L. (2019). Sample size planning for detecting mediation effects: A power analysis procedure considering uncertainty in effect size estimates. Multivariate Behavioral Research, 54(6), 822–839.

    Article  PubMed  Google Scholar 

  • Liu, S., & Yamamoto, T. (2020). How much should you trust your power calculation results? Power Analysis as an Estimation Problem.

  • 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.

    Article  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.

    Article  Google Scholar 

  • Montoya, A. K. (2022). Selecting a within- or between-subject Design for Mediation: Validity, causality, and statistical power. Multivariate Behavior Research.

  • Muthén, L. K., & Muthén, B. O. (2002). How to use a Monte Carlo study to decide on sample size and determine power. Structural Equation Modeling, 9(4), 599–620.

    Article  Google Scholar 

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

    Article  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 

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

    Article  Google Scholar 

  • Qin, X., Deutsch, J., & Hong, G. (2021a). Unpacking complex mediation mechanisms and their heterogeneity between sites in a job corps evaluation. The Journal of Policy Analysis and Management, 40(1), 158–190.

    Article  Google Scholar 

  • Qin, X., & Hong, G. (2017). A weighting method for assessing between-site heterogeneity in causal mediation mechanism. Journal of Educational and Behavioral Statistics, 42(3), 308–340.

    Article  Google Scholar 

  • Qin, X., Hong, G., Deutsch, J., & Bein, E. (2019). Multisite causal mediation analysis in the presence of complex sample and survey designs and non-random nonresponse. The Journal of the Royal Statistical Society Series A (Statistics in Society), 182(4), 1343–1370.

    Article  Google Scholar 

  • Qin, X., Wormington, S., Guzman-Alvarez, A., & Wang, M.-T. (2021b). Why does a growth mindset intervention impact achievement differently across secondary schools? Unpacking the mediation mechanism from a national multisite randomized experiment. The Journal of Research on Educational Effectiveness, 14(3), 617–644.

    Article  PubMed  Google Scholar 

  • Qin, X., & Wang, L. (2023). Causal moderated mediation analysis: Methods and software. Behavior Research Methods: In press.

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

  • Qu, W. & Zhang, Z. (2020). Mnonr: A generator of multivariate non-Normal random numbers. R package version 1.0.0. https://CRAN.R-project.org/package=mnonr.

  • Qu, W., Liu, H., & Zhang, Z. (2020). A method of generating multivariate non-normal random numbers with desired multivariate skewness and kurtosis. Behavior Research Methods, 52, 939–946.

  • Raudenbush, S. W. (1997). Statistical analysis and optimal design for cluster randomized trials. Psychological Methods, 2(2), 173.

    Article  Google Scholar 

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

    Article  PubMed  Google Scholar 

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

    Article  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.

    Article  Google Scholar 

  • Rudolph, K. E., Goin, D. E., & Stuart, E. A. (2020). Rudolph et al. Respond to “power in mediation analysis”. American Journal of Epidemiology, 189(12), 1571-1572.

  • Schoemann, A. M., Boulton, A. J., & Short, S. D. (2017). Determining power and sample size for simple and complex mediation models. Social Psychological and Personality Science, 8(4), 379–386.

    Article  Google Scholar 

  • Schönbrodt, F. D., & Wagenmakers, E. J. (2018). Bayes factor design analysis: Planning for compelling evidence. Psychonomic Bulletin & Review, 25(1), 128–142.

    Article  Google Scholar 

  • Tchetgen Tchetgen, E. J., & Shpitser, I. (2012). Semiparametric theory for causal mediation analysis: Efficiency bounds, multiple robustness, and sensitivity analysis. Annals of Statistics, 40, 1816.

    Article  Google Scholar 

  • Thoemmes, F., MacKinnon, D. P., & Reiser, M. R. (2010). Power analysis for complex mediational designs using Monte Carlo methods. Structural Equation Modeling, 17(3), 510–534.

    Article  PubMed  PubMed Central  Google Scholar 

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

    Google Scholar 

  • Vale, C. D., & Maurelli, V. A. (1983). Simulating multivariate nonnormal distributions. Psychometrika, 48(3), 465–471.

    Article  Google Scholar 

  • VanderWeele, T. J. (2020). Invited commentary: Frontiers of power assessment in mediation analysis. American Journal of Epidemiology, 189(12), 1568–1570.

    Article  PubMed  PubMed Central  Google Scholar 

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

    Article  Google Scholar 

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

    Article  PubMed  PubMed Central  Google Scholar 

  • VanderWeele, T. J., Vansteelandt, S., & Robins, J. M. (2014). Effect decomposition in the presence of an exposure-induced mediator-outcome confounder. Epidemiology, 25(2), 300–306.

    Article  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.

    Article  Google Scholar 

  • Vittinghoff, E., Sen, Ś., & McCulloch, C. E. (2009). Sample size calculations for evaluating mediation. Statistics in Medicine, 28(4), 541–557.

    Article  PubMed  Google Scholar 

  • Vo, T., Superchi, C., Boutron, I., & Vansteelandt, S. (2020). The conduct and reporting of mediation analysis in recently published randomized controlled trials: Results from a methodological systematic review. Journal of Clinical Epidemiology, 117, 78–88.

    Article  PubMed  Google Scholar 

  • Zhang, Z. (2014). Monte Carlo based statistical power analysis for mediation models: Methods and software. Behavior Research Methods, 46(4), 1184–1198.

    Article  PubMed  Google Scholar 

Download references

Acknowledgements

The research reported in this study was made possible by a grant from the Spencer Foundation (202100132), a U.S. Department of Education Institute of Education Sciences Grant (R305D200031), a National Institutes of Health Grant (R01AG080590), and the 2022 National Academy of Education (NAEd)/Spencer Postdoctoral Fellowship Program. The views expressed are those of the author and do not necessarily reflect the views of the foundations. The author thanks Drs. Kenneth Frank, Guanglei Hong, Amanda Kay Montoya, Lijuan Wang, and Zhiyong Zhang for their insightful suggestions and 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 web application has already been published online: https://xuqin.shinyapps.io/CausalMediationPowerAnalysis/.

Publisher’s note

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

Appendices

Appendix A. Proofs of identification of causal effects

As a supplement to the identification section, this appendix proves the identification results of the causal mediation effects.

As proved by Imai et al. (2010b) and VanderWeele and Vansteelandt (2009),

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=\int E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)|{\textbf{X}}_i\right] dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i\left(t,m\right)|{\textbf{X}}_i,{M}_i\left({t}^{\prime}\right)=m\right] dF\left({M}_i\left({t}^{\prime}\right)=m|{\textbf{X}}_i\right) dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i\left(t,m\right)|{\textbf{X}}_i,{M}_i\left({t}^{\prime}\right)=m,{T}_i={t}^{\prime}\right] dF\left({M}_i\left({t}^{\prime}\right)=m|{\textbf{X}}_i\right) dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i\left(t,m\right)|{\textbf{X}}_i,{T}_i={t}^{\prime}\right] dF\left({M}_i\left({t}^{\prime}\right)=m|{\textbf{X}}_i\right) dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i\left(t,m\right)|{\textbf{X}}_i,{T}_i=t\right] dF\left({M}_i\left({t}^{\prime}\right)=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right) dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i\left(t,m\right)|{\textbf{X}}_i,{T}_i=t,{M}_i(t)=m\right] dF\left({M}_i\left({t}^{\prime}\right)=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right) dF\left({\textbf{X}}_i\right)=\iint E\left[{Y}_i|{\textbf{X}}_i,{T}_i=t,{M}_i=m\right] dF\left({M}_i=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right) dF\left({\textbf{X}}_i\right),$$

where t and t are any two different levels of the treatment. The third and fifth equalities hold based on Assumptions 1 and 2. The fourth and sixth equalities hold based on Assumptions 3 and 4. The same idea applies to the identifications of E[Yi(t, Mi(t))], E[Yi(t, Mi(t))], and E[Yi(t, Mi(t))]. By taking contrasts of expected potential outcomes, we can identify the causal mediation effects defined in Table 1.

Continuous mediator and continuous outcome

Based on Eq. 1, we can identify that

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=E\left\{E\left[{Y}_i|{\textbf{X}}_i,T=t,{M}_i=E\left[{M}_i|{\textbf{X}}_i,T={t}^{\prime}\right]\right]\right\}={\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }E\left[\textbf{X}\right].$$

Similarly,

$$E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]={\beta}_0^y+{\beta}_t^y{t}^{\prime }+\left({\beta}_m^y+{\beta}_{tm}^y{t}^{\prime}\right)\left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }E\left[\textbf{X}\right],$$
$$E\left[{Y}_i\left(t,{M}_i(t)\right)\right]={\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }E\left[\textbf{X}\right],$$
$$E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]={\beta}_0^y+{\beta}_t^y{t}^{\prime }+\left({\beta}_m^y+{\beta}_{tm}^y{t}^{\prime}\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }E\left[\textbf{X}\right].$$

Hence, based on the definitions in Table 1, we can finally identify the causal effects as

$$TIE=E\left[{Y}_i\left(t,{M}_i(t)\right)\right]-E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=\left({\beta}_m^y+{\beta}_{tm}^yt\right){\beta}_t^m\left(t-{t}^{\prime}\right),$$
$$PDE=E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]=\left({\beta}_t^y+{\beta}_{tm}^y\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)\right)\left(t-{t}^{\prime}\right),$$
$$PIE=E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]=\left({\beta}_m^y+{\beta}_{tm}^y{t}^{\prime}\right){\beta}_t^m\left(t-{t}^{\prime}\right),$$
$$TDE=E\left[{Y}_i\left(t,{M}_i(t)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]=\left({\beta}_t^y+{\beta}_{tm}^y\left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }E\left[\textbf{X}\right]\right)\right)\left(t-{t}^{\prime}\right),$$
$$INT= TIE- PIE={\beta}_t^y{\beta}_{tm}^y{\left(t-{t}^{\prime}\right)}^2.$$

Continuous mediator and binary outcome

Based on Eq. 2, we can identify that

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)|{\textbf{X}}_i\ \right]$$
$$=\int \Pr \left({Y}_i=1|{\textbf{X}}_i,{T}_i=t,{M}_i=m\right) dF\left({M}_i=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right)$$
$$=\int \Pr \left({Y}_i^{\ast }>0|{\textbf{X}}_i,{T}_i=t,{M}_i=m\right) dF\left({M}_i=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right)$$
$$=\int \Pr \left({\beta}_0^y+{\beta}_t^yt+{\beta}_m^ym+{\beta}_{tm}^y tm+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right) dF\left({M}_i=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right)$$
$$=\int \Pr \left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i+{\varepsilon}_{mi}\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right) dF\left({\varepsilon}_{mi}\right)$$
$$=\iint \textbf{1}\left\{{\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i+{\varepsilon}_{mi}\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right\} dF\left({\varepsilon}_{y_i^{\ast }}\right) dF\left({\varepsilon}_{mi}\right)$$
$$=\Pr \left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i+{\varepsilon}_{mi}\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right)$$
$$=\Pr \left(\left({\beta}_m^y+{\beta}_{tm}^yt\right){\varepsilon}_{mi}+{\varepsilon}_{y_i^{\ast }}>-\left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\right)$$
$$=\Pr \left(\left({\beta}_m^y+{\beta}_{tm}^yt\right){\varepsilon}_{mi}+{\varepsilon}_{y_i^{\ast }}<\left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\right)$$
$$=\Phi \left(\frac{\left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i}{\sqrt{{\left({\beta}_m^y+{\beta}_{tm}^yt\right)}^2{\sigma}_m^2+1}}\right),$$

where Φ represents the cumulative density function of the standard normal distribution, and the last equation holds because \({\varepsilon}_{mi}\sim N\left(0,{\sigma}_m^2\right)\) and \({\varepsilon}_{y_i^{\ast }}\sim N\left(0,1\right)\). Hence,

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[\Phi \left(\frac{\left({\beta}_0^y+{\beta}_t^yt+\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i}{\sqrt{{\left({\beta}_m^y+{\beta}_{tm}^yt\right)}^2{\sigma}_m^2+1}}\right)\right].$$

The same applies to the identifications of E[Yi(t, Mi(t))], E[Yi(t, Mi(t))], and E[Yi(t, Mi(t))]. We are then able to identify each causal effect by taking a contrast of expected potential outcomes.

Binary mediator and continuous outcome

Based on Eq. 3, we can identify that

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[{\sum}_{m=0}^1E\left[{Y}_i|{\textbf{X}}_i,{T}_i=t,{M}_i=m\right]\times \Pr \left({M}_i=m|{\textbf{X}}_i,{T}_i={t}^{\prime}\right)\right]=E\left[\left({\beta}_0^y+{\beta}_t^yt+{\beta}_m^y+{\beta}_{tm}^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+\left({\beta}_0^y+{\beta}_t^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],$$
$$E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]=E\left[{\sum}_{m=0}^1E\left[{Y}_i|{\textbf{X}}_i=\textbf{x},{T}_i={t}^{\prime },{M}_i=m\right]\times \Pr \left({M}_i=m|{\textbf{X}}_i=\textbf{x},{T}_i=t\right)\right]=E\left[\left({\beta}_0^y+{\beta}_t^y{t}^{\prime }+{\beta}_m^y+{\beta}_{tm}^y{t}^{\prime }+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime}\right)+\left({\beta}_0^y+{\beta}_t^y{t}^{\prime }+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],$$
$$E\left[{Y}_i\left(t,{M}_i(t)\right)\right]=E\left[{\sum}_{m=0}^1E\left[{Y}_i|{\textbf{X}}_i=\textbf{x},{T}_i={t}^{\prime },{M}_i=m\right]\times \Pr \left({M}_i=m|{\textbf{X}}_i=\textbf{x},{T}_i=t\right)\right]=E\left[\left({\beta}_0^y+{\beta}_t^yt+{\beta}_m^y+{\beta}_{tm}^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+\left({\beta}_0^y+{\beta}_t^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],$$
$$E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[{\sum}_{m=0}^1E\left[{Y}_i|{\textbf{X}}_i=\textbf{x},{T}_i={t}^{\prime },{M}_i=m\right]\times \Pr \left({M}_i=m|{\textbf{X}}_i=\textbf{x},{T}_i=t\right)\right]=E\left[\left({\beta}_0^y+{\beta}_t^y{t}^{\prime }+{\beta}_m^y+{\beta}_{tm}^y{t}^{\prime }+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+\left({\beta}_0^y+{\beta}_t^y{t}^{\prime }+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right].$$

Hence, based on the definitions in Table 1, we can finally identify the causal effects as

$$TIE=E\left[{Y}_i\left(t,{M}_i(t)\right)\right]-E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[\left({\beta}_m^y+{\beta}_{tm}^yt\right)\left(\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],$$
$$PDE=E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[{\beta}_{tm}^y\left(t-{t}^{\prime}\right)\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+{\beta}_t^y\left(t-{t}^{\prime}\right)\right],$$
$$PIE=E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[\left({\beta}_m^y+{\beta}_{tm}^y{t}^{\prime}\right)\left(\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],$$
$$TDE=E\left[{Y}_i\left(t,{M}_i(t)\right)\right]-E\left[{Y}_i\left({t}^{\prime },{M}_i(t)\right)\right]=E\left[{\beta}_{tm}^y\left(t-{t}^{\prime}\right)\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+{\beta}_t^y\left(t-{t}^{\prime}\right)\right],$$
$$INT= TIE- PIE=E\left[{\beta}_{tm}^y\left(t-{t}^{\prime}\right)\left(\Phi \left({\beta}_0^m+{\beta}_t^mt+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right].$$

Binary mediator and binary outcome

Based on Eq. 4, we can identify that

$$E\left[{Y}_i\left(t,{M}_i\left({t}^{\prime}\right)\right)\right]=E\left[{\sum}_{m=0}^1E\left[{Y}_i|{\textbf{X}}_i=\textbf{x},{T}_i=t,{M}_i=m\right]\times \Pr \left({M}_i=m|{\textbf{X}}_i=\textbf{x},{T}_i={t}^{\prime}\right)\right]=E\left[\Pr \left({\beta}_0^y+{\beta}_t^yt+{\beta}_m^y+{\beta}_{tm}^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right)\times \Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+\Pr \left({\beta}_0^y+{\beta}_t^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i+{\varepsilon}_{y_i^{\ast }}>0\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right],=E\left[\Phi \left({\beta}_0^y+{\beta}_t^yt+{\beta}_m^y+{\beta}_{tm}^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)+\Phi \left({\beta}_0^y+{\beta}_t^yt+{{\boldsymbol{\beta}}_x^y}^{\prime }{\textbf{X}}_i\right)\times \left(1-\Phi \left({\beta}_0^m+{\beta}_t^m{t}^{\prime }+{{\boldsymbol{\beta}}_x^m}^{\prime }{\textbf{X}}_i\right)\right)\right].$$

Similarly, we can identify [Yi(t, Mi(t))], E[Yi(t, Mi(t))], and E[Yi(t, Mi(t))]. Each causal effect can be identified via a contrast of expected potential outcomes.

Appendix B. Derivations of \({\beta}_x^t,{\beta}_x^m,\) and \({\beta}_x^y\) for data generation

This appendix derives \({\boldsymbol{\beta}}_x^t,{\boldsymbol{\beta}}_x^m,\) and \({\boldsymbol{\beta}}_x^y\) based on the parameters that users are required to specify, \({\beta}_t^m,{\beta}_t^y,{\beta}_m^y,{\beta}_{tm}^y,{R}_{tx}^2,\) \({R}_{mx}^2,\) and \({R}_{yx}^2\), where \({R}_{tx}^2,\) \({R}_{mx}^2,\) and \({R}_{yx}^2\) are respectively the proportion of the variance in T (or T if T is binary) explained by X, the proportion of the variance in M (or M if M is binary) explained by X, and the proportion of the variance in Y (or Y if Y is binary) explained by X, without controlling for any variables.

I first focus on a single standard normal covariate X. If the treatment is not randomized, and the treatment, mediator, and outcome are all continuous, the following standardized regressions are used for data generation.

$${T}_i={\beta}_x^t{X}_i+{\varepsilon}_{ti},$$
$${M}_i={\beta}_t^m{T}_i+{\beta}_x^m{X}_i+{\varepsilon}_{mi},$$
$${Y}_i={\beta}_t^y{T}_i+{\beta}_m^y{M}_i+{\beta}_{tm}^y{T}_i{M}_i+{\beta}_x^y{X}_i+{\varepsilon}_{yi},$$

where \({\hat{\beta}}_x^t={R}_{tx}.\) In the mediator model, based on the ordinary least squares (OLS) estimator

$$\left(\begin{array}{c}{\hat{\beta}}_t^m\\ {}{\hat{\beta}}_x^m\end{array}\right)={\left[\left(\begin{array}{c}{T}^{\prime}\\ {}{X}^{\prime}\end{array}\right)\left(T\kern0.5em X\right)\right]}^{-1}\left[\left(\begin{array}{c}{T}^{\prime}\\ {}{X}^{\prime}\end{array}\right)M\right]={\left[\begin{array}{cc}1& {R}_{tx}\\ {}{R}_{tx}& 1\end{array}\right]}^{-1}\left[\begin{array}{c}{R}_{mt}\\ {}{R}_{mx}\end{array}\right],$$

where T = (T1, …, Tn), X = (X1, …, Xn), and M = (M1, …, Mn) for n individuals, and they are all standardized, we can calculate \({\beta}_x^m\) as

$${\beta}_x^m={R}_{mx}-{\beta}_t^m{R}_{tx},$$
(B.1)

which is consistent with Eq. 1 in Mauro (1990). Similarly, in the outcome model, based on the OLS estimator

$$\left(\begin{array}{c}{\hat{\beta}}_t^y\\ {}{\hat{\beta}}_m^y\\ {}{\hat{\beta}}_{tm}^y\\ {}{\hat{\beta}}_x^y\end{array}\right)={\left[\left(\begin{array}{c}{T}^{\prime}\\ {}{M}^{\prime}\\ {}{TM}^{\prime}\\ {}{X}^{\prime}\end{array}\right)\left(\begin{array}{cccc}T& M& TM& X\end{array}\right)\right]}^{-1}\left[\left(\begin{array}{c}{T}^{\prime}\\ {}{M}^{\prime}\\ {}{TM}^{\prime}\\ {}{X}^{\prime}\end{array}\right)Y\right]$$
$$={\left[\begin{array}{cccc}1& {R}_{mt}& {R}_{t, tm}& {R}_{tx}\\ {}{R}_{mt}& 1& {R}_{m, tm}& {R}_{mx}\\ {}{R}_{t, tm}& {R}_{m, tm}& 1& {R}_{x, tm}\\ {}{R}_{tx}& {R}_{mx}& {R}_{x, tm}& 1\end{array}\right]}^{-1}\left[\begin{array}{c}{R}_{yt}\\ {}{R}_{ym}\\ {}{R}_{y, tm}\\ {}{R}_{yx}\end{array}\right],$$

where TM = (T1M1, …, TnMn) and Y = (Y1, …, Yn) for n individuals, and they are all standardized, we can calculate \({\beta}_x^y\) as

$${\beta}_x^y={R}_{yx}-{\beta}_{tm}^y{R}_{x, tm}-{\beta}_m^y{R}_{mx}-{\beta}_t^y{R}_{tx},$$
(B.2)

where Rx, tm = 0 because \({R}_{x, tm}=\frac{\textrm{E}(XTM)-\textrm{E}\left(X\left)\textrm{E}\right( TM\right)}{\sqrt{\textrm{Var}\left(X\left)\textrm{Var}\right( TM\right)}}\), where E(X) = 0, Var(X) = 1,

Var(TM) = Var(T)Var(M) + Var(T)E(M)2 + Var(M)E(T)2 = 1, and

$$\textrm{E}\left( XT M\right)=E\left( XT\left({\beta}_t^mT+{\beta}_x^mX+{\varepsilon}_m\right)\right)$$
$$={\beta}_t^mE\left(X{T}^2\right)+{\beta}_x^mE\left({X}^2T\right)+E\left( XT{\varepsilon}_m\right)$$
$$={\beta}_t^mE\left(X{\left({\beta}_x^tX+{\varepsilon}_t\right)}^2\right)+{\beta}_x^mE\left({X}^2\left({\beta}_x^tX+{\varepsilon}_t\right)\right)+E\left(X\left({\beta}_x^tX+{\varepsilon}_t\right){\varepsilon}_m\right)$$
$$=\left({\beta}_t^m{\beta}_x^{t2}+{\beta}_x^m{\beta}_x^t\right)E\left({X}^3\right)+{\beta}_t^mE\left({\varepsilon}_t^2X\right)+\left(2{\beta}_t^m{\beta}_x^t+{\beta}_x^m\right)E\left({X}^2{\varepsilon}_t\right)+{\beta}_x^tE\left({X}^2{\varepsilon}_m\right)+E\left(X{\varepsilon}_t{\varepsilon}_m\right),$$

where E(X3) = 0, \(E\left({\varepsilon}_t^2X\right)=E\left({\varepsilon}_t^2\right)E(X)=0\), E(X2εt) = E(X2)E(εt) = 0, E(X2εm) = E(X2)E(εm) = 0, and E(tεm) = E(X)E(εt)E(εm) = 0.

Therefore,

$${\beta}_x^y={R}_{yx}-{\beta}_m^y{R}_{mx}-{\beta}_t^y{R}_{tx}.$$
(B.3)

If the number of covariates is p, p independent standard normal covariates are generated. I have verified through simulations that power depends on the number of covariates and \({R}_x^2\) contributed by the set of covariates as a whole but is not affected by how much \({R}_x^2\) each specific covariate contributes and how the multiple covariates are correlated. Therefore, based on the assumption that the covariates evenly partition each of \({R}_{tx}^2\), \({R}_{mx}^2\), and \({R}_{yx}^2\), the coefficient of each covariate in each model can be calculated as the previously derived coefficient of the single covariate divided by \(\sqrt{p}\).

Above, I focus on a nonrandomized treatment and continuous treatment, mediator, and outcome. If the treatment is randomized, Rtx = 0. If any of the treatment, mediator, and outcome is binary, the corresponding model becomes a latent regression, and the corresponding \({R}_x^2\) is defined as the proportion of the variance in the latent index of the corresponding response explained by X, and thus the Eqs. (B.1) and (B.2) still apply. However, Rx, tm is different under different scenarios. Its derivation is particularly tricky if T and/or M are binary. In addition, when T (or M) is binary, Rtx in Eq. (B.1) and Eq. (B.2) (or Rmx in Eq. (B.2)) is the correlation between X and the predictor T (or M), which is on the original scale rather than the latent scale, and thus it needs to be recalculated. These difficulties can be greatly alleviated by calculating Rx, tm, Rtx, and Rmx with simulated data. The accuracy of the approach has been verified through simulations.

As shown above, the calculation of βx’s depends on not only \({R}_x^2\)’s but also the signs of Rx’s. Nevertheless, the latter plays a trivial role with respect to power. When both the mediator and outcome are continuous and X is standardized, the effect estimands do not depend on βx, in which case power is not affected by the signs of Rx’s. When the mediator and/or outcome is binary and X is standardized, although βx is involved in the effect estimands, I have verified through simulations that different signs of Rx’s make little difference in power under various scenarios. Therefore, I calculate each Rx as the square root of the corresponding \({R}_x^2\).

Appendix C. Simulations comparing the Monte Carlo method and the bootstrapping method when the mediator and outcome are nonnormal

I conducted Monte Carlo simulations to compare the performance of the Monte Carlo confidence interval method and the bootstrapping method in terms of bias, mean squared error (MSE), 95% confidence/credible interval (CI) coverage rate, type I error rate, and power for the estimation and inference of the causal mediation effects under various scenarios that vary by the sample size and the skewness and kurtosis of the distributions of the mediator and the outcome.

Data generation

Focusing on a randomized treatment, I generated the treatment T from a Bernoulli distribution with Pr(T) = 0.5 and generated the pretreatment covariate X from a standard normal distribution. I generated the continuous mediator and outcome based on the following models:

$${M}_i={\beta}_0^m+{\beta}_t^m{T}_i+{\beta}_x^m{\textrm{X}}_i+{\varepsilon}_{mi},$$
$${Y}_i={\beta}_0^y+{\beta}_t^y{T}_i+{\beta}_m^y{M}_i+{\beta}_{tm}^y{T}_i{M}_i+{\beta}_x^y{\textrm{X}}_i+{\varepsilon}_{yi},$$

where \({\beta}_{00}^m\) and \({\beta}_{00}^y\) are set to be 0 in all the scenarios; εM and εY have a mean of 0, a variance of 1, and different values of skewness and kurtosis under different scenarios. I considered three different sets of parameter values. In set 1, all the parameters take the value of 0, so that type I error rates can be assessed. Sets 2 and 3 are selected from those considered in the section of sample size planning, as shown in Table 3. Set 2 is the smallest set of parameter values, in which \({\beta}_t^y=0.14\) (S), \({\beta}_m^y=0.14\) (S), \({\beta}_{tm}^y=0.1\) (HS), \({R}_{mx}^2={R}_{yx}^2=0.02\) (S), \({\beta}_t^m=0.14\) (S). Set 3 is the largest set of parameter values, in which \({\beta}_t^y=0.36\) (M), \({\beta}_m^y=0.27\) (HM), \({\beta}_{tm}^y=0.14\) (S), \({R}_{mx}^2={R}_{mx}^2=0.075\) (HM), \({\beta}_t^m=0.27\) (HM). In addition, we considered three different sample sizes, 30, 50, and 150, and three different sets of skewness and kurtosis of the distributions of the mediator and the outcome, (1, 1), (2, 3), and (3, 8). In total, there are 3 × 3 × 3 = 27 different scenarios. For each scenario, I generated 10,000 replications.

Software implementation

I ran the simulations in R. I generated εM and εY with the R package mnonr (Qu & Zhang, 2020). To implement the bootstrapping algorithm, I used the boot function and generated 1000 bootstrapped samples for each replication. Confidence intervals are constructed using the bootstrap percentile interval.

Evaluation criteria

Given the three different sets of model parameters values, we obtain three sets of true values of PIE, TIE, PDE, TDE, and INT: (1)(0, 0, 0, 0, 0), (2) (0.04, 0.08, 0.26, 0.30, 0.04), (3) (0.14, 0.25, 0.67, 0.77, 0.10). The true effects are calculated in the same way as noted below Table 2. Let δ denote each true effect and \({\hat{\delta}}_i\) be the estimate obtained from the ith replication. The following evaluation criteria are used to evaluate the performance of each method. (1) Bias \(=\frac{\sum_{i=1}^{\textrm{10,000}}\left({\hat{\delta}}_i-\delta \right)}{\textrm{10,000}}\) for δ = 0, and relative bias \(=\frac{\sum_{i=1}^{\textrm{10,000}}\left({\hat{\delta}}_i-\delta \right)}{\textrm{10,000}\delta }\) for δ ≠ 0. (2) MSE \(=\frac{\sum_{i=1}^{\textrm{10,000}}{\left({\hat{\delta}}_i-\delta \right)}^2}{\textrm{10,000}}\). (3) 95% CI coverage rate \(=\frac{\#\left({\hat{L}}_i\le \delta \le {\hat{U}}_i\right)}{\textrm{10,000}}\), where \(\left[{\hat{L}}_i,{\hat{U}}_i\right]\) is the 95% CI of the ith replication, and \(\#\left({\hat{L}}_i\le \delta \le {\hat{U}}_i\right)\) is the number of replications with CI that includes δ. (4) Rejection rate \(=\frac{\#\left({\hat{L}}_i>0\ or\ {\hat{U}}_i<0\right)}{\textrm{10,000}}\), where \(\#\left({\hat{L}}_i>0\ or\ {\hat{U}}_i<0\right)\) is the number of replications that reject the null hypothesis that δ = 0 with the significance level alpha at 0.05. The rejection rate is the power when δ ≠ 0 and is the type I error rate when δ = 0.

Simulation results

We present the simulation results for PIE, TIE, PDE, TDE, and INT in Appendix Tables 8, 9, 10, 11 and 12 respectively.

Under the three sets of parameter values, the 95% CI coverage rate of INT is always away from 95% when the sample size is small. To find a scenario when the 95% CI coverage rate gets close to 95%, I increase the true value of INT by increasing \({\beta}_{tm}^y\) from S to HM. Hence, in Appendix Table 12, I further incorporate the simulation results based on Set 4 of the parameter values, \({\beta}_t^y=0.36\) (M), \({\beta}_m^y=0.27\) (HM), \({\beta}_{tm}^y=0.27\) (HM), \({R}_{mx}^2={R}_{mx}^2=0.075\) (HM), \({\beta}_t^m=0.27\) (HM), which leads to a true natural treatment-by-mediator interaction effect of 0.20.

Table 8 Simulation results for the pure indirect effect
Table 9 Simulation results for the total indirect effect
Table 10 Simulation results for the pure direct effect
Table 11 Simulation results for the total direct effect
Table 12 Simulation results for the natural treatment-by-mediator interaction effect

Appendix D. Sample size planning when the number of covariates is 10

Table 13 Sample sizes for achieving a power of 0.8 when both M and Y are normal
Table 14 Sample sizes for achieving a power of 0.8 when M is normal and Y is binary
Table 15 Sample sizes for achieving a power of 0.8 when M is binary and Y is normal
Table 16 Sample sizes for achieving a power of 0.8 when both M and Y are binary

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. Sample size and power calculations for causal mediation analysis: A Tutorial and Shiny App. Behav Res 56, 1738–1769 (2024). https://doi.org/10.3758/s13428-023-02118-0

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.3758/s13428-023-02118-0

Keywords

Navigation