Method document
Sample size to estimate a relative risk
How many participants are needed in each of two groups to estimate a relative risk within a chosen factor: an interval that runs from the estimate divided by that factor to the estimate multiplied by it. Covers unequal groups, finite populations, cluster sampling and non-response.
https://statwisely.com/methods/precision-relative-risk/
When to use it
- A cohort or cross-sectional study whose aim is to estimate how many times more likely an outcome is in one group than another.
- Comparisons whose objective is stated as a precision rather than a test.
Not for
- Case-control studies, where the relative risk cannot be estimated. Use the odds ratio.
- Showing that the relative risk differs from 1. Use a powered test under “Detect an effect”.
Notation
- Sample sizes of groups 1 and 2 (for example exposed and unexposed)
- Expected risk of the outcome in groups 1 and 2
- Allocation ratio n₂ / n₁
- Precision factor: the interval runs from RR / f to RR × f
- Number of groups, including the reference group
- Standard normal quantile for confidence 1 − α (1.960 for 95%)
- Population sizes of the two groups
- Design effect
- Intracluster correlation coefficient (ICC)
- Usable observations per cluster
- Number of clusters in each group
- Coefficient of variation of cluster size
- Low and high ends of the range of cluster values
- Non-response rate
Formulas
Simple random sampling
A relative risk is estimated on the log scale, where its interval is symmetric, so a margin of ln f there becomes a factor f on the ratio scale. The bracket is the large-sample variance of the log relative risk, per participant [1].
Several groups against a reference
Optional. With g groups, each of the g − 1 others is compared with the same reference group, giving g − 1 risk ratios. Each comparison has the two-group requirement n₁⁽ʲ⁾; every comparison group is given the largest, so all intervals reach the factor, and the reference group is n₂ = r_a n₁. Choosing simultaneous intervals splits α across the g − 1 comparisons (Bonferroni). A larger reference group serves every comparison at once. Cluster sampling is not offered with several groups, and a population size applies to each group.
Finite population correction
Applied to each group against its own population when population sizes are given [2]. It matters only when a group is a sizeable share of its population, and is not offered with cluster sampling.
Design effect from an ICC
For clusters of equal size [3]. A design effect can also be entered directly, in which case no ICC is used.
Unequal cluster sizes
When each cluster is given its own share s_j of the sample, the CV of those shares enlarges the design effect [4]. With a design effect entered directly the shares only divide the sample, since a measured design effect already reflects its survey’s cluster sizes.
Number of clusters for a chosen cluster size
Applied to each group separately, with distinct clusters in each. The requirement is rounded up to whole clusters, so the total can exceed n × DE slightly, and rounding can shift the allocation ratio a little.
Cluster size for a fixed number of clusters
Solving k·m = n·DE for m. Below that number of clusters no cluster size reaches the margin, because each extra person per cluster adds less and less information; the calculator reports the minimum number of clusters instead. With two groups, k clusters are taken in each.
ICC from a range across clusters
When no ICC is available: the range within which most clusters’ values are expected to fall is taken as about four between-cluster standard deviations, and the ICC is their share of the variance of the first group’s outcome, p₁(1 − p₁). An elicitation aid, not a measurement. With two groups, the range describes the first group’s clusters.
Few clusters
Optional. With few clusters the interval is built on k − 1 degrees of freedom, so the normal critical value is replaced by t. Because k depends on n, this is iterated until it settles.
Non-response
The number to approach in each group so that n respond. Applied last, after any clustering.
Parameters
Confidence level
Values: 90%, 95% or 99%
95% is the convention in health research. A higher level widens the interval, so the same margin needs a larger sample.
Precision factor
Values: Above 1; 1.5 means the interval runs from RR / 1.5 to RR × 1.5
A ratio is bounded multiplicatively, so its precision is a factor rather than a difference. Rare outcomes make the log relative risk very variable, so they need large samples for any given factor.
Expected risk in group 1
Values: Between 0 and 1
The share of group 1, for example the exposed, expected to have the outcome over the study period.
Expected risk in group 2
Values: Between 0 and 1
The share of group 2, for example the unexposed, expected to have the outcome; often known from routine data.
Allocation ratioOptional
Values: Above 0; 1 for equal groups
The planned size of group 2 divided by group 1. Equal groups give the most precision for a given total; use another ratio when one group is easier or cheaper to recruit.
Number of groups, including the referenceOptional
Values: A whole number of at least 2; 2 for one comparison
For example, three exposure levels compared with no exposure is g = 4.
Expected proportion in each comparison groupOptional
Values: g − 1 values between 0 and 1
The outcome expected in each group compared with the reference; the reference group’s own proportion is p₂.
Simultaneous intervals across comparisonsOptional
Values: On or off
Turn on when the comparisons will be read together, so that every interval holds at once.
Population sizesOptional
Values: Whole numbers of at least 2; leave the second empty if both groups come from populations of the same size
Leave empty for large populations. They matter only when a group would be more than about 5% of its population. Not available with cluster sampling.
Expected non-response rateOptional
Values: 0% up to, but not including, 100%
The share of people approached who will not take part; use the response rate of a comparable study. Approaching more people restores the number of respondents, not their representativeness: if non-responders differ, the estimate can still be biased.
Intracluster correlation (ICC)Optional
Values: From 0 to 1
The share of the outcome’s variation that lies between clusters. Published ICCs for health outcomes in primary-care and community clusters are mostly small, often below 0.05 [6], but depend on the outcome and the kind of cluster; prefer an estimate from a comparable study.
Range of values across clustersOptional
Values: Two values in the outcome’s units, the first below the second
An alternative to the ICC: the range within which you expect most clusters’ values to fall. It is converted to an ICC by the formula above.
Design effectOptional
Values: Above 0; usually between 1 and 3
An alternative to the ICC, when a previous study of the same design reports its design effect.
Observations per clusterOptional
Values: A whole number of at least 1
Usable responses per cluster. Larger clusters are cheaper to reach, but when the ICC is above zero each additional person in a cluster adds less information.
Number of clusters in each groupOptional
Values: A whole number of at least 2
Instead of a cluster size, when the clusters are fixed: the emirates of a country, the schools of a district. The calculator then finds the cluster size, or reports how many clusters the margin needs.
Share of the sample for each clusterOptional
Values: One positive value per cluster, on any scale
When clusters will contribute unequally, for example in proportion to their population. With an ICC, unequal shares enlarge the design effect [4].
Correction for few clustersOptional
Values: On or off
Uses t on k − 1 degrees of freedom instead of the normal distribution. Worth applying when there are few clusters, roughly fewer than 30.
Assumptions
- The two groups are independent random samples followed for the same period, and participants respond independently apart from the clustering specified.
- The relative risk is crude (unadjusted), and enough outcomes are expected in each group for the large-sample variance to apply.
- With clustering, the ICC is that of the binary outcome, the same in both groups.
- With cluster sampling: the two groups have distinct clusters, with the same ICC and cluster size in each; clusters are of equal size unless shares are given; the sampled clusters are a small fraction of all clusters; and the analysis accounts for the clustering, for example with survey-design standard errors [3, 5].
- Non-response is unrelated to the outcome.
Worked examples
Two equal groups
Expected risks 30% and 15%, factor 1.5: the variance term is 0.7/0.3 + 0.85/0.15 = 8.00, and (ln 1.5)² = 0.1644, so n₁ = 1.96² × 8.00 / 0.1644 = 186.9, rounded up to 187 per group.
Group 1: 187 · Group 2: 187 · Total: 374
Open this example in the calculatorProtocol statement
To estimate a relative risk with 95% confidence, to within a factor of 1.5 of the estimate, assuming expected proportions of 30% and 15% in the two groups, the required sample size is 187 participants per group, 374 in total. Calculated with StatWisely (statwisely.com) using: n₁ = z_(1-α/2)² × ((1-p₁)/p₁ + (1-p₂)/(r·p₂)) / ln(f)²; n₂ = r × n₁. These are planning estimates; confirm the final design with a qualified statistician.
Allowing for loss to follow-up
Expecting 20% not to provide an outcome: 187 / (1 − 0.20) = 233.8, so 234 are recruited in each group.
Group 1: 187 · Group 2: 187 · Total: 374 · To approach: 234 and 234
Open this example in the calculatorCluster sampling with an ICC
ICC 0.02 and 20 per cluster: DE = 1 + 19 × 0.02 = 1.38. Each group needs 187 × 1.38 = 258.1, so 13 clusters of 20 and 260 participants per group.
Group 1: 260 · Group 2: 260 · Total: 520
Open this example in the calculatorProtocol statement
To estimate a relative risk with 95% confidence, to within a factor of 1.5 of the estimate, assuming expected proportions of 30% and 15% in the two groups, 374 participants would be required under simple random sampling. Allowing for a design effect of 1.38 (ICC 0.02, 20 per cluster) for cluster sampling, the required sample size is 260 participants per group, 520 in total, in 13 clusters of 20 in each group. This assumes clusters of equal size, distinct between the two groups, with a negligible sampling fraction. Calculated with StatWisely (statwisely.com) using: n₁ = z_(1-α/2)² × ((1-p₁)/p₁ + (1-p₂)/(r·p₂)) / ln(f)²; n₂ = r × n₁; clustered: n x DE, DE = 1 + (m-1)ρ. These are planning estimates; confirm the final design with a qualified statistician.
Two exposure levels against no exposure
Outcomes of 30% and 40% in two exposed groups against 0.15 unexposed, factor 1.5, read together: the 30% comparison needs most, 0.7/0.3 + 0.85/0.15 = 8.00; with α split two ways z = 2.241, so n = 2.241² × 8.00 / (ln 1.5)² = 244.5, rounded up to 245 in each of the 3 groups.
245 per group · Total: 735
Open this example in the calculatorValidation
- Every worked example on this page is recomputed by the StatWisely engine whenever the software is built. If a number or formula here stopped matching the calculator, the release would be stopped until this document was corrected.
- An independent implementation in R recomputes this procedure, with and without cluster sampling, every night and before each production release, and the results are compared with the engine’s.
- The basic result agrees with the closed form: 1.96² × 8.00 / 0.1644 = 186.9, rounded up to 187 per group. In R, ceiling(qnorm(0.975)^2 * ((1-0.3)/0.3 + (1-0.15)/0.15) / log(1.5)^2) returns 187.
How to cite
StatWisely. Sample size to estimate a relative risk. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/precision-relative-risk/
Cite the original references for the formulas your design uses as well.
References
- 1.Katz D, Baptista J, Azen SP, Pike MC. Obtaining confidence intervals for the risk ratio in cohort studies. Biometrics. 1978;34(3):469–474.
- 2.Cochran WG. Sampling Techniques. 3rd ed. New York: John Wiley & Sons; 1977.
- 3.Kish L. Survey Sampling. New York: John Wiley & Sons; 1965.
- 4.Eldridge SM, Ashby D, Kerry S. Sample size for cluster randomized trials: effect of coefficient of variation of cluster size and analysis method. International Journal of Epidemiology. 2006;35(5):1292–1300. doi:10.1093/ije/dyl129
- 5.Donner A, Klar N. Design and Analysis of Cluster Randomization Trials in Health Research. London: Arnold; 2000.
- 6.Adams G, Gulliford MC, Ukoumunne OC, Eldridge S, Chinn S, Campbell MJ. Patterns of intra-cluster correlation from primary care research to inform study design and analysis. Journal of Clinical Epidemiology. 2004;57(8):785–794. doi:10.1016/j.jclinepi.2003.12.013