Calculate sample size for testing mediation effect in linear regression based on Vittinghoff, Sen and McCulloch's (2009) method.
ssMediation.VSMc(power,
b2,
sigma.m,
sigma.e,
corr.xm,
n.lower = 1,
n.upper = 1e+30,
alpha = 0.05,
verbose = TRUE)
power for testing \(b_2=0\) for the linear regression \(y_i=b0+b1 x_i + b2 m_i + \epsilon_i, \epsilon_i\sim N(0, \sigma_e^2)\).
regression coefficient for the mediator \(m\) in the linear regression \(y_i=b0+b1 x_i + b2 m_i + \epsilon_i, \epsilon_i\sim N(0, \sigma_e^2)\).
standard deviation of the mediator.
standard deviation of the random error term in the linear regression \(y_i=b0+b1 x_i + b2 m_i + \epsilon_i, \epsilon_i\sim N(0, \sigma_e^2)\).
correlation between the predictor \(x\) and the mediator \(m\).
lower bound for the sample size.
upper bound for the sample size.
type I error rate.
logical. TRUE
means printing sample size; FALSE
means not printing sample size.
sample size.
results of optimization to find the optimal sample size.
The test is for testing the null hypothesis \(b_2=0\) versus the alternative hypothesis \(b_2\neq 0\) for the linear regressions: $$y_i=b_0+b_1 x_i + b_2 m_i + \epsilon_i, \epsilon_i\sim N(0, \sigma^2_{e})$$
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\).
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.
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
# NOT RUN {
# example in section 3 (page 544) of Vittinghoff et al. (2009).
# n=863
ssMediation.VSMc(power = 0.80, b2 = 0.1, sigma.m = 1, sigma.e = 1,
corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
# }
Run the code above in your browser using DataLab