The log-rank test compares two time-to-event curves in full rather than at a single cut-off — the difference between "do these users churn more slowly?" and "how many had churned by day 30?". Plan the study in events, the currency this test actually spends, then get the chi-square statistic, the p-value and the hazard ratio.
The ratio of instantaneous event rates you want to be able to detect — 0.8 means arm 2's risk at any moment is four-fifths of arm 1's. It is not a difference in how many people eventually have the event, which over a fixed window is a much smaller number.
Arm 2 relative to arm 1. 0.80 is a 20% lower risk.
The fraction of patients randomised to arm 1, so 0.5 is even. Imbalance costs events: the required event count rises as the split moves away from half, and events are what power a survival comparison.
0.5 is an even split.
The chance a patient in arm 1 has the event before follow-up ends — not the rate per year, and not the rate over an indefinite horizon. It converts the event requirement into an enrolment: halve it and the events needed do not move while the recruitment roughly doubles.
Chance a patient has the event within follow-up.
The same probability for arm 2, over the same window. It should be broadly consistent with the hazard ratio above — a ratio of 0.8 against event probabilities that are identical is a contradiction the arithmetic will not flag for you.
Usually lower than arm 1 by roughly the hazard ratio.
The false-positive rate you agree to run. At α = 0.05 a comparison of two identical things still comes out significant one time in twenty, so lower it when acting on a wrong result is expensive, and split it across comparisons if you are going to run several. The 0.05 is a convention, not a property of your data.
The chance the test finds the effect if the effect is really there. At 0.80 you miss a real one in one study out of five; 0.90 is the usual choice when a miss is the expensive outcome, and costs roughly a third more data. Power is a property of the design — it cannot be recovered after the data is in.
Two-sided asks whether the two differ at all. One-sided asks only whether one beats the other: more sensitive for the same sample, but blind to the opposite result even when it is large. Choose it before the data, for a reason you could have written down in advance — switching afterwards halves the p-value you were about to report.
Required events, and the enrolment that produces them
Events (Schoenfeld)
631
Events (Freedman)A different approximation to the same distribution.
636
Schoenfeld, before rounding
630.52
Patients, arm 1
1,148
Patients, arm 2
1,148
Patients, totalA consequence of the event count, not the requirement.
2,296
Event probability per patientWeighted across the two arms by the allocation.
27.50%
The requirement is 636 events, not 2,296 patients. The patient count is only what it takes to produce those events at the 27.5% event rate you entered: halve that rate and the events needed do not move while the enrolment roughly doubles. Schoenfeld's formula asks for 631 events and Freedman's for 636; they are different approximations to the same distribution and they separate as the hazard ratio moves away from 1, so plan on the larger — 636. The levers that matter, in order, are the length of follow-up and the definition of the event — not the recruitment target.
Both formulas assume proportional hazards — that the ratio is the same at every point in follow-up. If the treatment acts only after a delay, or wears off, the log-rank test loses power and this sample size is optimistic.
Drag the dashed line — or focus it and use the arrow keys — to change hazard ratio to detect.
Show these numbers as a table
Required events against hazard ratio to detect
Hazard ratio to detect
Required events
0.40
38
0.46
52
0.51
71
0.57
99
0.63
143
0.68
215
0.74
342
0.79
596
0.85
1,212
0.91
3,348
How many events actually occurred in arm 1 — deaths, churns, failures. Censored patients are not events; they leave the risk set and are already accounted for in the expected counts.
What arm 1 would have contributed if both arms shared one survival curve, summed across every event time. It is not a number you can eyeball — it comes out of the survival analysis (R's survdiff prints it as “expected”), and it is fractional because each event time apportions one event by how many were still at risk in each arm.
Under the null, summed over the risk sets.
The event count for arm 2, over the same follow-up. Power lives in these totals rather than in the enrolment: a trial well short of its planned events has not produced a negative result, it has not produced a result.
Arm 2's expected contribution under the null. The two expected counts have to sum to the two observed ones — every event is expected somewhere — so a mismatch means one of the four numbers came from a different analysis or a different follow-up window.
ΣO and ΣE must match — every event is expected somewhere.
The false-positive rate you agree to run. At α = 0.05 a comparison of two identical things still comes out significant one time in twenty, so lower it when acting on a wrong result is expensive, and split it across comparisons if you are going to run several. The 0.05 is a convention, not a property of your data.
Log-rank test result
p-value
0.0258
Chi-squared
4.9679
Degrees of freedom
1
Hazard ratio (O/E)Arm 1 relative to arm 2, from the table itself.
1.3776
95% confidence interval
[1.041, 1.823]
Total observed events
196.000
Total expected events
196.000
The two survival curves differ somewhere over the follow-up you observed (p 0.0258, on 196 events). Somewhere is all the test says — not when, and not whether the gap persists; curves that separate early and rejoin later describe a delay rather than a durable improvement, and only the Kaplan–Meier plot distinguishes them. The observed-over-expected hazard ratio is 1.38, with the data consistent with anything from 1.04 to 1.82. Read that as a ratio of rates: at any moment, an arm-1 patient who has survived that long faces that multiple of the arm-2 patient's risk. It is not a difference in how many people eventually have the event, which over a fixed window is usually a much smaller number.
The hazard ratio here is the observed-over-expected estimate, which is the one a log-rank table supports. It is close to, but not the same as, the Cox model's maximum-likelihood estimate; where a study reports both, quote the Cox one.
A ratio of rates, not a difference in how many people eventually have the event.
Show these numbers as a table
The hazard ratio and its interval
Hazard ratio (arm 1 relative to arm 2)
Estimate
Interval
Hazard ratio
1.38
1.04 to 1.82
When to use it
Use the log-rank test when the outcome is how long something takes, not whether it happened by an arbitrary date. Time to churn, time to first purchase, how long a trial survives before converting or lapsing — all share a feature that breaks ordinary tests: when you analyse, most users have not had the event yet. Someone who signed up three days ago is not a non-churner but a churner-so-far, and this test handles that censoring natively rather than scoring it as a zero.
The usual alternative is to pick a horizon and compare two proportions — day-30 retention, say — with a chi-square test or the A/B test calculator. That is a fine test of a very specific question, and it throws away when the events happened. If one arm loses users in week one and the other the same number over eight weeks, the day-30 proportions are identical while the experience is not.
It tells you whether two curves differ, not how much or where. For a magnitude, fit a Cox proportional-hazards model — the log-rank test is its score test — or read the hazard ratio this page estimates from observed and expected counts. Three or more arms extend to a k−1 degree-of-freedom version, as one-way ANOVA extends a two-group comparison of means. If the question is how time-to-event relates to a continuous covariate, that is regression rather than a correlation test.
Assumptions
Two assumptions carry real weight here, and one of them decides whether the test can find anything at all:
Proportional hazards. The test is most powerful when one group's instantaneous risk is a constant multiple of the other's throughout. It stays valid when that fails but loses power badly, and in the worst case — curves that cross — an early advantage and a late disadvantage cancel, and the statistic comes back near zero on two obviously different populations.
Censoring independent of the outcome. Users still under observation must be no more and no less likely to churn than those observed longer. Product data breaks this routinely: someone who deletes the app stops generating the telemetry that would record their churn, and looks like a healthy censored user forever.
Both arms entered under the same conditions. Staggered entry is fine, but a treatment arm launched in December against a control running since August compares seasons as well as variants — the survival version of when allocation point and exposure point differ.
Independent subjects, one per randomised unit. Accounts with several seats, or a household sharing a subscription, are correlated and shrink the standard error in the usual way — see randomization: the ABCs of A/B testing.
Ties are handled approximately. Product event times are often recorded to the day, producing many simultaneous events. The hypergeometric variance below handles that, but very coarse timestamps erode this test's advantage over comparing proportions at a cut-off.
How the calculation works
At every distinct time an event occurs, the test compares how many events fell in group 1 with how many would be expected if the group label carried no information, given who is still at risk. Summing observed minus expected across those times gives one statistic, chi-square on one degree of freedom. The consequence that surprises people is that the sample-size tab asks for events, not subjects: those who never have the event contribute to the risk sets and almost nothing to the power. Doubling a cohort of users who never churn buys nothing.
Expected events at each event time
e₁ⱼ = dⱼ · n₁ⱼ / nⱼ
dⱼ events occur at time j among nⱼ subjects at risk, of whom n₁ⱼ are in group 1. Under the null, events split in proportion to the risk sets.
One degree of freedom. vⱼ is the hypergeometric variance, which is what makes tied event times correct rather than merely tolerable.
Hazard ratio from the same counts
HR ≈ (O₁/E₁) / (O₂/E₂)
The standard rough estimate. A Cox model gives a better one with a proper interval, but this comes free with the test.
Events required — Schoenfeld
e = (z₁₋α/₂ + z₁₋β)² / (p₁p₂(ln HR)²)
p₁ and p₂ are allocation proportions, so p₁p₂ = 0.25 for an even split and this reduces to 4(z₁₋α/₂ + z₁₋β)²/(ln HR)². The default here, and what most survival power software implements.
Events required — Freedman
e = (z₁₋α/₂ + z₁₋β)² (1 + r·HR)² / (r(1 − HR)²)
Shown alongside because the two disagree. At HR = 0.80 they are within about 1%; at HR = 0.40 Freedman asks for roughly 14% more events. Quoting whichever is smaller without saying which is how survival studies end up underpowered.
Subjects from events
n = e / P(event during follow-up)
The step everyone skips. If only 30% of users will have churned by the end of the window, you need more than three times as many subjects as events, and lengthening the window is often cheaper than recruiting more.
Worked example
A subscription product is testing a new onboarding sequence and expects it to slow churn rather than eliminate it. The hypothesis is a hazard ratio of 0.80 — a 20% lower instantaneous churn risk at any point in the first 90 days. About 30% of new subscribers historically cancel within 90 days, and the split is even. You want 80% power at the two-sided 5% level.
Hazard ratio to detect
0.80
Significance level (α)
0.05, two-sided
Power (1 − β)
0.80
Allocation ratio
1:1
Probability of event in the window
0.30 (90-day churn)
Follow-up
90 days, administrative censoring at the end
631 churn events under Schoenfeld, 636 under Freedman — the two essentially agree at this hazard ratio. At a 90-day churn rate near 30% that is roughly 2,100 subscribers in total, about 1,050 per arm, each followed for the full 90 days.
The 631 is the real requirement and the 2,100 is a consequence of it. Change nothing but the churn rate — run the same test on an enterprise tier where 90-day churn is 6% — and the events needed are unchanged while the subscribers needed rise to around 10,500. Power lives in the events, and a population that does not churn cannot supply them however many you enrol. The levers worth pulling are follow-up and event definition: extending the window to 180 days might take the event probability to 45% and cut the cohort by a third, at a cost in calendar time rather than traffic.
Interpreting the output
A small p-value says the two curves differ somewhere over the follow-up you observed. It does not say where, by how much, or that the difference persists. Always publish the two Kaplan–Meier curves next to it: curves that separate at week one and rejoin at week six describe a delay, not a retention improvement, and only the picture tells you which you bought.
The hazard ratio is the effect size, and it is a ratio of rates rather than a difference in outcomes. An HR of 0.80 means that at any moment a treated user is 20% less likely to churn than an otherwise-similar control who has survived as long. It does not mean 20% fewer people churn: over a fixed window it usually becomes a much smaller difference in the eventual proportion, and skipping that conversion reliably over-promises — the gap we describe in why the uplift in A/B tests often differs from real-world results.
A large p-value needs most care. Check the curves for crossing first: power against differences that reverse partway through is very poor, and a null on crossing curves is an artefact of the statistic rather than a finding about users. Check the event count too — 90 events against a design that needed 631 means the study is not yet readable.
Resist looking every week and stopping when it goes significant. Survival data accumulates continuously, which makes repeated inspection unusually tempting and unusually damaging. Use a group-sequential boundary with the looks planned in advance, as in navigating sequential testing, or fix the event count and read it once. Specifying a survival design before it runs is squarely what our causal inference work covers.
Frequently asked questions
Why does the sample size come back in events rather than users?
Because the information in a survival study lives entirely in the events. A subscriber who has not churned tells you only that they had not churned yet, which constrains the curve very little; a subscriber who churned on day 12 pins down a point on it. The statistic is a sum of observed-minus-expected terms taken at event times, so its variance is governed by how many event times there are. That is why enrolling twice as many users who never churn does nothing for power, and why the two effective levers are following people for longer and choosing a population or an event definition where events actually occur.
Should I use the Schoenfeld or the Freedman number?
Use Schoenfeld as the default, note Freedman, and if they disagree materially plan against the larger. Schoenfeld's formula comes from the score test of the Cox model and is what most survival software implements; Freedman's is derived directly from the log-rank statistic and is more conservative when the hazard ratio is far from one. Near a hazard ratio of 0.8 the two are within a percent of each other and the choice is immaterial. Around 0.4 the gap opens to roughly 14%, and at that point it is worth being explicit about which one your plan was built on, because a reviewer who recomputes it with the other formula will get a different answer.
What if the curves cross?
Then the log-rank test is the wrong instrument and will usually return a comfortable null on two populations that plainly differ, because the early excess of events in one arm is cancelled by the late excess in the other. Crossing is common in product data: a change that pushes people to decide faster produces more early churn and better long-run retention. If you expect it, plan for it — pre-specify a restricted mean survival time comparison, which measures the area between the curves and is interpretable in days, or a weighted test such as Fleming-Harrington that emphasises the period you care about. What you must not do is discover the crossing afterwards and pick whichever test gives the answer you like.
Does this apply outside clinical trials?
Yes, and the product applications are the ones we see most. Time to churn, time to first order, time to reactivation, how long a free trial lasts before conversion, how long a fixed bug stays fixed — all are time-to-event outcomes with heavy censoring, because most users are still in flight when you analyse. The vocabulary is medical for historical reasons: survival, hazard and censoring translate directly into retention, instantaneous churn risk and users whose story has not finished yet. The one thing that genuinely differs is that product data usually has much coarser event times, often rounded to the day, which produces many ties.
Why not just compare day-30 retention with a proportion test?
It is a legitimate test and sometimes the right one, particularly when day 30 is a contractual or commercial threshold that genuinely matters. Its costs are that it discards the timing of every event, so two very different churn patterns with the same 30-day total look identical; it discards everyone with less than 30 days of history, which on a growing product can be most of your users; and it is less powerful than the log-rank test when the hazards really are proportional. Use the proportion test when the horizon is the question, and the log-rank test when the shape of the curve is.
Can I adjust for covariates with a log-rank test?
Not directly — it compares groups and nothing else. You can stratify it, which fits a separate set of risk sets within each stratum and combines them, and that works well for a small number of categorical factors such as plan tier or acquisition channel. For anything more, move to a Cox proportional-hazards model, which accepts continuous covariates and returns an adjusted hazard ratio with a confidence interval. The log-rank test is the score test of exactly that model with a single binary predictor, so this is a generalisation rather than a change of method.
Retention questions are survival questions. We design them in events, follow-up and censoring rather than in a flat user count. Causal Inference Analysis
References
Schoenfeld, D. A. (1983). Sample-size formula for the proportional-hazards regression model. Biometrics, 39(2), 499-503.
Freedman, L. S. (1982). Tables of the number of patients required in clinical trials using the logrank test. Statistics in Medicine, 1(2), 121-129.
Collett, D. (2015). Modelling Survival Data in Medical Research (3rd ed.). Chapman & Hall/CRC.