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, , is different from the mean in group B, . The hypotheses are:
or
where the ratio between the sample sizes of the two groups is
Formulas
This calculator uses the following formulas to compute sample size and power, respectively:
where:
- is the matching ratio
- and are standard deviations of group A and B
- is the standard Normal distribution function
- is the standard Normal quantile function
- is Type I error
- is Type II error, meaning 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.