Sample Size, $n$

Power, $1-\beta$

Type I error rate, $\alpha$

X-axis

min

max

Documentation
Test 1 Mean
Compare 2 Means
Compare k Means
Test 1 Proportion
Compare 2 Proportions
Compare Paired Proportions
Compare k Proportions
Test Time-To-Event Data
Test Odds Ratio
Test Relative Incidence in Self Controlled Case Series Studies
Other

## Calculate Sample Size Needed to Other: 1-Sample Normal

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(\frac{\mu-\mu_0}{\sigma/\sqrt{n}}-z_{1-\alpha/2}\right)+\Phi\left(-\frac{\mu-\mu_0}{\sigma/\sqrt{n}}-z_{1-\alpha/2}\right)$$
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.