Sample Size, $n$

Power, $1-\beta$

Type I error rate, $\alpha$



X-axis

min

max


Calculate Sample Size Needed to Test 1 Mean: 1-Sample, 2-Sided Equality


This calculator is useful for tests concerning whether a mean, $\mu$, is equal to a reference value, $\mu_0$. The Null and Alternative hypotheses are

$H_0:\mu=\mu_0$
$H_1:\mu\neq\mu_0$

Formulas

This calculator uses the following formulas to compute sample size and power, respectively: $$n=\left(\sigma\frac{z_{1-\alpha/2}+z_{1-\beta}}{\mu-\mu_0}\right)^2$$
$$1-\beta= \Phi\left(z-z_{1-\alpha/2}\right)+\Phi\left(-z-z_{1-\alpha/2}\right) \quad ,\quad z=\frac{\mu-\mu_0}{\sigma/\sqrt{n}}$$
where

R Code

R code to implement these functions:

mu=2
mu0=1.5
sd=1
alpha=0.05
beta=0.20
(n=(sd*(qnorm(1-alpha/2)+qnorm(1-beta))/(mu-mu0))^2)
ceiling(n)# 32
z=(mu-mu0)/sd*sqrt(n)
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-alpha/2)))

References

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

Rosner B. 2010. Fundamentals of Biostatistics. 7th Ed. Brooks/Cole. page 232.