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 Test 1 Mean: 1-Sample, 1-Sided

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

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

or
$H_0:\mu=\mu_0$
$H_1:\mu\gt\mu_0$

### Formulas

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

### R Code

R code to implement these functions:

mu=115
mu0=120
sd=24
alpha=0.05
beta=0.20
(n=(sd*(qnorm(1-alpha)+qnorm(1-beta))/(mu-mu0))^2)
ceiling(n)# 143
z=(mu-mu0)/sd*sqrt(n)
(Power=pnorm(abs(z)-qnorm(1-alpha)))

### References

Rosner B. 2010. Fundamentals of Biostatistics. 7th Ed. Brooks/Cole. page 224 and 230.