← All resources

WORKED EXAMPLE · TIME-TO-EVENT ANALYSIS

Kaplan–Meier and Log-Rank Worked Example: Time to Recurrence

Follow synthetic participant-level recurrence and censoring data through Kaplan–Meier curves, risk sets, median recurrence-free time, an unadjusted log-rank comparison, interpretation, and reporting.

Published by BioTabularLast reviewed: October 30, 2026

This worked example uses synthetic data created for teaching. Imagine a randomized study that follows 30 participants for up to 24 weeks after baseline. The event is disease recurrence. Participants who have not experienced recurrence by their last observed visit are right-censored at that time.

Define the event, time origin, and target

Observational unit
The participant; each participant contributes one time and one event indicator.
Time origin
Week 0, defined as study baseline or randomization.
Event
Disease recurrence, coded 1.
Right censoring
No recurrence observed through the participant’s last follow-up, coded 0.
Primary description
The recurrence-free survival probability over time in each group.
Group comparison
An unadjusted log-rank test of equality of the two survival functions.

“Survival” here means remaining recurrence-free; it does not necessarily mean remaining alive. Every time-to-event analysis must state the event, starting point, time scale, and censoring rule explicitly.

Inspect the participant-level data

Participant follow-up times and observed status
ParticipantGroupFollow-up (weeks)Observed status
C01Control2Recurrence
C02Control3Recurrence
C03Control4Recurrence
C04Control5Censored
C05Control6Recurrence
C06Control7Recurrence
C07Control8Censored
C08Control9Recurrence
C09Control10Recurrence
C10Control12Censored
C11Control13Recurrence
C12Control15Recurrence
C13Control16Censored
C14Control18Recurrence
C15Control20Censored
T01Treatment4Censored
T02Treatment7Recurrence
T03Treatment8Censored
T04Treatment10Recurrence
T05Treatment11Censored
T06Treatment13Recurrence
T07Treatment14Censored
T08Treatment16Recurrence
T09Treatment17Censored
T10Treatment18Recurrence
T11Treatment20Censored
T12Treatment21Censored
T13Treatment22Censored
T14Treatment24Censored
T15Treatment24Censored

The downloadable file encodes recurrence as 1 and censoring as 0, as required by BioTabular. A censored participant was known to be recurrence-free through the recorded time. Censoring does not mean the participant could never recur after that time.

Build the Kaplan–Meier curves

At each recurrence time, the Kaplan–Meier estimate multiplies the preceding probability by the proportion of the current risk set that remains event-free:

Ŝ(t) = product over event times ≤ t of [1 − events at that time ÷ participants at risk]Censoring reduces later risk sets but does not create a downward step

For example, the first control recurrence occurs at week 2 with all 15 control participants at risk. The estimate becomes 14/15 = .933. Recurrences cause vertical steps. Censoring marks where follow-up ends and removes that participant from later risk sets.

Kaplan–Meier recurrence-free survival curves for treatment and control. The treatment step curve remains above control, and censoring times are marked on both curves.
Each downward step is a recurrence. Short marks indicate censoring. The curves should be interpreted together with the shrinking numbers at risk, especially near the end of follow-up.

Review risk sets and selected estimates

WeekControl at riskTreatment at risk
01515
61114
12610
1826
2402

“At risk” means still under observation and recurrence-free immediately before that time. The risk sets become small late in follow-up, so the curve tails carry much less information than the early portions.

GroupParticipantsRecurrencesCensoredMedian recurrence-free time
Control1510510 weeks
Treatment15510Not reached
Control survival at week 10
0.4909
Treatment survival at week 10
0.8512
Control survival at week 18
0.1473
Treatment survival at week 18
0.5586

The control curve first reaches or falls below .50 at week 10, so its estimated median recurrence-free time is 10 weeks. The treatment estimate remains above .50 through its final event time and subsequent censoring; its median is therefore not reached during observed follow-up. “Not reached” is not the same as “no median exists” or “the median is infinite.”

Compare the curves with the log-rank test

The log-rank test compares the observed number of events in each group with the number expected at the pooled event times under equal survival functions. It accumulates this comparison across follow-up while accounting for the changing risk sets.

Control observed recurrences
10
Control expected recurrences
5.6299
Treatment observed recurrences
5
Treatment expected recurrences
9.3701
Log-rank statistic
χ²(1) = 5.7976
Two-sided p-value
0.0160

At α = .05, the synthetic data provide evidence against equal recurrence-free survival functions. The direction is understood from the curves and observed-versus-expected events: the treatment group has fewer recurrences than expected under the null, and its curve remains higher.

The p-value does not quantify the size of the separation. The ordinary log-rank output also does not provide a hazard ratio, an absolute risk difference at a chosen time with its uncertainty, or a covariate-adjusted treatment effect.

Assumptions and design checks

  1. Independent participants: each participant contributes one event or censoring time. Clustered participants require methods that reflect the cluster structure.
  2. Common, meaningful time origin: follow-up begins from the same defined point for both groups.
  3. Correct event coding: 1 means recurrence and 0 means right-censored. Reversing these codes changes the analysis completely.
  4. Non-informative censoring: conditional on the design and available information, censoring should not selectively remove participants because of an unobserved recurrence risk that the analysis ignores.
  5. Comparable event ascertainment: follow-up schedules and recurrence definitions should not systematically differ between groups.
  6. Curve comparison: the log-rank test is particularly responsive to persistent separation of the kind shown here. Strongly crossing curves may require a more carefully chosen estimand and method.

Reproduce the result in BioTabular

  1. Download the synthetic CSV and open the Kaplan–Meier survival calculator.
  2. Import the file. Keep Participant_ID as the identifier, Group as categorical, and both Follow_up_weeks and Event_status as numeric.
  3. Review the categorical order, then confirm the variable roles.
  4. Select Follow_up_weeks as time, Event_status as the event indicator, and Group as the grouping column.
  5. Run the analysis at α = .05. Confirm 30 included observations, 15 recurrences, 15 censored observations, control median 10, treatment median not reached, and log-rank χ²(1) = 5.798, p = .016.
  6. Inspect the curve, confidence bands, censoring marks, and risk sets before interpreting the comparison.

Interpret and report the result

During the observed 24-week period, the treatment group has a higher estimated probability of remaining recurrence-free. The evidence concerns the full unadjusted survival functions represented by these data. It does not prove proportional hazards, identify a biological mechanism, or rule out bias from censoring, event ascertainment, or study conduct.

“Thirty participants were followed for up to 24 weeks. Recurrence occurred in 10 of 15 control participants and 5 of 15 treatment participants; the remaining observations were right-censored. The Kaplan–Meier median recurrence-free time was 10 weeks in control and was not reached in treatment. Recurrence-free survival differed between groups in an unadjusted log-rank test, χ²(1) = 5.80, p = .016, with the treatment curve remaining above control during observed follow-up.”

A complete report should also define baseline, recurrence, censoring, administrative follow-up, analysis population, any competing events, and whether the comparison was prespecified.

Common mistakes this example avoids

  • Analyzing follow-up time with a t-test and ignoring censoring.
  • Treating censored participants as if they had the event at their last visit.
  • Treating censoring as proof that a participant stayed recurrence-free forever.
  • Reporting a median when the curve never reaches .50.
  • Interpreting a log-rank p-value as a hazard ratio or effect size.
  • Reading the sparse tail of a curve as precisely as its early portion.
  • Using an ordinary Kaplan–Meier analysis when competing risks change the scientific question.

Limits of this worked example

The study is small, synthetic, unadjusted, and has no delayed entry, interval censoring, recurrent events, competing risks, site clustering, or time-varying covariates. BioTabular currently provides ordinary Kaplan–Meier estimates and a log-rank comparison. A real study may need a Cox model, restricted mean survival time, competing-risks methods, stratification, cluster-robust inference, or another prespecified analysis chosen for the estimand and design.

Related resources

Return to Which Statistical Test Should I Use? for the broader distinction between time-to-event outcomes and ordinary numeric outcomes. Compare this one-record-per-participant analysis with the longitudinal mixed-model worked example, where each participant contributes repeated numeric measurements rather than one event or censoring time.

References and further reading

BioTabular’s editorial approach and scope explain how these educational resources are prepared and what they do not replace.