Site icon Codanics

Sample Size for Diagnostic & Survival Studies

Sample Size Calculator for Diagnostic and Survival Studies: free online tool by Codanics that runs in your browser
Epidemiology & clinical research

Sample Size for Diagnostic Accuracy and Survival Studies: Sensitivity, Specificity and Log-Rank (Schoenfeld, Freedman)

Plan the size of a diagnostic accuracy study or a time-to-event trial. For diagnostic studies, get the number of people needed to estimate sensitivity and specificity with a chosen precision (Buderer’s method), or to show that they exceed a minimum acceptable value. For survival studies, get the number of events needed to detect a hazard ratio with the log-rank test (Schoenfeld or Freedman), and the total sample size from accrual, follow-up, median survival and dropout.

✅ No login needed100% freeRuns in your browserYour data stays on your device
Sample Size Calculator for Diagnostic and Survival Studies✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Your data is analysed on your own computer or phone, even when you upload a CSV or Excel file. Nothing is uploaded, stored or seen by Codanics, and no login is needed.
  • PriceFree, no login or sign-up needed
  • Your dataProcessed in your browser, never uploaded
  • Works onPhone, tablet or computer, any modern browser
  • Made byDr. Muhammad Aammar Tufail, Codanics
  • Published17 November 2026
  • Last updated16 November 2026

📚 How to cite this tool

This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.

Citation · APA 7th edition

Tufail, M. A. (2026). Sample size for diagnostic accuracy and survival studies: sensitivity, specificity and log-rank [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/sample-size-diagnostic-survival/

In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)

The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the sample size calculator for diagnostic and survival studies

  1. Pick the tab that matches your study: estimating sensitivity and specificity with a given precision, testing them against a minimum acceptable value, or comparing survival between two groups.
  2. For diagnostic studies, enter the expected sensitivity and specificity (from a pilot study or the literature), the prevalence of the condition among the people you will recruit, and the margin of error or the minimum acceptable value.
  3. For survival studies, enter the hazard ratio you want to detect, α, power and the allocation ratio. Then give either the median survival in the control group with the accrual and follow-up periods, or the overall probability of an event.
  4. Add the expected dropout, read the number of events and participants, and copy the methods paragraph into your protocol or grant application.

Diagnostic accuracy: Buderer’s method

Sensitivity is estimated only from people who have the condition, and specificity only from people who do not. So the number of people you must recruit depends on the prevalence in your study sample. Buderer (1996) calculates how many diseased and non-diseased people are needed for the desired precision, then divides by the prevalence:

n(diseased) = z² × Se × (1 − Se) / d² N(for Se) = n(diseased) / prevalence n(non-diseased) = z² × Sp × (1 − Sp) / d² N(for Sp) = n(non-diseased) / (1 − prevalence) N = max(N for Se, N for Sp), then N / (1 − dropout)

For example, sensitivity 90% ± 5% with 95% confidence needs 139 people with the disease. If only 20% of those recruited have it, you must recruit 695 people. Rare conditions therefore need large studies, or a case-control (two-gate) design, which is cheaper but can overestimate accuracy.

Testing sensitivity or specificity against a minimum value

Regulatory and validation studies often need to show that sensitivity is at least a certain value, such as 80%. This is a one-sided test of a single proportion. The normal-approximation formula is shown with the exact binomial answer, which is preferred for proportions close to 100%:

n = [ z₁₋α √(p₀(1 − p₀)) + z₁₋β √(p₁(1 − p₁)) ]² / (p₁ − p₀)²

Survival studies: events drive power

In a time-to-event trial, statistical power depends on the number of events, not on the number of participants. A trial of 1,000 people with 50 deaths has little power. You first calculate the events needed, then the number of people who must be followed to observe that many events.

Schoenfeld: D = (z₁₋α/₂ + z₁₋β)² / ( p(1 − p) × (ln HR)² ), p = share allocated to one arm Freedman: D = (z₁₋α/₂ + z₁₋β)² × (1 + k·HR)² / ( k × (1 − HR)² ), k = allocation ratio N = D / P(event) Exponential model with uniform accrual over A and further follow-up F: P(event) = 1 − [e^(−λF) − e^(−λ(A + F))] / (λA), λ = ln 2 / median survival

Schoenfeld’s formula is the most widely used and is derived from the Cox model; Freedman’s gives slightly larger numbers. For HR = 0.7, α = 0.05 (two-sided) and 80% power with equal allocation, Schoenfeld gives 247 events and Freedman 253.

Checked against R. The Freedman totals agree with powerSurvEpi::ssizeCT.default() for the same event probabilities (within one or two participants, because this tool rounds the number of events up first), the Schoenfeld number of events matches the formula coded in R, and the exact binomial critical values, α and power match pbinom(). For the general sample size for means and proportions, use the sample size calculator.

References: Buderer NM (1996) Acad Emerg Med 3:895–900 · Flahault A, Cadilhac M, Thomas G (2005) J Clin Epidemiol 58:859–862 · Schoenfeld DA (1983) Biometrics 39:499–503 · Freedman LS (1982) Stat Med 1:121–129 · Collett D (2015) Modelling Survival Data in Medical Research, 3rd ed.

Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

How do I calculate the sample size for a diagnostic accuracy study?

Decide the expected sensitivity and specificity, the precision you want (for example ± 5%) and the prevalence in your sample. The number of diseased people needed is z²·Se(1−Se)/d², divided by the prevalence to get the total. The same is done for specificity, and the larger total is used (Buderer’s method).

Why does prevalence matter so much?

Sensitivity is estimated only from people with the condition. If only 5% of recruits have it, you need 20 recruits for each diseased person, so the total grows quickly when the condition is rare.

How many events do I need for a survival study?

With equal groups, α = 0.05 and 80% power, Schoenfeld’s formula gives about 247 events for HR = 0.7, 88 for HR = 0.55 and 631 for HR = 0.8. The number of participants is then the events divided by the probability that a participant has an event during the study.

Should I use Schoenfeld or Freedman?

Both are accepted. Schoenfeld is the most common in protocols and is based on the Cox model. Freedman gives slightly more events. Report which one you used.

What hazard ratio should I plan for?

Use the smallest effect that would change practice, informed by previous trials or pilot data. Overly optimistic hazard ratios are a common reason why trials fail to show a difference.

Does this tool handle non-inferiority or cluster trials?

No. It covers superiority log-rank comparisons and single-proportion diagnostic designs. Non-inferiority, cluster and comparative diagnostic designs need further adjustments.

Do I need to log in or create an account to use the sample size calculator for diagnostic and survival studies?

No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.

How do I cite this tool in my thesis or paper?

Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Sample size for diagnostic accuracy and survival studies: sensitivity, specificity and log-rank [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/sample-size-diagnostic-survival/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.

Free guides and courses from Codanics

More free tools

See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 17 November 2026, last updated 16 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.
Exit mobile version