Menu

Inputs

Group B Sample Size (nB): 170

Total Sample Size (N): 255

Calculate Sample Size for Comparing 2 Means: 1-Sided

This calculator is useful for the tests concerning whether the means of two groups are different. Suppose the two groups are 'A' and 'B', and we collect a sample from both groups -- i.e. we have two samples. We perform a two-sample test to determine whether the mean in group A, μA\mu_A, is different from the mean in group B, μB\mu_B. The hypotheses are:
H0:μA=μBH1:μA>μBH_0: \mu_A = \mu_B \\ H_1: \mu_A > \mu_B
or
H0:μA=μBH1:μA<μBH_0: \mu_A = \mu_B \\ H_1: \mu_A < \mu_B
where the ratio between the sample sizes of the two groups is κ=nB/nA\kappa = n_B/n_A

Formulas

This calculator uses the following formulas to compute sample size and power, respectively:
nA=(σA2+σB2κ)(z1α+z1βμAμB)2n_A = (\sigma_A^2 + \frac{\sigma_B^2}{\kappa}) \left( \frac{z_{1-\alpha} + z_{1-\beta}}{\mu_A - \mu_B} \right)^2
nB=κnAn_B = \kappa \cdot n_A
1β=Φ(μAμBnAσA2+σB2/κz1α)1-\beta = \Phi\left( \frac{|\mu_A - \mu_B|\sqrt{n_A}}{\sqrt{\sigma_A^2 + \sigma_B^2/\kappa}} - z_{1-\alpha} \right)
where: - κ=nB/nA\kappa = n_B/n_A is the matching ratio - σA\sigma_A and σB\sigma_B are standard deviations of group A and B - Φ\Phi is the standard Normal distribution function - Φ1\Phi^{-1} is the standard Normal quantile function - α\alpha is Type I error - β\beta is Type II error, meaning 1β1-\beta is power

R Code

1muA <- 132.86
2muB <- 127.44
3sdA <- 15.34
4sdB <- 18.23
5kappa <- 2
6alpha <- 0.05
7beta <- 0.20
8nA <- (sdA^2 + sdB^2/kappa) * ((qnorm(1 - alpha) + qnorm(1 - beta)) / (muA - muB))^2
9ceiling(nA) # 85
10nB <- kappa * nA
11ceiling(nB) # 170
12z <- (muA - muB) / sqrt(sdA^2/nA + sdB^2/nB)
13(Power <- pnorm(z - qnorm(1 - alpha)))

References

Chow S, Shao J, Wang H. 2008. Sample Size Calculations in Clinical Research. 2nd Ed. Chapman & Hall/CRC Biostatistics Series. page 58.

Rosner B. 2010. Fundamentals of Biostatistics. 7th Ed. Brooks/Cole. page 302 and 303.