← All topics

Step 3 · Methods · Topic 13 of 17 · 11 min

Time to event: Kaplan-Meier and log-rank

How to use observations in which the event has not happened yet.

In short#

  • Data: time, an event indicator and right censoring. A censored observation reports that the event did not occur up to time t.
  • Kaplan-Meier estimate: S(t) = Π(1 − dᵢ / nᵢ) over event times tᵢ ≤ t. Here dᵢ is the number of events at tᵢ, and nᵢ is the number at risk immediately before that time.
  • Linza intervals are pointwise 95% Greenwood intervals on the log-log scale.
  • The log-rank test compares curves overall and usually has greatest power when hazards are proportional. Censoring is assumed to be non-informative.
  • For planned pairs, Linza runs separate two-group log-rank tests and applies Holm correction across the declared family.
  • Cox regression estimates adjusted hazard ratios (HRs). The global rank-time test checks all coefficients together, while term-level tests help locate a linear trend. Their p values are unadjusted, and these tests do not detect every possible violation of proportional hazards.
  • The coefficient trend plot displays approximate time-specific coefficient estimates from scaled Schoenfeld residuals. Tied events share one averaged point; no confidence bands are shown.

In plain words#

Sometimes the question is not only whether an event occurs, but when: how long a device runs before failure or how long until relapse. Some objects leave observation before the event. The device still works, but the test has ended. This is censoring.

Do not discard these observations: they tell us that the event had not occurred up to a certain time. The Kaplan-Meier method uses this information to estimate the probability of remaining event-free over time as a step curve.

The median time to event is when the estimated event-free probability reaches 50%. If the curve never reaches 50%, the median is not reached and appears as N/A.

The omnibus test asks whether the group curves differ overall. It does not say which groups differ. Choose all pairs or each group versus a preselected control before reading pair results. Holm correction limits the chance of one or more false positives across those planned tests.

Cox regression estimates how predictors are associated with the instantaneous event rate among observations still event-free at each time. A hazard ratio of 2 means that, for the specified contrast and with other predictors held constant, the estimated event rate is twice as high at each follow-up time under the proportional-hazards assumption. It does not mean that the probability of remaining event-free through the study period is halved. Linza reports a global rank-time test and separate tests for each model term. Term-level p values are unadjusted, so they can flag a possible trend but are not confirmatory. A larger p value does not establish proportional hazards, and other time patterns may remain undetected.

The plot adds scaled Schoenfeld residuals to the fitted coefficient to show an approximate coefficient over follow-up. Under proportional hazards, points should fluctuate around the fitted horizontal coefficient. A visible pattern is a prompt to investigate the study and model, not proof of a particular alternative. The tied-event points use an average Efron residual, and Linza omits pointwise confidence bands.

In Linza#

  1. Add a Survival table: group, time, event (1) or censoring (0).
  2. In Analyses, Linza draws curves with censor marks, a number at risk table and the omnibus log-rank.
  3. The device reliability example opens with ready data.
  4. With at least three groups, open Planned pairwise comparisons in Analyses. Select all pairs or a control group. Results show each two-group statistic and raw and Holm-adjusted p values.
  5. Choose Cox proportional-hazards regression to estimate adjusted hazard ratios (HRs). Alongside the likelihood-ratio test, review the global time-trend test and the unadjusted test for each model term. They answer different questions.
  6. Open Graphs for the Cox model. The lower panels show approximate coefficient estimates over follow-up, with the fitted coefficient as a horizontal reference. Compare this descriptive view with the global and term-level score tests.
Try it in Linza Opens in a new tab with synthetic data. Work in the original tab remains unchanged.

Common mistakes#

  • Excluding censored observations or counting them as events.
  • Drawing a conclusion about one pair of groups from the omnibus log-rank.
  • Reading a small pairwise p value as a hazard ratio (HR) or effect size. Linza reports a test of curve differences, not an HR estimate; crossing curves and sparse events need careful interpretation.

Check yourself#

A device ran 300 hours without failure and the test ended. How do you record it?

Optional. Your answer is not saved.

Sources#

  • Kaplan E.L., Meier P. (1958) Nonparametric estimation from incomplete observations. Journal of the American Statistical Association, 53(282). Open publication Opens in a new tab
  • Mantel N. (1966) Evaluation of survival data and two new rank order statistics arising in its consideration. Cancer Chemotherapy Reports, 50(3). Search for publication Opens in a new tab
  • Bland J.M., Altman D.G. (2004) The logrank test. BMJ, 328. Search for publication Opens in a new tab
  • Grambsch P.M., Therneau T.M. (1994) Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81(3). Open publication Opens in a new tab

References are for further reading. A method’s suitability depends on the study design and its assumptions.