Tutorials › Introduction to Statistics › Deriving Sample Size for a Target Power

Errors, Power and Sample Size · Tutorial 682 of 996

Deriving Sample Size for a Target Power

Learn to rearrange the one-sided z-test power equation and choose the smallest integer sample size that meets a target power.

Intermediate 10 min read

What You'll Learn

  • State the model and assumptions for a one-sided z test for a population mean.
  • Connect the rejection threshold to power at a specified alternative mean.
  • Rearrange the power condition to obtain the required sample size.
  • Use normal quantiles and round the calculated threshold up to an integer.
  • Check how the chosen sample size meets, or falls short of, the target power.

Why Derive Sample Size From Power?

A study planned around a mean difference needs enough observations to make that difference detectable with a chosen probability. The required number depends on the direction and size of the effect the study is designed to detect, the variability of individual observations, the significance level, and the target power. Deriving the sample-size formula makes those connections explicit and shows exactly why the final answer must be rounded up.

This tutorial considers a one-sided upper-tail z test for a population mean when the population standard deviation is known. The goal is to find the smallest whole-number sample size that gives at least a specified power at a particular alternative mean. The result is conditional on the model and planning values; it is not a guarantee that a future study will observe a significant result.

Model and Power Condition

Model and assumptions: Let \(X_1,\ldots,X_n\) be independent observations from a population with mean \(\mu\) and known standard deviation \(\sigma>0\). For an exact z-test calculation, assume the observations are normally distributed, so \(\bar{x}\sim N(\mu,\sigma^2/n)\). The test is specified as \(H_0:\mu\leq\mu_0\) versus \(H_a:\mu>\mu_0\), with significance level \(\alpha\). It rejects for a sufficiently large sample mean. The calculation plans power at the particular alternative \(\mu_1=\mu_0+\delta\), where \(\delta>0\) is the minimum relevant mean difference.

Independence and the specified distributional model justify the standard error \(\sigma/\sqrt{n}\) and the normal distribution used in the calculation. In some settings, a normal approximation for \(\bar{x}\) may be used instead of an exactly normal population, but that approximation must be reasonable for the planned sample size and population. The formula below treats \(\sigma\), \(\alpha\), and \(\delta\) as known planning inputs.

Write \(z_{1-\alpha}\) for the standard normal quantile with cumulative probability \(1-\alpha\), and \(z_{1-\beta}\) for the quantile with cumulative probability \(1-\beta\), where \(1-\beta\) is the target power. The upper-tail test rejects when its standardized statistic exceeds \(z_{1-\alpha}\):

$$ Z=\frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}}, \qquad \text{reject }H_0\text{ if }Z>z_{1-\alpha}. $$

At the planned alternative \(\mu_1=\mu_0+\delta\), the sample mean has distribution \(N(\mu_0+\delta,\sigma^2/n)\). Power is the probability of rejection when this alternative is true. Thus, it is the probability that the sample mean exceeds the rejection threshold, calculated under the alternative rather than under the null.

Deriving the Sample-Size Formula

The rejection condition can be written as a condition on \(\bar{x}\). Because \(\sigma/\sqrt{n}\) is positive, rearranging the inequality does not reverse its direction. The following steps use the normal model at the specified alternative.

1
Write the rejection threshold.
\(Z>z_{1-\alpha}\) is equivalent to \(\bar{x}>\mu_0+z_{1-\alpha}\sigma/\sqrt{n}\).
2
Calculate power under the alternative.
When \(\mu=\mu_0+\delta\), standardizing the threshold using the alternative distribution gives power \(\Phi(\delta\sqrt{n}/\sigma-z_{1-\alpha})\), where \(\Phi\) is the standard normal cumulative distribution function.
3
Require the target power.
Set \(\Phi(\delta\sqrt{n}/\sigma-z_{1-\alpha})\geq 1-\beta\). Since \(\Phi\) is increasing, applying its inverse gives \(\delta\sqrt{n}/\sigma-z_{1-\alpha}\geq z_{1-\beta}\).
4
Solve for \(n\).
For \(\delta>0\), \(\sigma>0\), and a target power greater than \(\alpha\), the right-hand side \(z_{1-\alpha}+z_{1-\beta}\) is positive. Squaring after isolating \(\sqrt{n}\) gives the sample-size threshold.
$$ \begin{aligned} \text{Power at }\mu_1 &=P\left(\bar{x}>\mu_0+z_{1-\alpha}\frac{\sigma}{\sqrt{n}} \;\middle|\;\mu=\mu_0+\delta\right)\\ &=\Phi\left(\frac{\delta\sqrt{n}}{\sigma}-z_{1-\alpha}\right). \end{aligned} $$
$$ \begin{aligned} \Phi\left(\frac{\delta\sqrt{n}}{\sigma}-z_{1-\alpha}\right) &\geq 1-\beta\\ \frac{\delta\sqrt{n}}{\sigma}-z_{1-\alpha} &\geq z_{1-\beta}\\ n &\geq \left(\frac{\sigma(z_{1-\alpha}+z_{1-\beta})}{\delta}\right)^2. \end{aligned} $$
Sample-size result: For an upper-tail one-sided z test of a mean with known population standard deviation, the smallest integer sample size that achieves target power \(1-\beta>\alpha\) at \(\mu_1=\mu_0+\delta\), with \(\delta>0\), is $$ n_{\min}= \left\lceil \left(\frac{\sigma(z_{1-\alpha}+z_{1-\beta})}{\delta}\right)^2 \right\rceil. $$ The ceiling symbol means round up to the next whole number if the threshold is not already an integer. Rounding to the nearest integer can produce a sample size that falls below the threshold.

This derivation shows why the formula is specific to the stated test and alternative. The critical value \(z_{1-\alpha}\) comes from the upper-tail rejection rule. The quantile \(z_{1-\beta}\) comes from requiring power \(1-\beta\) at the planned alternative. The difference \(\delta\) is the distance from the null boundary \(\mu_0\) to that alternative mean, not the standard deviation of the sample mean.

Worked Example: A Target Power of 90 Percent

Suppose a hypothetical test compares a population mean with \(\mu_0=50\) units using an upper-tail z test. The known population standard deviation is \(\sigma=10\) units. The study must have 90% power to detect a mean of 54 units, using \(\alpha=0.05\). Find the minimum sample size.

The model assumes independent normally distributed observations with known \(\sigma=10\) units. The specified direction is appropriate for the planned alternative \(54>50\), and the relevant difference is \(\delta=54-50=4\) units. For \(\alpha=0.05\), \(z_{1-\alpha}=1.6449\); for target power \(0.90\), \(z_{1-\beta}=z_{0.90}=1.2816\).

Substitute the planning values. The units of \(\sigma\) and \(\delta\) cancel, leaving a dimensionless sample-size threshold.

$$ \begin{aligned} n &\geq \left(\frac{10(1.6449+1.2816)}{4}\right)^2\\ &=\left(\frac{29.265}{4}\right)^2\\ &=(7.31625)^2\\ &\approx 53.53. \end{aligned} $$

The minimum whole-number sample size is therefore \(n_{\min}=54\). At \(n=53\), the sample size is below the derived threshold; at \(n=54\), it is above it. Under the stated model, the power at \(n=54\) is approximately \(\Phi(4\sqrt{54}/10-1.6449)=\Phi(1.2945)\), or about 0.902. This is at least the 0.90 target.

Worked Example: A More Stringent Significance Level

A hypothetical one-sided z test is planned to detect an increase of at least 5 units in a population mean. Assume independent normal observations and known population standard deviation \(\sigma=12\) units. The significance level is \(\alpha=0.01\), and the target power is 0.80. What sample size is required?

The planned increase gives \(\delta=5\) units. The stricter significance level has upper-tail critical value \(z_{0.99}=2.3263\), and the 0.80 target power gives \(z_{0.80}=0.8416\). Substitution yields:

$$ \begin{aligned} n &\geq \left(\frac{12(2.3263+0.8416)}{5}\right)^2\\ &=\left(\frac{38.0148}{5}\right)^2\\ &=(7.60296)^2\\ &\approx 57.805. \end{aligned} $$

The minimum integer sample size is \(n_{\min}=58\). As a check, using the displayed critical value, the power at 58 is \(\Phi(5\sqrt{58}/12-2.3263)\approx\Phi(0.8469)\approx0.8015\), just above 0.80. The sample-size threshold and the check refer to the same upper-tail test and the same planned difference of 5 units.

Worked Example: Rounding Up Near an Integer Boundary

Consider a hypothetical study using a one-sided z test to detect a mean increase of 3 units. Assume independent normally distributed observations, known \(\sigma=8\) units, \(\alpha=0.05\), and target power 0.95. Find the required integer sample size.

Here \(\delta=3\) units. Both quantiles are \(z_{0.95}=1.6449\). Keeping the displayed values throughout the arithmetic gives:

$$ \begin{aligned} n &\geq \left(\frac{8(1.6449+1.6449)}{3}\right)^2\\ &=\left(\frac{26.3184}{3}\right)^2\\ &=(8.7728)^2\\ &\approx 76.962. \end{aligned} $$

Although the threshold is close to 77, it is below 77, so the smallest integer that meets it is \(n_{\min}=77\). For confirmation, the power at 77 is \(\Phi(3\sqrt{77}/8-1.6449)\approx\Phi(1.64571)\approx0.9501\). Using 76 observations would not meet the target: the power is approximately \(\Phi(3\sqrt{76}/8-1.6449)\approx0.9478\). This example illustrates why the ceiling rule, not ordinary rounding, determines the answer.

What the Result Does and Does Not Say

The formula gives a minimum sample size for a particular model, test, significance level, target power, and alternative difference. It does not say that every study with that sample size will reject the null hypothesis. Rather, if the model and inputs hold, repeated samples of that size would reject at the stated long-run proportion when the true mean equals the specified alternative.

The planned difference \(\delta\) should be chosen in the context of the question. It represents the smallest mean difference the study is designed to detect with the target power. A test can have high power for a larger difference and lower power for a smaller one. Thus, a calculation is only as meaningful as its stated alternative and measurement units.

The calculation also assumes the test is one-sided in the direction selected before examining the data. If the scientific question concerns departures in either direction, this upper-tail formula does not describe the required test. Changing the test changes its rejection threshold and therefore changes the power condition.

Common Mistakes

  • Rounding to the nearest integer. A threshold of 57.805 does not call for 58 merely because it is near 58; it calls for 58 because 57 is below the threshold and 58 is the smallest whole number that meets it.
  • Using the wrong alternative difference. In the formula, \(\delta\) is the difference between the planned alternative mean and the null boundary. It is not \(\mu_1\) itself.
  • Using a two-sided critical value. This derivation uses the upper-tail critical value \(z_{1-\alpha}\). A two-sided test has a different rejection rule and does not use this formula unchanged.
  • Treating power as certainty. A planned power of 0.80 does not mean the study will certainly detect the effect. It means the rejection probability is 0.80 under the model when the true mean equals the specified alternative.
  • Ignoring the known-\(\sigma\) assumption. The derivation uses \(\sigma/\sqrt{n}\) and a standard normal statistic. It is not automatically the sample-size formula for a test that estimates the standard deviation from the data.
Key takeaway: For a one-sided upper-tail z test of a mean, require \(\Phi(\delta\sqrt{n}/\sigma-z_{1-\alpha})\geq1-\beta\), solve for \(n\), and round the resulting threshold up. State the assumed model and the planned difference before interpreting the answer.

Check Your Understanding

Try these questions using the definitions and derivation above.

  1. In the sample-size formula, what does \(\delta\) represent, and why must it be positive for the upper-tail test described here?
  2. For \(\alpha=0.05\) and target power 0.90, identify the two normal quantiles used in the formula and explain what each one represents.
  3. A calculation gives a threshold of 41.02. What is the minimum whole-number sample size, and why is 41 insufficient?
  4. Explain why increasing the planned minimum relevant difference changes the calculated sample-size threshold, holding the other inputs fixed.
  5. What model assumption allows the exact normal power calculation when \(\sigma\) is known?