Tutorials › Introduction to Statistics › Planning Sample Size for a Mean Test

Errors, Power and Sample Size · Tutorial 683 of 996

Planning Sample Size for a Mean Test

Plan the sample size for a one-sample mean test by connecting the effect you want to detect with variability, significance level, and target power.

Intermediate 10 min read

What You'll Learn

  • Identify the planning inputs for a one-sample mean test.
  • Calculate an approximate sample size for a two-sided or one-sided test.
  • Round a calculated sample size up and interpret it in context.
  • Check the assumptions behind a normal-based planning calculation.
  • Distinguish approximate planning from exact one-sample t-test power.

From a Meaningful Difference to a Sample Size

Before collecting data, a researcher needs to decide how many observations to obtain. For a one-sample mean test, that decision depends on the difference the study should be able to detect, the variability of individual observations, the significance level, and the desired power. A larger sample makes the sample mean more precise, but it also requires more time, participants, or resources.

The difference used in planning should be scientifically meaningful, not merely a value chosen because it produces a convenient sample size. For example, a clinician might decide that a change of 5 points on a symptom scale would matter to patients. The calculation then asks how many independent measurements are needed for a test to have a specified chance of detecting a true difference of that size.

Definition: For a one-sample mean test, let \(\mu_0\) be the mean specified by the null hypothesis and let \(\mu_1\) be a particular alternative mean of interest. The planned difference is \(\delta=|\mu_1-\mu_0|\). The target power is the probability of rejecting \(H_0\) when the population mean is \(\mu_1\). A planning calculation uses a significance level \(\alpha\), a target power \(1-\beta\), and an estimate of the population standard deviation \(\sigma\).

The standard deviation estimate should come from relevant prior information, such as earlier measurements taken in a similar population using the same scale. It describes the spread of individual observations, not the spread of the sample mean. The calculation uses it together with the planned difference to determine how many observations are needed.

The Normal-Based Planning Formula

Suppose observations are independent and come from a population with standard deviation \(\sigma\). If \(\sigma\) is known and the population is normal, the sample mean has distribution \(\bar{x}\sim N(\mu,\sigma^2/n)\). With a sufficiently large sample, this normal model for the sample mean can also be a useful approximation under less restrictive population shapes. For planning, \(\sigma\) is usually an estimate rather than a known value.

Write \(z_q\) for the \(q\)-quantile of the standard normal distribution, so that \(P(Z\le z_q)=q\) when \(Z\sim N(0,1)\). For a two-sided test of \(H_0:\mu=\mu_0\) against \(H_a:\mu\ne\mu_0\), the approximate required sample size is:

$$ n \approx \left(\frac{(z_{1-\alpha/2}+z_{1-\beta})\sigma}{\delta}\right)^2 $$

For a one-sided test, the corresponding approximation is:

$$ n \approx \left(\frac{(z_{1-\alpha}+z_{1-\beta})\sigma}{\delta}\right)^2 $$

In either case, round the result up to the next whole number. A sample cannot contain a fraction of an observation, and rounding down could leave the planned power below its target. The two-sided formula uses a more extreme critical value because the rejection region is split between both tails.

Why the Formula Works

The formula follows by expressing the test statistic in standard deviation units under the alternative mean. For a two-sided z test with \(\sigma\) known, reject \(H_0\) when the absolute value of the test statistic exceeds \(z_{1-\alpha/2}\). If \(\mu_1>\mu_0\), the test statistic has a standard normal distribution shifted to the right by \(\lambda=\delta\sqrt{n}/\sigma\). Its power is therefore:

$$ P(Z>z_{1-\alpha/2}-\lambda)+P(Z<-z_{1-\alpha/2}-\lambda) $$

For a positive shift, the second probability is often small at the design effect of interest. The first term reaches the target power \(1-\beta\) when \(z_{1-\alpha/2}-\lambda=-z_{1-\beta}\). Solving this equation gives \(\lambda=z_{1-\alpha/2}+z_{1-\beta}\). Substituting \(\lambda=\delta\sqrt{n}/\sigma\) and squaring both sides gives the two-sided planning formula. The one-sided formula follows by replacing the two-sided critical value with \(z_{1-\alpha}\).

This derivation also shows what drives sample size: the effect relative to the standard deviation, \(\delta/\sigma\). When the meaningful difference is small compared with the spread of individual measurements, a larger sample is needed. The formula is an approximation, especially for small samples and for tests that estimate \(\sigma\) from the same data.

Worked Example: A Two-Sided Test of Mean Symptom Change

A researcher plans to test whether the mean symptom score after a program differs from a reference value of 50 points. A difference of 5 points in either direction would be scientifically meaningful. Relevant prior data suggest a standard deviation of 12 points. The researcher wants a two-sided test with \(\alpha=0.05\) and 90% power. Find the approximate sample size.

The test is \(H_0:\mu=50\) against \(H_a:\mu\ne50\). Here \(\delta=5\) points, \(\sigma=12\) points, and \(1-\beta=0.90\). The required normal quantiles are \(z_{0.975}=1.960\) and \(z_{0.90}=1.282\). The independence and variability assumptions should be plausible for the planned measurements; in particular, the standard deviation estimate must apply to this population and score.

Substitute these values into the two-sided formula:

$$ n \approx \left(\frac{(1.960+1.282)(12)}{5}\right)^2 =\left(\frac{38.904}{5}\right)^2 =(7.7808)^2 \approx 60.54 $$

Rounding up gives \(n=61\). Under the planning assumptions and normal approximation, 61 independent measurements provide about 90% power to detect a true mean difference of 5 points using the specified two-sided test. This is not a guarantee that the study will detect the difference; it is a design probability conditional on that difference and the assumed standard deviation.

Choosing the Test Direction and Applying the Plan

The one-sided formula is appropriate only when the scientific question and test direction are fixed before examining the results. A one-sided test puts the full significance level in one tail, so it can require fewer observations for a specified effect in that direction. It does not provide the same test for a difference in the opposite direction. Choosing a one-sided test after seeing which way the sample mean moved would invalidate the stated error rate.

Worked Example: Detecting a Planned Decrease

A team evaluates whether a treatment lowers mean resting heart rate from a reference of 72 beats per minute. A reduction of 3 beats per minute is the smallest decrease considered important. A relevant standard deviation estimate is 8 beats per minute. The team plans a one-sided test with \(H_0:\mu=72\), \(H_a:\mu<72\), \(\alpha=0.05\), and 80% power. Estimate the required sample size.

The planned alternative is \(\mu_1=69\), so the difference in the prespecified direction has magnitude \(\delta=3\) beats per minute. The data should consist of independent observations from the population of interest, and the estimate of 8 beats per minute should reflect the spread of individual heart-rate measurements. The relevant quantiles are \(z_{0.95}=1.645\) and \(z_{0.80}=0.842\).

Using the one-sided formula:

$$ n \approx \left(\frac{(1.645+0.842)(8)}{3}\right)^2 =\left(\frac{19.896}{3}\right)^2 =(6.632)^2 \approx 43.98 $$

Round up to \(n=44\). With these planning assumptions, 44 independent measurements give approximately 80% power to detect a true mean decrease of 3 beats per minute with the specified lower-tailed test. This design does not target the same power for detecting an increase.

Planning When the Standard Deviation Is Estimated

In many mean tests, the population standard deviation is unknown and the final analysis uses a one-sample t test. Its statistic is \(T=(\bar{x}-\mu_0)/(s/\sqrt{n})\), where \(s\) is the sample standard deviation. A standard normal calculation is then a planning approximation, not an exact t-test sample-size calculation. It is often a useful first calculation when the sample is not very small and a reasonable estimate of \(\sigma\) is available.

For an exact power calculation under a normal population, the t statistic under a specified alternative follows a noncentral t distribution with \(n-1\) degrees of freedom and noncentrality parameter \(\lambda=(\mu_1-\mu_0)\sqrt{n}/\sigma\). Because both the degrees of freedom and the noncentrality parameter depend on \(n\), the required sample size is typically found by checking candidate sample sizes numerically. For a two-sided test, power is the probability that this statistic falls below the negative t critical value or above the positive t critical value. A numerical t-based calculation can refine the normal-based estimate, particularly when the planned sample is small.

Worked Example: A More Stringent Two-Sided Design

A laboratory plans to test whether a mean measurement differs from a reference of 20 units. A difference of 2 units is the smallest one worth detecting, and a relevant pilot estimate of the standard deviation is 4.5 units. The lab chooses a two-sided significance level of 0.01 and target power of 90%. Find the normal-based planning estimate.

The planned difference is \(\delta=2\) units, \(\sigma=4.5\) units, \(\alpha=0.01\), and \(1-\beta=0.90\). The calculation assumes independent measurements and that the pilot standard deviation is relevant to the planned population and measurement process. For a two-sided test, \(z_{1-\alpha/2}=z_{0.995}=2.576\); for 90% power, \(z_{0.90}=1.282\).

$$ n \approx \left(\frac{(2.576+1.282)(4.5)}{2}\right)^2 =\left(\frac{17.361}{2}\right)^2 =(8.6805)^2 \approx 75.35 $$

The normal-based estimate is therefore \(n=76\) measurements after rounding up. This is an initial design estimate for a test at the 1% level, not an exact t-test result. If the planned analysis is a one-sample t test and the sample is modest, the researcher should refine the estimate using t-test power calculations under the stated normal-population model.

Common Planning Mistakes

  • Using an arbitrary difference. A sample-size calculation cannot decide which effect matters scientifically. Specify the smallest meaningful difference first, in the measurement's original units.
  • Using a standard error in place of a standard deviation. The formula takes the spread of individual observations. The standard error depends on sample size and is \(\sigma/\sqrt{n}\); it is not the input estimate for \(\sigma\).
  • Rounding down. If the calculation gives 60.54, a plan for 60 observations does not meet the calculated threshold. Round up to 61.
  • Switching to a one-sided test after seeing the data. The direction must be justified and chosen in advance. Otherwise, the stated significance level no longer describes the test as planned.
  • Treating an approximation as an exact guarantee. The result depends on the assumed variability, effect size, model, and test. A t-based refinement may be needed, and real data may differ from the planning assumptions.
Key takeaway: For a one-sample mean test, choose a meaningful difference and a defensible standard deviation estimate, specify the test direction, \(\alpha\), and target power, then calculate and round the sample size up. Treat a normal-based result as an approximation when the final analysis estimates the standard deviation.

Check Your Understanding

Answer each question using the planning principles in this tutorial.

  1. In a two-sided mean-test calculation, what does \(\delta\) represent, and why should it be chosen on scientific grounds?
  2. A calculation gives \(n=52.08\). What sample size should be planned, and why?
  3. Why is the standard deviation of individual measurements used instead of the standard error of the mean?
  4. When is a one-sided sample-size formula appropriate? What limitation does that choice impose?
  5. Why might a normal-based sample-size estimate need refinement when the planned analysis is a one-sample t test?