Understand the idea
Survival analysis handles data like 'this patient was followed for 18 months without the event happening, then we lost contact': you know they survived at least that long, but not what happened after. Kaplan-Meier is the classic way to turn a whole collection of such partial observations into one honest survival curve, using every scrap of information each subject actually provided, rather than throwing out anyone whose exact event time is unknown.
The way it works: at every moment someone actually experiences the event, recalculate the fraction of the STILL-AT-RISK group that survived that moment, and multiply all those fractions together as you move forward in time. Subjects who are censored (lost to follow-up, or the study simply ended) quietly leave the 'at risk' group at their own last-known time without ever counting as a failure: they contribute exactly what they know (survived at least this long) and nothing more.
The median survival time is the time by which the curve estimates that half the group has had the event: read it where the curve first falls to 50% or below. One special case: if the curve falls to exactly 50% and stays flat there until a later drop, every time along that flat stretch fits equally well, so KernelStats reports the time halfway along it. If the curve never actually reaches 50% (heavy censoring, or most subjects doing well), the median is honestly reported as 'not reached' rather than guessed at or extrapolated. To compare survival between two or more groups, the log-rank test asks whether the observed number of events in each group, at every event time, matches what you'd expect if all the groups truly had identical survival.
The Kaplan-Meier curve is also called the product-limit estimator, because it multiplies together the chances of surviving each step.
Practitioner explanation
KernelStats computes the product-limit estimator S-hat(t) = product over event times t_i<=t of (1 - d_i/n_i), with Greenwood's formula for the variance and a LOG-LOG (complementary log-log) TRANSFORMED 95% confidence band (built on g = log(-log(S-hat)) and back-transformed), the default in Stata, SAS PROC LIFETEST and Python's lifelines (R's survfit defaults to conf.type = 'log', so the card's R export sets conf.type = 'log-log' explicitly to match), chosen because it keeps the confidence limits mechanically confined to [0,1], unlike a naive symmetric interval on S-hat itself which can extend outside that range.
The proportional-hazards assumption underlying the log-rank test's FULL POWER is ACTUALLY TESTED when two or more groups are present: a Grambsch-Therneau test (the same test as R's cox.zph with its defaults) fits a Cox model with group as a factor and asks whether the hazard ratio drifts over follow-up time, measured on the Kaplan-Meier scale g(t) = 1 - S-hat(t-). The product states a subtle but important honesty point directly: NON-proportional hazards do NOT invalidate the log-rank p-value itself (under the null hypothesis the curves are identical, so hazards are trivially proportional); what non-proportionality costs is POWER, since crossing curves can have early and late differences cancel out and let the test miss a real difference. When a group has zero events or every event falls at exactly one time, the test cannot run and the card reports 'not assessed', explicitly never a false pass.
Both of the method's core assumptions, non-informative censoring (censoring unrelated to prognosis) and independence across subjects, are stated as ASSUMED FROM THE STUDY DESIGN, with the product stating plainly that the data themselves cannot test either one; only the proportional-hazards assumption for the log-rank comparison gets an actual computed check. This distinction between 'assumed, untestable from data' and 'checked directly' is drawn explicitly rather than left for the reader to infer.
When to use it
Consider it when
You have time-to-event data with right-censoring (a follow-up time and a 0/1 event flag) and want to estimate the survival curve directly, its median, and optionally compare survival across two or more groups without adjusting for covariates.
Use caution when
You need to adjust for continuous or multiple covariates while estimating the effect on survival (use Cox proportional-hazards regression instead), or the survival curves being compared clearly cross, which erodes the log-rank test's power even though it remains valid under the null hypothesis.
Formulas and symbols
Kaplan-Meier product-limit estimator
d_i the number of events at time t_i; n_i the number still at risk just before t_i. Censored subjects leave the risk set at their own censoring time without a step.
Greenwood's variance formula
Underlies the log-log transformed 95% confidence band (R's survfit needs conf.type = 'log-log' to reproduce it; its own default is 'log').
Median survival time
t_a is the first time the curve is at or below 0.5 and t_b the first time it is below 0.5. The comparison with 0.5 allows for rounding: a value within about 1.5 × 10⁻⁸ of 0.5 (the square root of machine precision) counts as 0.5, so a curve that reaches one half exactly is not moved to a later event time by floating-point error. When the curve sits at 0.5 from t_a until a later drop at t_b, the median is the midpoint of that flat stretch; when it sits at 0.5 to the end of follow-up, the median is t_a. Reported as 'not reached' if the curve never drops to or below 0.5 within the observed follow-up. The 95% limits of the median are read the same way, the lower limit off the lower confidence curve and the upper limit off the upper one ('not reached' when that curve never gets to 0.5). The rule follows the convention of R's printed median (print.survfit, with its 0.95LCL and 0.95UCL); R's quantile(survfit, 0.5) differs only when the curve stays at 0.5 to the end of follow-up, where it takes the midpoint of t_a and the last follow-up time.
Assumptions and checks
- If subjects are censored FOR reasons related to their prognosis (e.g. sicker patients dropping out of the study), rather than for reasons unrelated to their risk (e.g. the study simply ended), the Kaplan-Meier curve and any group comparison are biased.
In KernelStats: Not checked by KernelStats: assumed from the study design; stated directly as a standing 'Non-informative censoring' reminder.
- Independence of observations. Kaplan-Meier and the log-rank test assume each subject's event/censoring time is independent of every other subject's; clustered data (e.g. multiple body sites per patient) understate the true variability of the curve and the test.
In KernelStats: Not checked by KernelStats: assumed from the study design; stated directly as a standing 'Independent survival times' reminder.
- Proportional hazards. If the hazard ratio between groups changes over follow-up time (crosses over, or grows/shrinks), a single log-rank test result summarizes a comparison whose direction or magnitude is not constant over time, and can be a weak or misleading summary of what is actually happening.
In KernelStats: A Schoenfeld-residual-style proportional-hazards test (matching R's cox.zph convention), reported directly on the card when more than one group is compared; explicitly reported as 'NOT ASSESSED' rather than a false pass when the diagnostic could not run.
Alternatives
- Cox Proportional-Hazards Regression. You want to adjust for one or more covariates and quantify their effect on the hazard, rather than only describe or compare unadjusted survival curves.
- Censored Weibull Reliability (Life-Data) Fit. You want a fully parametric survival model to extrapolate beyond the observed follow-up period, rather than a nonparametric curve estimate.
Worked example
Scenario
Comparing survival between a new treatment and standard-of-care groups in a clinical trial with 35% overall censoring.
Result
Median survival: 18.4 months (treatment) versus 11.2 months (standard care); log-rank chi-square = 6.8, df = 1, p = .009. Grambsch-Therneau proportional-hazards check: p = .34 (no evidence of a drifting hazard ratio).
Interpretation
The treatment group shows meaningfully longer median survival, and the significant log-rank test supports a real difference between the curves; the non-significant proportional-hazards check supports treating the log-rank test's assumption as reasonably satisfied here, though that check has limited power to detect a real violation with this event count.
Common misconceptions
Misconception
A non-significant log-rank test proves the survival curves for the compared groups are identical.
Correction
A non-significant log-rank test only means the data did not provide strong evidence of a difference: absence of evidence is not evidence of absence. This is especially true when survival curves cross: the log-rank test remains statistically valid under the null hypothesis even with non-proportional hazards, but crossing curves specifically erode its POWER to detect a real difference, since early and late differences can cancel out in the test's aggregation.
Read more: Misconception: a non-significant result proves there is no effect
Misconception
Censored subjects should be excluded from the analysis since their exact event time is unknown.
Correction
A censored subject contributes real, usable information (that they survived at least up to their last known follow-up time) and stays in the at-risk set until that time before leaving without counting as a failure. Excluding censored subjects entirely throws away information the Kaplan-Meier estimator is specifically designed to use, and typically biases the estimated survival curve.
Read more: Misconception: a larger sample size fixes a biased estimate
References
- Nonparametric estimation from incomplete observations, Kaplan, E. L. and Meier, P. (1958), Journal of the American Statistical Association, 53(282), 457-481.
- Evaluation of survival data and two new rank order statistics, Mantel, N. (1966), Cancer Chemotherapy Reports, 50(3), 163-170.
