minEffect.VSMc(n,
power,
sigma.m,
sigma.e,
corr.xm,
alpha = 0.05,
verbose = TRUE)TRUE means printing minimum absolute detectable effect; FALSE means not printing minimum absolute detectable effect.Vittinghoff et al. (2009) showed that for the above linear regression, testing the mediation effect
is equivalent to testing the null hypothesis $H_0: b_2=0$
versus the alternative hypothesis $H_a: b_2\neq 0$, if the
correlation corr.xm between the primary predictor and mediator is non-zero.
The full model is $$y_i=b_0+b_1 x_i + b_2 m_i + \epsilon_i, \epsilon_i\sim N(0, \sigma^2_{e})$$
The reduced model is $$y_i=b_0+b_1 x_i + \epsilon_i, \epsilon_i\sim N(0, \sigma^2_{e})$$
Vittinghoff et al. (2009) mentioned that if confounders need to be included
in both the full and reduced models, the sample size/power calculation formula
could be accommodated by redefining corr.xm as the multiple
correlation of the mediator with the confounders as well as the predictor.
powerMediation.VSMc,
ssMediation.VSMc# example in section 3 (page 544) of Vittinghoff et al. (2009).
# minimum effect is =0.1
minEffect.VSMc(n = 863, power = 0.8, sigma.m = 1,
sigma.e = 1, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)Run the code above in your browser using DataLab