How this calculation works
The log-rank test compares event timing between groups while preserving information from right-censored observations. At each pooled event time, the expected event count in a group is proportional to its share of the risk set immediately before that time. The calculator adds observed-minus-expected counts and their hypergeometric covariance, then forms a joint chi-square statistic. A censored observation contributes to risk sets until its censoring time but never contributes an event. The procedure compares survival distributions; it does not estimate a treatment effect or replace the need to inspect the curves.
U=Σₜ(Oₜ−Eₜ); χ²=U_reducedᵀ V_reduced⁻¹ U_reduced with g−1 degrees of freedom.A worked example
Group one has an event at time one, an event at time two and censoring at time three. Group two has events at times two and four and censoring at time five. At time one all six people are at risk, with one event, so each group expects half an event. At time two five remain at risk: two from group one and three from group two. The two tied events therefore have expected counts 0.8 and 1.2. At time four only group two remains at risk, so its event adds no between-group contrast. The resulting chi-square is 49/61, approximately 0.803279.
Good to know
4–500 nonnegative time/event/group rows, with 2–6 independent groups. Right censoring only; censoring is assumed noninformative within groups. Tied events use pooled hypergeometric covariance and time>=event-time risk membership. Singular reduced covariance raises an error. No delayed entry, left truncation, competing-risk adjustment, weights, hazard ratio, proportional-hazards fit or clinical interpretation. Chi-square calibration is approximate and can be unreliable with very sparse event information.
Reference: Statsmodels — log-rank survival comparison (opens in a new tab) ↗
Censoring changes who is at risk without creating an event
A person with no observed event before follow-up ends is right censored, not known to have survived forever. Their event-free observation contributes up to the last known time. At a tied event/censoring time, this page counts everyone whose recorded time is at least the event time in the risk set, then allocates observed events. The convention is explicit so another implementation using a different ordering rule can be compared correctly.
At each pooled event time the total event count is fixed, and group event counts are compared with the allocation expected under equal survival behavior. The finite-population correction accounts for several events occurring in the same risk set. Group contrasts sum to zero, so the full covariance has an intentional redundant direction. Removing one group produces the g−1-dimensional system used by the joint statistic; it does not discard that group’s observations.
A survival comparison is not an effect estimate
The log-rank statistic aggregates signed event-count contrasts over follow-up. Crossing survival patterns can cancel, making an unweighted test less sensitive even when curves visibly differ. A significant result does not specify which group has a constant hazard ratio or how much survival time changes. A nonsignificant result does not establish equivalence. Inspecting survival curves and choosing an analysis appropriate to the scientific question remain separate tasks.
Independent censoring is an assumption about the observation process. If people at high event risk disproportionately disappear from follow-up, retaining them in early risk sets does not correct that selection. This tool also does not account for repeated observations from the same person or clustered groups. The Kaplan Meier survival from censored observations calculator estimates a curve for one data set; this page constructs the pooled between-group comparison and exposes its risk-set arithmetic.
A few questions, answered
Can a censored record have event=1?
No. Use zero for right censoring and one only when the event actually occurred at the recorded time. Reversing this coding changes the risk-set comparison.
Why can the calculator reject data with several groups?
If the reduced event-count covariance is singular, the requested joint comparison has insufficient independent information. The page reports that instead of silently using a pseudoinverse or invented degrees of freedom.