Calculate sample size for testing mediation effect in logistic regression based on Vittinghoff, Sen and McCulloch's (2009) method.
ssMediation.VSMc.logistic(power,
b2,
sigma.m,
p,
corr.xm,
n.lower = 1,
n.upper = 1e+30,
alpha = 0.05,
verbose = TRUE)
power for testing
regression coefficient for the mediator
standard deviation of the mediator.
the marginal prevalence of the outcome.
correlation between the predictor
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
Vittinghoff et al. (2009) showed that for the above logistic regression, testing the mediation effect
is equivalent to testing the null hypothesis
The full model is
The reduced model is
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 4 (page 545) of Vittinghoff et al. (2009).
# n=255
ssMediation.VSMc.logistic(power = 0.80, b2 = log(1.5), sigma.m = 1, p = 0.5,
corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# }
Run the code above in your browser using DataLab