BiostatKit / Sample size / Sample size for survival
Sample Size Calculator for Survival Analysis
Find how many events and how many participants a survival comparison needs. Enter the hazard ratio you want to detect and the event-free proportion in the control group. You get the events, the participants, a sentence for your methods section, and the R code.
Your data never leaves your browser. No sign-up, no ads.Result
Events and participants for a two-group log-rank test.
Sentence for your manuscript
Written in AMA style from your numbers. Check it against your own study design before you submit.
Reporting checklist
- CONSORT 2010 (trials): explain how the sample size was determined (item 7a). For a time-to-event outcome give the hazard ratio, the number of events, the event rate in the control group, the significance level, the power and the allocation ratio.
- STROBE 2007 (cohort studies): explain how the study size was arrived at (item 10).
- Say where the hazard ratio and the control-group event rate came from, and the follow-up time they refer to.
Methods wording. The number of events and participants for a log-rank comparison was calculated with BiostatKit [1] using the sample-size formula of Schoenfeld [2].
[1] BiostatKit. Sample size calculator for survival analysis. Accessed [date]. [URL]
[2] Schoenfeld DA. Sample-size formula for the proportional-hazards regression model. Biometrics. 1983;39(2):499-503.
Reproduce it in R
The script is filled in with your numbers. Paste it into R or RStudio and compare.
This calculator was checked against an independent SciPy calculation on 2 reference cases and matched to 4 significant digits. See the verification log.
How the number of events and participants is worked out
What it is
In a survival comparison the power of the log-rank test depends mainly on the number of events (deaths, relapses, whatever you count), not on the number of participants. The participants are the number you must follow to see that many events.
How this page computes it
Events, Schoenfeld: d = (Z1-α/2 + Z1-β)² x (1 + k)² / ( k x [ln HR]² )
Events, Freedman: d = (Z1-α/2 + Z1-β)² x (1 + k x HR)² / ( k x (1 - HR)² )
With proportional hazards, the event-free proportion in the experimental group is Se = ScHR. The average probability of an event is P = (1 - Sc)/(1 + k) + (1 - Se) x k/(1 + k), and the participants are d / P, rounded up in each group.
Assumptions
- Proportional hazards: the hazard ratio is constant over follow-up.
- Every participant is followed for the same period, and the event-free proportions you enter refer to the end of it. There is no staggered entry in this model.
- A 2-sided log-rank test, one event type, no competing risks.
Common mistakes
- Reporting the participants without the events. The events are what the power rests on.
- Entering the hazard ratio the wrong way round. Here it is experimental over control.
- Ignoring recruitment time and dropouts over time. Longer follow-up or a higher event rate needs fewer participants, but the events needed stay the same.
- Using this when the survival curves are expected to cross. The log-rank test then loses power.
Frequently asked questions
Schoenfeld or Freedman?
Both give the number of events for the log-rank test. They agree when the hazard ratio is near 1. Freedman asks for somewhat more events when the hazard ratio is far from 1. Pick one, state it, and keep it.
What is the event-free proportion in the control group?
The share of control participants you expect to still be free of the event at the end of follow-up, for example 2-year progression-free survival. Take it from a published study or registry.
What if I only know the median survival?
With exponential survival the event-free proportion at time t is 0.5 raised to the power of t over the median. Work it out for your follow-up time and enter that.
Why does a hazard ratio of 1 give an error?
A hazard ratio of 1 means no difference, and no number of events can detect no difference. Enter the smallest hazard ratio that would matter clinically.
Is my data stored or sent anywhere?
No. All calculations run in your browser tab. Nothing is uploaded, and the page works offline once loaded.
Related calculators: Sample size: two means or two proportions · Sample size for a proportion