Menu

Inputs

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, μ0\mu_0. The Null and Alternative hypotheses are either:
H0:μ=μ0H1:μ<μ0H_0: \mu = \mu_0 \\ H_1: \mu < \mu_0
or
H0:μ=μ0H1:μ>μ0H_0: \mu = \mu_0 \\ H_1: \mu > \mu_0

Formulas

This calculator uses the following formulas to compute sample size and power, respectively:
n=(σz1α+z1βμμ0)2n = \left( \sigma\frac{z_{1-\alpha} + z_{1-\beta}}{\mu - \mu_0} \right)^2
1β=Φ(μμ0σ/nz1α)1-\beta = \Phi\left( \frac{|\mu - \mu_0|}{\sigma / \sqrt{n}} - z_{1-\alpha} \right)
where: nn is sample size σ\sigma is standard deviation Φ\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

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

References

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