PUBH-310 · Lesson 3 of 12 · 22 min
Sampling and sample size
▶ Video coming soon A video version of this lesson is on the way.
Priya opened the planning meeting with a number. “Across the three hospitals, we have about 2,400 staff who started a new schedule assignment in the last ten years and had no diabetes at that time. Roughly 900 went onto rotating nights. Is that enough?” Tomás asked, “Enough for what?” Dr. Arkwright smiled. “That,” he said, “is exactly the right question. Enough to estimate what, with what precision, and to detect an effect of what size?”
This lesson covers two related tasks. Sampling is deciding who is studied, so that results apply to the population of interest. Sample size planning is deciding how many people are needed so that the study can answer its question with useful precision. Both are decided before data collection, and both appear in every protocol. The calculations are done with formulas or software, but the ideas behind them can be grasped with simple arithmetic, which is how this lesson presents them. The detailed statistics belong to *Biostatistics for Public Health* (PUBH-311).
Target population, source population and sample
Three populations need to be distinguished. The target population is the group to which the conclusions should apply: hospital shift workers in general, or in the region. The source population (or sampling frame) is the group from which participants are actually drawn: employees on the payroll of three Brannock Valley hospitals. The study sample is the people who end up with data. Differences between the target and source populations affect generalizability (external validity). Differences between the source population and the sample, if they are related to exposure and outcome, cause selection bias, which threatens internal validity and is the subject of lesson 8.
For a causal question, internal validity comes first. A study of nurses only, or of one hospital, can give a valid estimate of an effect even though it is not representative of all workers, as long as the comparison within the study is fair. The British Doctors Study and the Nurses’ Health Study were not representative of their national populations, yet their causal findings on smoking and many other exposures proved widely applicable, because biology does not usually differ greatly between doctors and other people. For a descriptive question, by contrast, representativeness is everything: a prevalence estimated in a non-representative sample may simply be wrong.
Probability sampling
When a study needs a representative sample, as most descriptive surveys do, it uses probability sampling, in which every member of the source population has a known, non-zero chance of selection. The main methods are:
- Simple random sampling: every person has an equal chance, like drawing names from a hat. It requires a complete list of the population.
- Systematic sampling: every kth person on a list, after a random start. It is simple in practice but can go wrong if the list has a periodic pattern.
- Stratified sampling: the population is divided into strata, such as hospitals or job types, and a random sample is drawn from each. It guarantees representation of each stratum and usually improves precision. Strata can be sampled in proportion to their size or oversampled, as national surveys do for small provinces, states or population groups, with weights used in analysis to restore the correct proportions.
- Cluster sampling: groups, such as hospital units, schools or neighbourhoods, are sampled first, and then all or some people within them. It is cheaper when no list of individuals exists or when travel is costly, but people within a cluster resemble each other, which reduces precision.
- Multistage sampling: combinations of the above, as in large national health surveys. The Canadian Community Health Survey, run by Statistics Canada, uses a multistage design with stratification by health region.
Non-probability sampling, such as convenience samples of volunteers or online panels, is quicker and cheaper but offers no guarantee that the sample resembles the population. It can be acceptable for causal questions within a well-defined group, or for qualitative work, but descriptive estimates from convenience samples should be treated with great caution.
The design effect
Cluster sampling reduces precision because people in the same cluster share characteristics. The reduction is summarized by the design effect (DEFF): the ratio of the variance of an estimate under the actual design to its variance under simple random sampling of the same size. For equal-sized clusters, a common approximation is DEFF = 1 + (m − 1) × ICC, where m is the number of people per cluster and the intracluster correlation coefficient (ICC) measures how similar people within a cluster are. Even a small ICC matters when clusters are large. With 20 people per hospital unit and an ICC of 0.05, the design effect is 1 + 19 × 0.05 = 1.95: the study needs almost twice as many people as a simple random sample would. Lesson 9 returns to this for cluster randomized trials.
Two kinds of sample size question
Sample size calculations answer one of two questions, depending on the study’s aim.
- Precision-based: how many people are needed to estimate a quantity (a prevalence, a mean, or a risk ratio) within a chosen margin of error? This suits descriptive studies and is increasingly preferred for causal studies too, because it focuses on estimation rather than testing.
- Power-based: how many people are needed to have a good chance of detecting an effect of a given size, if it exists, using a significance test? This is standard for randomized trials and common in observational studies.
Precision: estimating a prevalence
For a prevalence p, the margin of error of a 95 percent confidence interval from a simple random sample of size n is approximately 1.96 × √[p(1 − p) ÷ n]. Rearranging gives the sample size needed for a margin of error d: n = 1.96² × p(1 − p) ÷ d². Three practical points follow from this formula. Precision depends on the absolute number sampled, not on the fraction of the population sampled (unless the sample is a large share of a small population). Halving the margin of error requires four times as many people. And the formula needs a guess at p, which comes from previous studies; using 0.5 gives the largest, most conservative answer.
Worked problem
Sample size for a prevalence survey
The occupational health service wants to estimate the prevalence of prediabetes among hospital staff within plus or minus 3 percentage points (95 percent confidence). Earlier surveys suggest a prevalence of about 20 percent. The survey will sample hospital units as clusters, with an expected design effect of 1.5, and expects 80 percent of those invited to take part. How many staff should be invited?
Show solution
- Simple random sample size: n = 1.96² × 0.20 × 0.80 ÷ 0.03² = 3.8416 × 0.16 ÷ 0.0009 = 683.
- Adjust for clustering: 683 × 1.5 = 1,025.
- Adjust for non-response: 1,025 ÷ 0.80 = 1,281.
Answer: About 1,280 staff should be invited. Note that the non-response adjustment keeps precision but does nothing about non-response bias: if the 20 percent who decline differ from participants, the estimate may still be biased.
Power: comparing two groups
For a causal question, investigators usually plan to compare risks between exposed and unexposed groups. Four ingredients determine the sample size:
- The significance level (alpha), the probability of a false positive (type I error) if there is truly no effect, conventionally 0.05 two-sided.
- The power, the probability of detecting the effect if it truly exists, conventionally 80 or 90 percent. One minus power is the type II error rate (beta).
- The expected risk in the comparison group, taken from previous data.
- The smallest effect worth detecting, often called the minimal important difference: the risk in the exposed group, or the risk ratio, that would matter for practice or policy.
For two proportions p1 and p2 with equal groups, a standard approximation for the number per group is n = (z for alpha + z for power)² × [p1(1 − p1) + p2(1 − p2)] ÷ (p1 − p2)². For alpha 0.05 two-sided, the z value is 1.96; for 80 percent power it is 0.84, and for 90 percent power it is 1.28.
Worked problem
Sample size for comparing two risks
The eight-year risk of diabetes among day workers is expected to be 10 percent. The team wants 80 percent power, at a two-sided alpha of 0.05, to detect a risk of 15 percent among night workers (a risk ratio of 1.5). How many people per group are needed? How does the answer change with 90 percent power, or for a risk of 12.5 percent?
Show solution
- (1.96 + 0.84)² = 7.85. Variance term: 0.10 × 0.90 + 0.15 × 0.85 = 0.090 + 0.1275 = 0.2175. Difference squared: 0.05² = 0.0025.
- n per group = 7.85 × 0.2175 ÷ 0.0025 = about 683.
- With 90 percent power: (1.96 + 1.28)² = 10.5, so n = 10.5 × 0.2175 ÷ 0.0025 = about 914 per group.
- For 10 versus 12.5 percent: variance term 0.090 + 0.109 = 0.199; difference squared 0.000625; n = 7.85 × 0.199 ÷ 0.000625 = about 2,500 per group.
Answer: About 683 per group for 80 percent power to detect 10 versus 15 percent; about 914 for 90 percent power. Halving the difference to be detected (2.5 instead of 5 percentage points) almost quadruples the sample size, to about 2,500 per group.
Figure 1 shows the general pattern. Power rises steeply at first and then levels off, and the curve depends heavily on the size of the effect. With roughly 900 night workers and 1,500 day workers available, the Brannock study would have well over 80 percent power for a risk ratio of 1.5 but far less for a risk ratio of 1.25. Since meta-analyses suggested effects of roughly that smaller size, the team realized that their study, on its own, could estimate the effect only imprecisely. This fed directly into their decision to collaborate with other regions and to plan for their results to be pooled in future meta-analyses, as lesson 11 describes.
What else changes the sample size
Real studies need adjustments to the simple formulas:
- Unequal groups: with a ratio of k unexposed to each exposed person, the total sample increases, but adding controls beyond about four per case or per exposed person gives diminishing returns.
- Loss to follow-up: inflate the sample by the expected loss. If 15 percent may be lost, divide by 0.85.
- Confounder adjustment: adjusting for confounders that are correlated with the exposure inflates the variance; a rough correction divides the sample size by (1 − R²), where R² is the proportion of variation in exposure explained by the confounders.
- Clustering: multiply by the design effect.
- Case-control studies: the inputs are the proportion of controls exposed and the odds ratio to detect, rather than risks.
- Rates and time-to-event outcomes: what matters most is the number of events, not the number of people. A study of 10,000 people with 30 events is a small study.
The last point deserves emphasis. For rare outcomes, precision is driven almost entirely by the number of cases. In the Brannock cohort, with an eight-year risk of about 6 to 10 percent, 2,400 people would yield perhaps 150 to 240 cases. A useful rough rule is that the 95 percent confidence interval around a rate ratio is approximately the estimate multiplied and divided by exp(1.96 × √(1/a + 1/b)), where a and b are the numbers of cases in the two groups. With 70 cases among exposed and 90 among unexposed, √(1/70 + 1/90) = 0.159, and exp(1.96 × 0.159) = 1.37. An observed rate ratio of 1.3 would therefore have an interval of about 0.95 to 1.78: compatible with no effect or a large one.
Power after the fact, and studies that are “too small”
Two common practices are misguided. The first is calculating post hoc power after a study finds no significant result, using the observed effect size. This number is a direct function of the p-value and adds no information; the confidence interval already shows what effects the data are compatible with. The second is dismissing every small study as worthless. A small, well-conducted, unbiased study contributes to meta-analyses and can inform decisions, provided it is reported fully and interpreted through its confidence interval rather than its p-value. What should not be done is to run an underpowered study, find nothing, and conclude that there is no effect.
Writing the sample size section
Funders, ethics boards and journals expect a sample size justification that a reader could reproduce. It states the primary outcome, the expected comparison-group risk and its source, the effect size and why it matters, alpha and power (or the target precision), allowances for loss, clustering and confounder adjustment, and the resulting number. Where a fixed number of participants is available, as in the Brannock records, the section reports the precision or power that this number provides instead. The team wrote: “With approximately 900 exposed and 1,500 unexposed employees and an expected eight-year risk of 8 percent among day workers, the study will have about 87 percent power to detect a risk ratio of 1.5 and about 37 percent power to detect a risk ratio of 1.25 at a two-sided alpha of 0.05; we will therefore emphasize estimation with confidence intervals and contribute data to pooled analyses.”
Common mistakes
MistakeA sample must be a large fraction of the population to be precise.
InsteadPrecision depends mainly on the absolute sample size, not the sampling fraction.
MistakeInviting extra people to make up for non-response solves the non-response problem.
InsteadIt restores numbers but not representativeness; non-response bias may remain.
MistakeCluster samples give the same precision as simple random samples of the same size.
InsteadClustering reduces precision by the design effect, which can approach 2 or more even with small intracluster correlations.
MistakeA study with 10,000 participants is always large.
InsteadFor rare outcomes, precision depends on the number of events, which may be small.
MistakePost hoc power tells us whether a negative study was adequate.
InsteadLook at the confidence interval; post hoc power merely restates the p-value.
Summary and key terms
- Distinguish the target population, the source population and the study sample; selection affects internal validity, representativeness affects generalizability.
- Probability sampling (simple, systematic, stratified, cluster, multistage) gives each person a known chance of selection and is essential for descriptive estimates.
- Clustering inflates variance; the design effect is approximately 1 + (m − 1) × ICC.
- Precision-based calculations size a study to estimate a quantity within a margin of error; halving the margin quadruples the sample.
- Power-based calculations depend on alpha, power, the baseline risk and the smallest important effect; small effects need very large samples.
- Adjust for loss to follow-up, clustering, unequal groups and confounder adjustment; for rare outcomes, the number of events drives precision.
- Source population
- The population from which study participants are actually drawn.
- Probability sampling
- Sampling in which every member of the source population has a known, non-zero chance of selection.
- Design effect
- The ratio of the variance of an estimate under a complex design to its variance under simple random sampling.
- Intracluster correlation coefficient
- A measure of how similar individuals in the same cluster are, from 0 to 1.
- Power
- The probability that a study detects an effect of a given size if it truly exists.
- Type I error
- Concluding there is an effect when there is none; its probability is alpha.
- Type II error
- Failing to detect a real effect; its probability is beta, and power is 1 − beta.
- Minimal important difference
- The smallest effect size that would matter for practice or policy, used in sample size planning.
Practice problems
Work each problem on paper first, then reveal the answer to check.
How many people are needed to estimate a prevalence of about 10 percent within plus or minus 2 percentage points (95 percent confidence) using simple random sampling?
Show answer
n = 3.8416 × 0.10 × 0.90 ÷ 0.0004 = 864.
A survey samples 30 schools with 25 students each. The ICC for the outcome is 0.02. What is the design effect, and what is the effective sample size?
Show answer
DEFF = 1 + 24 × 0.02 = 1.48. Total sample 750; effective sample size 750 ÷ 1.48 = about 507.
A trial needs 400 per arm before allowing for 20 percent loss to follow-up. How many should be enrolled per arm?
Show answer
400 ÷ 0.80 = 500 per arm.
A cohort reports a rate ratio of 1.2 with 25 cases among exposed and 30 among unexposed. Roughly what is the 95 percent confidence interval?
Show answer
√(1/25 + 1/30) = √0.0733 = 0.271; exp(1.96 × 0.271) = 1.70. Interval ≈ 1.2 ÷ 1.70 to 1.2 × 1.70 = 0.71 to 2.04, a very imprecise estimate.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.