Title: | Power/Sample Size Calculation for Mediation Analysis |
---|---|
Description: | Functions to calculate power and sample size for testing (1) mediation effects; (2) the slope in a simple linear regression; (3) odds ratio in a simple logistic regression; (4) mean change for longitudinal study with 2 time points; (5) interaction effect in 2-way ANOVA; and (6) the slope in a simple Poisson regression. |
Authors: | Weiliang Qiu <[email protected]> |
Maintainer: | Weiliang Qiu <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3.4 |
Built: | 2025-01-29 05:54:16 UTC |
Source: | https://github.com/cran/powerMediation |
Calculate minimal detectable slope given sample size and power for simple linear regression.
minEffect.SLR(n, power, sigma.x, sigma.y, alpha = 0.05, verbose = TRUE)
minEffect.SLR(n, power, sigma.x, sigma.y, alpha = 0.05, verbose = TRUE)
n |
sample size. |
power |
power for testing if |
sigma.x |
standard deviation of the predictor |
sigma.y |
marginal standard deviation of the outcome |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the simple linear regressions:
lambda.a |
minimum absolute detectable effect. |
res.uniroot |
results of optimization to find the optimal minimum absolute detectable effect. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Dupont, W.D. and Plummer, W.D.. Power and Sample Size Calculations for Studies Involving Linear Regression. Controlled Clinical Trials. 1998;19:589-601.
power.SLR
,
power.SLR.rho
,
ss.SLR
,
ss.SLR.rho
.
minEffect.SLR(n = 100, power = 0.8, sigma.x = 0.2, sigma.y = 0.5, alpha = 0.05, verbose = TRUE)
minEffect.SLR(n = 100, power = 0.8, sigma.x = 0.2, sigma.y = 0.5, alpha = 0.05, verbose = TRUE)
Calculate minimal detectable slope for mediator given sample size and power in simple linear regression based on Vittinghoff, Sen and McCulloch's (2009) method.
minEffect.VSMc(n, power, sigma.m, sigma.e, corr.xm, alpha = 0.05, verbose = TRUE)
minEffect.VSMc(n, power, sigma.m, sigma.e, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
power |
power for testing |
sigma.m |
standard deviation of the mediator. |
sigma.e |
standard deviation of the random error term in the linear regression
|
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Vittinghoff et al. (2009) showed that for the above linear regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative hypothesis
, if the
correlation
corr.xm
between the primary predictor and mediator is non-zero.
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.
b2 |
minimum absolute detectable effect. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
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)
# 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)
Calculate minimal detectable slope for mediator given sample size and power in cox regression based on Vittinghoff, Sen and McCulloch's (2009) method.
minEffect.VSMc.cox(n, power, sigma.m, psi, corr.xm, alpha = 0.05, verbose = TRUE)
minEffect.VSMc.cox(n, power, sigma.m, psi, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
power |
power for testing |
sigma.m |
standard deviation of the mediator. |
psi |
the probability that an observation is uncensored, so that
the number of event |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the cox regressions:
Vittinghoff et al. (2009) showed that for the above cox regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative hypothesis
, if the
correlation
corr.xm
between the primary predictor and mediator is non-zero.
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.
b2 |
minimum absolute detectable effect. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
powerMediation.VSMc.cox
,
ssMediation.VSMc.cox
# example in section 6 (page 547) of Vittinghoff et al. (2009). # minimum effect is = log(1.5) = 0.4054651 minEffect.VSMc.cox(n = 1399, power = 0.7999916, sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
# example in section 6 (page 547) of Vittinghoff et al. (2009). # minimum effect is = log(1.5) = 0.4054651 minEffect.VSMc.cox(n = 1399, power = 0.7999916, sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
Calculate minimal detectable slope for mediator given sample size and power in logistic regression based on Vittinghoff, Sen and McCulloch's (2009) method.
minEffect.VSMc.logistic(n, power, sigma.m, p, corr.xm, alpha = 0.05, verbose = TRUE)
minEffect.VSMc.logistic(n, power, sigma.m, p, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
power |
power for testing |
sigma.m |
standard deviation of the mediator. |
p |
the marginal prevalence of the outcome. |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the logistic regressions:
Vittinghoff et al. (2009) showed that for the above logistic regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative hypothesis
, if the
correlation
corr.xm
between the primary predictor and mediator is non-zero.
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.
b2 |
minimum absolute detectable effect. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
powerMediation.VSMc.logistic
,
ssMediation.VSMc.logistic
# example in section 4 (page 545) of Vittinghoff et al. (2009). # minimum effect is log(1.5)= 0.4054651 minEffect.VSMc.logistic(n = 255, power = 0.8, sigma.m = 1, p = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# example in section 4 (page 545) of Vittinghoff et al. (2009). # minimum effect is log(1.5)= 0.4054651 minEffect.VSMc.logistic(n = 255, power = 0.8, sigma.m = 1, p = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
Calculate minimal detectable slope for mediator given sample size and power in poisson regression based on Vittinghoff, Sen and McCulloch's (2009) method.
minEffect.VSMc.poisson(n, power, sigma.m, EY, corr.xm, alpha = 0.05, verbose = TRUE)
minEffect.VSMc.poisson(n, power, sigma.m, EY, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
power |
power for testing |
sigma.m |
standard deviation of the mediator. |
EY |
the marginal mean of the outcome |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the poisson regressions:
Vittinghoff et al. (2009) showed that for the above poisson regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative hypothesis
, if the
correlation
corr.xm
between the primary predictor and mediator is non-zero.
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.
b2 |
minimum absolute detectable effect. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
powerMediation.VSMc.poisson
,
ssMediation.VSMc.poisson
# example in section 5 (page 546) of Vittinghoff et al. (2009). # minimum effect is = log(1.35) = 0.3001046 minEffect.VSMc.poisson(n = 1239, power = 0.7998578, sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# example in section 5 (page 546) of Vittinghoff et al. (2009). # minimum effect is = log(1.35) = 0.3001046 minEffect.VSMc.poisson(n = 1239, power = 0.7998578, sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
Calculate power for testing slope for simple linear regression.
power.SLR(n, lambda.a, sigma.x, sigma.y, alpha = 0.05, verbose = TRUE)
power.SLR(n, lambda.a, sigma.x, sigma.y, alpha = 0.05, verbose = TRUE)
n |
sample size. |
lambda.a |
regression coefficient in the simple linear regression
|
sigma.x |
standard deviation of the predictor |
sigma.y |
marginal standard deviation of the outcome |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the simple linear regressions:
power |
power for testing if |
delta |
|
s |
|
t.cr |
|
rho |
correlation between the predictor |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Dupont, W.D. and Plummer, W.D.. Power and Sample Size Calculations for Studies Involving Linear Regression. Controlled Clinical Trials. 1998;19:589-601.
minEffect.SLR
,
power.SLR.rho
,
ss.SLR.rho
,
ss.SLR
.
power.SLR(n=100, lambda.a=0.8, sigma.x=0.2, sigma.y=0.5, alpha = 0.05, verbose = TRUE)
power.SLR(n=100, lambda.a=0.8, sigma.x=0.2, sigma.y=0.5, alpha = 0.05, verbose = TRUE)
Calculate power for testing slope for simple linear regression.
power.SLR.rho(n, rho2, alpha = 0.05, verbose = TRUE)
power.SLR.rho(n, rho2, alpha = 0.05, verbose = TRUE)
n |
sample size. |
rho2 |
square of the correlation between the outcome and the predictor. |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the simple linear regressions:
power |
power for testing if |
delta |
|
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Dupont, W.D. and Plummer, W.D.. Power and Sample Size Calculations for Studies Involving Linear Regression. Controlled Clinical Trials. 1998;19:589-601.
minEffect.SLR
,
power.SLR
,
ss.SLR.rho
,
ss.SLR
.
power.SLR.rho(n=100, rho2=0.6, alpha = 0.05, verbose = TRUE)
power.SLR.rho(n=100, rho2=0.6, alpha = 0.05, verbose = TRUE)
Power calculation for interaction effect in 2x2 two-way ANOVA given effect sizes.
powerInteract2by2(n, tauBetaSigma, alpha = 0.05, nTests = 1, verbose = FALSE)
powerInteract2by2(n, tauBetaSigma, alpha = 0.05, nTests = 1, verbose = FALSE)
n |
integer. Number of subjects per group. |
tauBetaSigma |
Effect sizes |
alpha |
family-wise type I error rate. |
nTests |
integer. For high-throughput omics study,
we perform two-way ANOVA for each of 'nTests' probes.
We use Bonferroni correction to control for family-wise type I error rate.
That is, for each probe, type I error rate would be |
verbose |
logical. Indicating if intermediate results should be printed out. |
We assume the following model:
where ,
,
,
,
,
and
.
The group means are
Note that ,
, and
.
The null hypothesis : all
are equal to zero.
The alternative hypothesis
: at least one
is different from zero.
The F test statistic is
where ncp
is the
non-centrality parameter of the F test statistic:
For the scenario , we have
,
,
,
.
Hence,
the non-centrality parameter can be simplified to
The power for testing the null hypothesis versus
the alternative hypothesis
is
where the rejection region boundary satisfies:
A list with 5 elements:
power |
the power of the two-way ANOVA test |
df1 |
the first degree of freedom of the F test statistic ( |
df2 |
the second degree of freedom of the F test statistic ( |
F0 |
the rejection region boundary |
ncp |
the non-centrality parameter |
Weiliang Qiu [email protected]
Chow SC, Shao J, and Wang H. Sample size calculations in clinical research. 2nd edition. Chapman & Hall/CRC. 2008
Montgomery DC. Design and Analysis of Experiments. 8th edition. John Wiley & Sons. Inc.
n = 25 tauBetaSigma = 0.3 # power = 0.8437275 res2 = powerInteract2by2(n = n, tauBetaSigma = tauBetaSigma, alpha = 0.05, nTests = 1, verbose = TRUE)
n = 25 tauBetaSigma = 0.3 # power = 0.8437275 res2 = powerInteract2by2(n = n, tauBetaSigma = tauBetaSigma, alpha = 0.05, nTests = 1, verbose = TRUE)
Calculating power for simple logistic regression with binary predictor.
powerLogisticBin(n, p1, p2, B, alpha = 0.05)
powerLogisticBin(n, p1, p2, B, alpha = 0.05)
n |
total number of sample size. |
p1 |
|
p2 |
|
B |
|
alpha |
Type I error rate. |
The logistic regression mode is
where ,
is the binary predictor,
,
,
, and
.
The sample size formula we used for testing if
, is Formula (2) in Hsieh et al. (1998):
where is the required total sample size and
is the
-th
percentile of the standard normal distribution.
Estimated power.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Hsieh, FY, Bloch, DA, and Larsen, MD. A SIMPLE METHOD OF SAMPLE SIZE CALCULATION FOR LINEAR AND LOGISTIC REGRESSION. Statistics in Medicine. 1998; 17:1623-1634.
## Example in Table I Design (Balanced design with high event rates) ## of Hsieh et al. (1998 ) ## the power = 0.95 powerLogisticBin(n = 1281, p1 = 0.4, p2 = 0.5, B = 0.5, alpha = 0.05)
## Example in Table I Design (Balanced design with high event rates) ## of Hsieh et al. (1998 ) ## the power = 0.95 powerLogisticBin(n = 1281, p1 = 0.4, p2 = 0.5, B = 0.5, alpha = 0.05)
Calculating power for simple logistic regression with continuous predictor.
powerLogisticCon(n, p1, OR, alpha = 0.05)
powerLogisticCon(n, p1, OR, alpha = 0.05)
n |
total sample size. |
p1 |
the event rate at the mean of the continuous predictor |
OR |
Expected odds ratio. |
alpha |
Type I error rate. |
The logistic regression mode is
where ,
is the continuous predictor, and
is the
the change in log odds for the difference between at the mean of
and at one SD above the mean.
The sample size formula we used for testing if
or equivalently
, is Formula (1) in Hsieh et al. (1998):
where is the required total sample size,
is the
odds ratio to be tested,
is the event rate at the mean
of the predictor
, and
is the
-th
percentile of the standard normal distribution.
Estimated power.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Hsieh, FY, Bloch, DA, and Larsen, MD. A SIMPLE METHOD OF SAMPLE SIZE CALCULATION FOR LINEAR AND LOGISTIC REGRESSION. Statistics in Medicine. 1998; 17:1623-1634.
## Example in Table II Design (Balanced design (1)) of Hsieh et al. (1998 ) ## the power is 0.95 powerLogisticCon(n=317, p1=0.5, OR=exp(0.405), alpha=0.05)
## Example in Table II Design (Balanced design (1)) of Hsieh et al. (1998 ) ## the power is 0.95 powerLogisticCon(n=317, p1=0.5, OR=exp(0.405), alpha=0.05)
Power calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with 2 time point.
powerLong(es, n, rho = 0.5, alpha = 0.05)
powerLong(es, n, rho = 0.5, alpha = 0.05)
es |
effect size of the difference of mean change. |
n |
sample size per group. |
rho |
correlation coefficient between baseline and follow-up values within a treatment group. |
alpha |
Type I error rate. |
The power formula is based on Equation 8.31 on page 336 of Rosner (2006).
where ,
,
is the mean change over time
in group 1,
is the mean change over time
in group 2,
is the variance of baseline values within a treatment group,
is the variance of follow-up values within a treatment group,
is the correlation coefficient between baseline and follow-up values within a treatment group,
and
is the u-th percentile of the standard normal distribution.
We wish to test .
When , then formula reduces to
where .
power for testing for difference of mean changes.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Rosner, B. Fundamentals of Biostatistics. Sixth edition. Thomson Brooks/Cole. 2006.
ssLong
, ssLongFull
,
powerLongFull
.
# Example 8.34 on page 336 of Rosner (2006) # power=0.75 powerLong(es=5/15, n=75, rho=0.7, alpha=0.05)
# Example 8.34 on page 336 of Rosner (2006) # power=0.75 powerLong(es=5/15, n=75, rho=0.7, alpha=0.05)
Power calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with more than 2 time points.
powerLong.multiTime(es, m, nn, sx2, rho = 0.5, alpha = 0.05)
powerLong.multiTime(es, m, nn, sx2, rho = 0.5, alpha = 0.05)
es |
effect size |
m |
number of subjects |
nn |
number of observations per subject |
sx2 |
within subject variance |
rho |
within subject correlation |
alpha |
type I error rate |
We are interested in comparing the slopes of the 2 groups and
:
where
and
The power calculation formula is (Equation on page 30 of Diggle et al. (1994)):
where ,
is the meaninful differnce of interest,
is the variance of the random error,
is the within-subject correlation, and
is the within-subject variance.
power
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Diggle PJ, Liang KY, and Zeger SL (1994). Analysis of Longitundinal Data. page 30. Clarendon Press, Oxford
# power=0.8 powerLong.multiTime(es=0.5/10, m=196, nn=3, sx2=4.22, rho = 0.5, alpha = 0.05)
# power=0.8 powerLong.multiTime(es=0.5/10, m=196, nn=3, sx2=4.22, rho = 0.5, alpha = 0.05)
Power calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with 2 time point.
powerLongFull(delta, sigma1, sigma2, n, rho = 0.5, alpha = 0.05)
powerLongFull(delta, sigma1, sigma2, n, rho = 0.5, alpha = 0.05)
delta |
absolute difference of the mean changes between the two groups: |
sigma1 |
the standard deviation of baseline values within a treatment group |
sigma2 |
the standard deviation of follow-up values within a treatment group |
n |
sample size per group |
rho |
correlation coefficient between baseline and follow-up values within a treatment group. |
alpha |
Type I error rate. |
The power formula is based on Equation 8.31 on page 336 of Rosner (2006).
where ,
,
is the mean change over time
in group 1,
is the mean change over time
in group 2,
is the variance of baseline values within a treatment group,
is the variance of follow-up values within a treatment group,
is the correlation coefficient between baseline and follow-up values within a treatment group,
and
is the u-th percentile of the standard normal distribution.
We wish to test .
power for testing for difference of mean changes.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Rosner, B. Fundamentals of Biostatistics. Sixth edition. Thomson Brooks/Cole. 2006.
ssLong
, ssLongFull
,
powerLong
.
# Example 8.33 on page 336 of Rosner (2006) # power=0.80 powerLongFull(delta=5, sigma1=15, sigma2=15, n=85, rho=0.7, alpha=0.05)
# Example 8.33 on page 336 of Rosner (2006) # power=0.80 powerLongFull(delta=5, sigma1=15, sigma2=15, n=85, rho=0.7, alpha=0.05)
Calculate power for testing mediation effect based on Sobel's test.
powerMediation.Sobel(n, theta.1a, lambda.a, sigma.x, sigma.m, sigma.epsilon, alpha = 0.05, verbose = TRUE)
powerMediation.Sobel(n, theta.1a, lambda.a, sigma.x, sigma.m, sigma.epsilon, alpha = 0.05, verbose = TRUE)
n |
sample size. |
theta.1a |
regression coefficient for the predictor in the linear regression linking
the predictor |
lambda.a |
regression coefficient for the mediator in the linear regression linking
the predictor |
sigma.x |
standard deviation of the predictor. |
sigma.m |
standard deviation of the mediator. |
sigma.epsilon |
standard deviation of the random error term
in the linear regression linking
the predictor |
alpha |
type I error. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Test statistic is based on Sobel's (1982) test:
where is the estimated standard deviation
of the estimate
using multivariate
delta method:
and
is the
variance
of the estimate
, and
is the variance
of the estimate
,
is the variance of the
mediator
.
From the linear regression , we have the
relationship
. Hence, we can simply
the variance
to
power |
power of the test for the parameter |
delta |
|
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Sobel, M. E. Asymptotic confidence intervals for indirect effects in structural equation models. Sociological Methodology. 1982;13:290-312.
ssMediation.Sobel
,
testMediation.Sobel
powerMediation.Sobel(n=248, theta.1a=0.1701, lambda.a=0.1998, sigma.x=0.57, sigma.m=0.61, sigma.epsilon=0.2, alpha = 0.05, verbose = TRUE)
powerMediation.Sobel(n=248, theta.1a=0.1701, lambda.a=0.1998, sigma.x=0.57, sigma.m=0.61, sigma.epsilon=0.2, alpha = 0.05, verbose = TRUE)
Calculate Power for testing mediation effect in linear regression based on Vittinghoff, Sen and McCulloch's (2009) method.
powerMediation.VSMc(n, b2, sigma.m, sigma.e, corr.xm, alpha = 0.05, verbose = TRUE)
powerMediation.VSMc(n, b2, sigma.m, sigma.e, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
sigma.e |
standard deviation of the random error term in the linear regression
|
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Vittinghoff et al. (2009) showed that for the above linear regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
power |
power for testing if |
delta |
|
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc
,
ssMediation.VSMc
# example in section 3 (page 544) of Vittinghoff et al. (2009). # power=0.8 powerMediation.VSMc(n = 863, b2 = 0.1, sigma.m = 1, sigma.e = 1, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
# example in section 3 (page 544) of Vittinghoff et al. (2009). # power=0.8 powerMediation.VSMc(n = 863, b2 = 0.1, sigma.m = 1, sigma.e = 1, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
Calculate Power for testing mediation effect in cox regression based on Vittinghoff, Sen and McCulloch's (2009) method.
powerMediation.VSMc.cox(n, b2, sigma.m, psi, corr.xm, alpha = 0.05, verbose = TRUE)
powerMediation.VSMc.cox(n, b2, sigma.m, psi, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
psi |
the probability that an observation is uncensored, so that
the number of event |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the cox regressions:
where is the hazard function and
is the baseline hazard function.
Vittinghoff et al. (2009) showed that for the above cox regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
power |
power for testing if |
delta |
|
, where
is the standard deviation of the mediator
,
is the correlation between the predictor
and the mediator
, and
is
the probability that an observation is uncensored, so that
the number of event
, where
is the sample size.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.cox
,
ssMediation.VSMc.cox
# example in section 6 (page 547) of Vittinghoff et al. (2009). # power = 0.7999916 powerMediation.VSMc.cox(n = 1399, b2 = log(1.5), sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
# example in section 6 (page 547) of Vittinghoff et al. (2009). # power = 0.7999916 powerMediation.VSMc.cox(n = 1399, b2 = log(1.5), sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
Calculate Power for testing mediation effect in logistic regression based on Vittinghoff, Sen and McCulloch's (2009) method.
powerMediation.VSMc.logistic(n, b2, sigma.m, p, corr.xm, alpha = 0.05, verbose = TRUE)
powerMediation.VSMc.logistic(n, b2, sigma.m, p, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
p |
the marginal prevalence of the outcome. |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the logistic regressions:
Vittinghoff et al. (2009) showed that for the above logistic regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
power |
power for testing if |
delta |
|
, where
is the standard deviation of the mediator
,
is the correlation between the predictor
and the mediator
, and
is the marginal prevalence of the
outcome.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.logistic
,
ssMediation.VSMc.logistic
# example in section 4 (page 545) of Vittinghoff et al. (2009). # power = 0.8005793 powerMediation.VSMc.logistic(n = 255, b2 = log(1.5), sigma.m = 1, p = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# example in section 4 (page 545) of Vittinghoff et al. (2009). # power = 0.8005793 powerMediation.VSMc.logistic(n = 255, b2 = log(1.5), sigma.m = 1, p = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
Calculate Power for testing mediation effect in poisson regression based on Vittinghoff, Sen and McCulloch's (2009) method.
powerMediation.VSMc.poisson(n, b2, sigma.m, EY, corr.xm, alpha = 0.05, verbose = TRUE)
powerMediation.VSMc.poisson(n, b2, sigma.m, EY, corr.xm, alpha = 0.05, verbose = TRUE)
n |
sample size. |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
EY |
the marginal mean of the outcome. |
corr.xm |
correlation between the predictor |
alpha |
type I error rate. |
verbose |
logical. |
The power is for testing the null hypothesis
versus the alternative hypothesis
for the poisson regressions:
Vittinghoff et al. (2009) showed that for the above poisson regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
power |
power for testing if |
delta |
|
, where
is the standard deviation of the mediator
,
is the correlation between the predictor
and the mediator
, and
is the marginal mean of the
outcome.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.poisson
,
ssMediation.VSMc.poisson
# example in section 5 (page 546) of Vittinghoff et al. (2009). # power = 0.7998578 powerMediation.VSMc.poisson(n = 1239, b2 = log(1.35), sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# example in section 5 (page 546) of Vittinghoff et al. (2009). # power = 0.7998578 powerMediation.VSMc.poisson(n = 1239, b2 = log(1.35), sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
Power calculation for simple Poisson regression. Assume the predictor is normally distributed.
powerPoisson( beta0, beta1, mu.x1, sigma2.x1, mu.T = 1, phi = 1, alpha = 0.05, N = 50)
powerPoisson( beta0, beta1, mu.x1, sigma2.x1, mu.T = 1, phi = 1, alpha = 0.05, N = 50)
beta0 |
intercept |
beta1 |
slope |
mu.x1 |
mean of the predictor |
sigma2.x1 |
variance of the predictor |
mu.T |
mean exposure time |
phi |
a measure of over-dispersion |
alpha |
type I error rate |
N |
toal sample size |
The simple Poisson regression has the following form:
where
We are interested in testing the null hypothesis
versus the alternative hypothesis
.
Assume
is normally distributed with mean
and variance
.
The sample size calculation formula derived by Signorini (1991) is
where is the over-dispersion parameter
(
),
is the type I error rate,
is the estimate of the slope
,
is the intercept,
is the mean exposure time,
is the
-th lower percentile of
the standard normal distribution, and
is the variance of the estimate
given the true slope
.
The variances are
and
power
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu <[email protected]>
Signorini D.F. (1991). Sample size for Poisson regression. Biometrika. Vol.78. no.2, pp. 446-50
See Also as sizePoisson
# power = 0.8090542 print(powerPoisson( beta0 = 0.1, beta1 = 0.5, mu.x1 = 0, sigma2.x1 = 1, mu.T = 1, phi = 1, alpha = 0.05, N = 28))
# power = 0.8090542 print(powerPoisson( beta0 = 0.1, beta1 = 0.5, mu.x1 = 0, sigma2.x1 = 1, mu.T = 1, phi = 1, alpha = 0.05, N = 28))
Sample size calculation for simple Poisson regression. Assume the predictor is normally distributed. Two-sided test is used.
sizePoisson( beta0, beta1, mu.x1, sigma2.x1, mu.T = 1, phi = 1, alpha = 0.05, power = 0.8)
sizePoisson( beta0, beta1, mu.x1, sigma2.x1, mu.T = 1, phi = 1, alpha = 0.05, power = 0.8)
beta0 |
intercept |
beta1 |
slope |
mu.x1 |
mean of the predictor |
sigma2.x1 |
variance of the predictor |
mu.T |
mean exposure time |
phi |
a measure of over-dispersion |
alpha |
type I error rate |
power |
power |
The simple Poisson regression has the following form:
where
We are interested in testing the null hypothesis
versus the alternative hypothesis
.
Assume
is normally distributed with mean
and variance
.
The sample size calculation formula derived by Signorini (1991) is
where is the over-dispersion parameter
(
),
is the type I error rate,
is the estimate of the slope
,
is the intercept,
is the mean exposure time,
is the
-th lower percentile of
the standard normal distribution, and
is the variance of the estimate
given the true slope
.
The variances are
and
total sample size
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu <[email protected]>
Signorini D.F. (1991). Sample size for Poisson regression. Biometrika. Vol.78. no.2, pp. 446-50
See Also as powerPoisson
# sample size = 28 print(sizePoisson( beta0 = 0.1, beta1 = 0.5, mu.x1 = 0, sigma2.x1 = 1, mu.T = 1, phi = 1, alpha = 0.05, power = 0.8))
# sample size = 28 print(sizePoisson( beta0 = 0.1, beta1 = 0.5, mu.x1 = 0, sigma2.x1 = 1, mu.T = 1, phi = 1, alpha = 0.05, power = 0.8))
Calculate sample size for testing slope for simple linear regression.
ss.SLR(power, lambda.a, sigma.x, sigma.y, n.lower = 2.01, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
ss.SLR(power, lambda.a, sigma.x, sigma.y, n.lower = 2.01, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power for testing if |
lambda.a |
regression coefficient in the simple linear regression
|
sigma.x |
standard deviation of the predictor |
sigma.y |
marginal standard deviation of the outcome |
n.lower |
lower bound for the sample size. |
n.upper |
upper bound for the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the simple linear regressions:
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Dupont, W.D. and Plummer, W.D.. Power and Sample Size Calculations for Studies Involving Linear Regression. Controlled Clinical Trials. 1998;19:589-601.
minEffect.SLR
,
power.SLR
,
power.SLR.rho
,
ss.SLR.rho
.
ss.SLR(power=0.8, lambda.a=0.8, sigma.x=0.2, sigma.y=0.5, alpha = 0.05, verbose = TRUE)
ss.SLR(power=0.8, lambda.a=0.8, sigma.x=0.2, sigma.y=0.5, alpha = 0.05, verbose = TRUE)
Calculate sample size for testing slope for simple linear regression based on R2.
ss.SLR.rho(power, rho2, n.lower = 2.01, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
ss.SLR.rho(power, rho2, n.lower = 2.01, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power. |
rho2 |
square of the correlation between the outcome and the predictor. |
n.lower |
lower bound of the sample size. |
n.upper |
upper bound o the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the simple linear regressions:
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Dupont, W.D. and Plummer, W.D.. Power and Sample Size Calculations for Studies Involving Linear Regression. Controlled Clinical Trials. 1998;19:589-601.
minEffect.SLR
,
power.SLR
,
power.SLR.rho
,
ss.SLR
.
ss.SLR.rho(power=0.8, rho2=0.6, alpha = 0.05, verbose = TRUE)
ss.SLR.rho(power=0.8, rho2=0.6, alpha = 0.05, verbose = TRUE)
Calculating sample size for simple logistic regression with binary predictor.
SSizeLogisticBin(p1, p2, B, alpha = 0.05, power = 0.8)
SSizeLogisticBin(p1, p2, B, alpha = 0.05, power = 0.8)
p1 |
|
p2 |
|
B |
|
alpha |
Type I error rate. |
power |
power for testing if the odds ratio is equal to one. |
The logistic regression mode is
where ,
is the binary predictor,
,
,
, and
.
The sample size formula we used for testing if
, is Formula (2) in Hsieh et al. (1998):
where is the required total sample size and
is the
-th
percentile of the standard normal distribution.
total sample size required.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Hsieh, FY, Bloch, DA, and Larsen, MD. A SIMPLE METHOD OF SAMPLE SIZE CALCULATION FOR LINEAR AND LOGISTIC REGRESSION. Statistics in Medicine. 1998; 17:1623-1634.
## Example in Table I Design (Balanced design with high event rates) ## of Hsieh et al. (1998 ) ## the sample size is 1281 SSizeLogisticBin(p1 = 0.4, p2 = 0.5, B = 0.5, alpha = 0.05, power = 0.95)
## Example in Table I Design (Balanced design with high event rates) ## of Hsieh et al. (1998 ) ## the sample size is 1281 SSizeLogisticBin(p1 = 0.4, p2 = 0.5, B = 0.5, alpha = 0.05, power = 0.95)
Calculating sample size for simple logistic regression with continuous predictor.
SSizeLogisticCon(p1, OR, alpha = 0.05, power = 0.8)
SSizeLogisticCon(p1, OR, alpha = 0.05, power = 0.8)
p1 |
the event rate at the mean of the continuous predictor |
OR |
Expected odds ratio. |
alpha |
Type I error rate. |
power |
power for testing if the odds ratio is equal to one. |
The logistic regression mode is
where ,
is the continuous predictor, and
is the
the change in log odds for the difference between at the mean of
and at one SD above the mean.
The sample size formula we used for testing if
or equivalently
, is Formula (1) in Hsieh et al. (1998):
where is the required total sample size,
is the
odds ratio to be tested,
is the event rate at the mean
of the predictor
, and
is the
-th
percentile of the standard normal distribution.
total sample size required.
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Hsieh, FY, Bloch, DA, and Larsen, MD. A SIMPLE METHOD OF SAMPLE SIZE CALCULATION FOR LINEAR AND LOGISTIC REGRESSION. Statistics in Medicine. 1998; 17:1623-1634.
## Example in Table II Design (Balanced design (1)) of Hsieh et al. (1998 ) ## the sample size is 317 SSizeLogisticCon(p1 = 0.5, OR = exp(0.405), alpha = 0.05, power = 0.95)
## Example in Table II Design (Balanced design (1)) of Hsieh et al. (1998 ) ## the sample size is 317 SSizeLogisticCon(p1 = 0.5, OR = exp(0.405), alpha = 0.05, power = 0.95)
Sample size calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with 2 time point.
ssLong(es, rho = 0.5, alpha = 0.05, power = 0.8)
ssLong(es, rho = 0.5, alpha = 0.05, power = 0.8)
es |
effect size of the difference of mean change. |
rho |
correlation coefficient between baseline and follow-up values within a treatment group. |
alpha |
Type I error rate. |
power |
power for testing for difference of mean changes. |
The sample size formula is based on Equation 8.30 on page 335 of Rosner (2006).
where ,
,
is the mean change over time
in group 1,
is the mean change over time
in group 2,
is the variance of baseline values within a treatment group,
is the variance of follow-up values within a treatment group,
is the correlation coefficient between baseline and follow-up values within a treatment group,
and
is the u-th percentile of the standard normal distribution.
We wish to test .
When , then formula reduces to
where .
required sample size per group
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Rosner, B. Fundamentals of Biostatistics. Sixth edition. Thomson Brooks/Cole. 2006.
ssLongFull
, powerLong
,
powerLongFull
.
# Example 8.33 on page 336 of Rosner (2006) # n=85 ssLong(es=5/15, rho=0.7, alpha=0.05, power=0.8)
# Example 8.33 on page 336 of Rosner (2006) # n=85 ssLong(es=5/15, rho=0.7, alpha=0.05, power=0.8)
Sample size calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with more than 2 time points.
ssLong.multiTime(es, power, nn, sx2, rho = 0.5, alpha = 0.05)
ssLong.multiTime(es, power, nn, sx2, rho = 0.5, alpha = 0.05)
es |
effect size |
power |
power |
nn |
number of observations per subject |
sx2 |
within subject variance |
rho |
within subject correlation |
alpha |
type I error rate |
We are interested in comparing the slopes of the 2 groups and
:
where
and
The sample size calculation formula is (Equation on page 30 of Diggle et al. (1994)):
where ,
is the meaninful differnce of interest,
is the variance of the random error,
is the within-subject correlation, and
is the within-subject variance.
subject per group
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Diggle PJ, Liang KY, and Zeger SL (1994). Analysis of Longitundinal Data. page 30. Clarendon Press, Oxford
# subject per group = 196 ssLong.multiTime(es=0.5/10, power=0.8, nn=3, sx2=4.22, rho = 0.5, alpha=0.05)
# subject per group = 196 ssLong.multiTime(es=0.5/10, power=0.8, nn=3, sx2=4.22, rho = 0.5, alpha=0.05)
Sample size calculation for testing if mean changes for 2 groups are the same or not for longitudinal study with 2 time point.
ssLongFull(delta, sigma1, sigma2, rho = 0.5, alpha = 0.05, power = 0.8)
ssLongFull(delta, sigma1, sigma2, rho = 0.5, alpha = 0.05, power = 0.8)
delta |
absolute difference of the mean changes between the two groups: |
sigma1 |
the standard deviation of baseline values within a treatment group |
sigma2 |
the standard deviation of follow-up values within a treatment group |
rho |
correlation coefficient between baseline and follow-up values within a treatment group. |
alpha |
Type I error rate |
power |
power for testing for difference of mean changes. |
The sample size formula is based on Equation 8.30 on page 335 of Rosner (2006).
where ,
,
is the mean change over time
in group 1,
is the mean change over time
in group 2,
is the variance of baseline values within a treatment group,
is the variance of follow-up values within a treatment group,
is the correlation coefficient between baseline and follow-up values within a treatment group,
and
is the u-th percentile of the standard normal distribution.
We wish to test .
required sample size per group
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Rosner, B. Fundamentals of Biostatistics. Sixth edition. Thomson Brooks/Cole. 2006.
ssLong
, powerLong
,
powerLongFull
.
# Example 8.33 on page 336 of Rosner (2006) # n=85 ssLongFull(delta=5, sigma1=15, sigma2=15, rho=0.7, alpha=0.05, power=0.8)
# Example 8.33 on page 336 of Rosner (2006) # n=85 ssLongFull(delta=5, sigma1=15, sigma2=15, rho=0.7, alpha=0.05, power=0.8)
Calculate sample size for testing mediation effect based on Sobel's test.
ssMediation.Sobel(power, theta.1a, lambda.a, sigma.x, sigma.m, sigma.epsilon, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
ssMediation.Sobel(power, theta.1a, lambda.a, sigma.x, sigma.m, sigma.epsilon, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power of the test. |
theta.1a |
regression coefficient for the predictor in the linear regression linking
the predictor |
lambda.a |
regression coefficient for the mediator in the linear regression linking
the predictor |
sigma.x |
standard deviation of the predictor. |
sigma.m |
standard deviation of the mediator. |
sigma.epsilon |
standard deviation of the random error term
in the linear regression linking
the predictor |
n.lower |
lower bound of the sample size. |
n.upper |
upper bound of the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The sample size is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Test statistic is based on Sobel's (1982) test:
where is the estimated standard deviation
of the estimate
using multivariate
delta method:
and
is the
variance
of the estimate
, and
is the variance
of the estimate
,
is the variance of the
mediator
.
From the linear regression , we have the
relationship
. Hence, we can simply
the variance
to
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Sobel, M. E. Asymptotic confidence intervals for indirect effects in structural equation models. Sociological Methodology. 1982;13:290-312.
powerMediation.Sobel
,
testMediation.Sobel
ssMediation.Sobel(power=0.8, theta.1a=0.1701, lambda.a=0.1998, sigma.x=0.57, sigma.m=0.61, sigma.epsilon=0.2, alpha = 0.05, verbose = TRUE)
ssMediation.Sobel(power=0.8, theta.1a=0.1701, lambda.a=0.1998, sigma.x=0.57, sigma.m=0.61, sigma.epsilon=0.2, alpha = 0.05, verbose = TRUE)
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)
ssMediation.VSMc(power, b2, sigma.m, sigma.e, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power for testing |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
sigma.e |
standard deviation of the random error term in the linear regression
|
corr.xm |
correlation between the predictor |
n.lower |
lower bound for the sample size. |
n.upper |
upper bound for the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Vittinghoff et al. (2009) showed that for the above linear regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc
,
powerMediation.VSMc
# 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)
# 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)
Calculate sample size for testing mediation effect in cox regression based on Vittinghoff, Sen and McCulloch's (2009) method.
ssMediation.VSMc.cox(power, b2, sigma.m, psi, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose=TRUE)
ssMediation.VSMc.cox(power, b2, sigma.m, psi, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose=TRUE)
power |
power for testing |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
psi |
the probability that an observation is uncensored, so that
the number of event |
corr.xm |
correlation between the predictor |
n.lower |
lower bound for the sample size. |
n.upper |
upper bound for the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the cox regressions:
Vittinghoff et al. (2009) showed that for the above cox regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.cox
,
powerMediation.VSMc.cox
# example in section 6 (page 547) of Vittinghoff et al. (2009). # n = 1399 ssMediation.VSMc.cox(power = 0.7999916, b2 = log(1.5), sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
# example in section 6 (page 547) of Vittinghoff et al. (2009). # n = 1399 ssMediation.VSMc.cox(power = 0.7999916, b2 = log(1.5), sigma.m = sqrt(0.25 * (1 - 0.25)), psi = 0.2, corr.xm = 0.3, alpha = 0.05, verbose = TRUE)
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)
ssMediation.VSMc.logistic(power, b2, sigma.m, p, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power for testing |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
p |
the marginal prevalence of the outcome. |
corr.xm |
correlation between the predictor |
n.lower |
lower bound for the sample size. |
n.upper |
upper bound for the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the logistic regressions:
Vittinghoff et al. (2009) showed that for the above logistic regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.logistic
,
powerMediation.VSMc.logistic
# 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)
# 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)
Calculate sample size for testing mediation effect in poisson regression based on Vittinghoff, Sen and McCulloch's (2009) method.
ssMediation.VSMc.poisson(power, b2, sigma.m, EY, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
ssMediation.VSMc.poisson(power, b2, sigma.m, EY, corr.xm, n.lower = 1, n.upper = 1e+30, alpha = 0.05, verbose = TRUE)
power |
power for testing |
b2 |
regression coefficient for the mediator |
sigma.m |
standard deviation of the mediator. |
EY |
the marginal mean of the outcome. |
corr.xm |
correlation between the predictor |
n.lower |
lower bound for the sample size. |
n.upper |
upper bound for the sample size. |
alpha |
type I error rate. |
verbose |
logical. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the poisson regressions:
Vittinghoff et al. (2009) showed that for the above poisson regression, testing the mediation effect
is equivalent to testing the null hypothesis
versus the alternative 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.
n |
sample size. |
res.uniroot |
results of optimization to find the optimal sample size. |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Vittinghoff, E. and Sen, S. and McCulloch, C.E.. Sample size calculations for evaluating mediation. Statistics In Medicine. 2009;28:541-557.
minEffect.VSMc.poisson
,
powerMediation.VSMc.poisson
# example in section 5 (page 546) of Vittinghoff et al. (2009). # n = 1239 ssMediation.VSMc.poisson(power = 0.7998578, b2 = log(1.35), sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
# example in section 5 (page 546) of Vittinghoff et al. (2009). # n = 1239 ssMediation.VSMc.poisson(power = 0.7998578, b2 = log(1.35), sigma.m = sqrt(0.25 * (1 - 0.25)), EY = 0.5, corr.xm = 0.5, alpha = 0.05, verbose = TRUE)
Calculate p-value and confidence interval for testing mediation effect based on Sobel's test.
testMediation.Sobel(theta.1.hat, lambda.hat, sigma.theta1, sigma.lambda, alpha = 0.05)
testMediation.Sobel(theta.1.hat, lambda.hat, sigma.theta1, sigma.lambda, alpha = 0.05)
theta.1.hat |
estimated regression coefficient for the predictor in the linear regression linking
the predictor |
lambda.hat |
estimated regression coefficient for the mediator in the linear regression linking
the predictor |
sigma.theta1 |
standard deviation of |
sigma.lambda |
standard deviation of |
alpha |
significance level of a test. |
The test is for testing the null hypothesis
versus the alternative hypothesis
for the linear regressions:
Test statistic is based on Sobel's (1982) test:
where is the estimated standard deviation
of the estimate
using multivariate
delta method:
and
is the estimated standard deviation
of the estimate
, and
is the estimated standard deviation
of the estimate
.
pval |
p-value for testing the null hypothesis |
CI.low |
Lower bound of the |
CI.upp |
Upper bound of the |
The test is a two-sided test. For one-sided tests, please double the
significance level. For example, you can set alpha=0.10
to obtain one-sided test at 5% significance level.
Weiliang Qiu [email protected]
Sobel, M. E. Asymptotic confidence intervals for indirect effects in structural equation models. Sociological Methodology. 1982;13:290-312.
powerMediation.Sobel
,
ssMediation.Sobel
testMediation.Sobel(theta.1.hat=0.1701, lambda.hat=0.1998, sigma.theta1=0.01, sigma.lambda=0.02, alpha=0.05)
testMediation.Sobel(theta.1.hat=0.1701, lambda.hat=0.1998, sigma.theta1=0.01, sigma.lambda=0.02, alpha=0.05)