For the complete documentation index, see llms.txt. This page is also available as Markdown.

Kaplan–Meier survival curves

Estimate survival probabilities over time using Kaplan–Meier curves, for an entire cohort or separately for groups defined by a clinical variable.

Estimate survival probabilities over time using Kaplan–Meier curves, for an entire cohort or separately for groups defined by a clinical variable.

Kaplan-Meier survival curves

Description

Analysis summary

Estimates, for the cohort, the probability of remaining free of the event over time (e.g. overall survival, progression-free survival), optionally one curve per level of a single grouping variable.

Computation

A Kaplan-Meier estimator is fitted per group (or a single 'Overall' curve when no group is given): at each event time the survival probability is the share of patients still at risk who have not yet had the event, with patients leaving the cohort without the event (censored) withdrawn from the at-risk count. The descriptive stats table carries, per curve, the patient and event counts, the median survival time with its 95% confidence bounds, and the time at which survival drops through 10/25/50/75/90% — None where the curve never reaches that level. Statistical tests compare survival between the groups: for two groups a pairwise Cox proportional-hazards regression, for more a global Cox test plus pairwise comparisons (log-rank when the Cox model fails to converge), with p-values FDR-adjusted for the multiple comparisons and the group with the longer survival named per contrast.

When to use

Use for time-to-event questions: overall survival, progression-free survival, time to relapse, optionally broken down by a categorical variable (tumour stage, treatment arm). For hazard-ratio 'prognostic effects' of one or more clinical variables, use survival_analysis instead.

Caveats

The estimator treats censored patients as event-free until they leave the cohort, so heavy or informative censoring biases the curves. Confidence bounds and medians are unstable near the tail, where few patients remain at risk; the CI band is not drawn below five patients in a curve. Comparisons assume no time-varying confounding.

Example questions

example questions
  • Survival Kaplan-Meier curve

  • Survival Kaplan-Meier curves stratified by clinical variable

Input columns

input columns
column
type
required
description

index

any

required

Patient identifier — one row per patient.

time

numeric

required

Survival duration (numeric). Input is assumed to be in years unless stated otherwise.

event

boolean, numeric

required

Event indicator (boolean or 0/1; True/1 = event occurred, False/0 = censored).

color_group

categorical

optional

Stratification variable — each unique value produces a separate survival curve.

patient_id

categorical

required

Patient identifier required for population summary statistics.

Visualizations

  • kaplan_meier How to read: One step curve per group (a single curve when the data is unstratified): each step down is one or more events, and the flatter the curve the longer the cohort stays event-free. Shaded bands around each curve are 95% confidence intervals — overlapping bands signal uncertainty, not necessarily significance; significance comes from the accompanying statistical table, whose stars mark group pairs with FDR-adjusted p<0.05 (★ p<0.05, ★★ p<0.01, ★★★ p<0.001, ★★★★ p<0.0001) and which names the group with the longer survival per pair. The y-axis is the probability of remaining event-free (labelled with the outcome, e.g. Overall Survival); the x-axis is time since baseline, in the chosen unit. Hovering a curve shows its survival probability and the number of patients still at risk at that time.

Example analysis 1

Name — Progression-Free Survival by Lymphocyte Density in Tumor (Age > 40)

Analysis parameters

analysis_name, analysis_params, viz_params

Visualization — kaplan_meier

Progression-Free Survival by Lymphocyte Density in Tumor (Age > 40)

Output table

descriptive_stats (4 rows)
group
n
n_events
n_censored
km_median
km_median_ci_lower
km_median_ci_upper
q10
q25
q50
q75
q90

High

125

61

64

2.491

1.399

4.939

2.491

0.8925

0.46

Low

118

65

53

1.676

1.191

2.338

8.449

6.768

1.676

0.6023

0.3641

Medium

113

74

39

1.52

1.076

1.821

3.888

1.52

0.6461

0.2683

Overall

356

200

156

1.722

1.467

2.075

8.088

1.722

0.7118

0.3669

statistical_tests (4 rows)
Contrast
Test used for pairwise comparison
Statistic
coef
Higher Survival Group
P-value
Adjusted P-value
Significance level

(global)

cox_hr

0.06296

0.06296

(High, Medium)

cox_hr

2.263

0.392

High

0.02366

0.07099

(High, Low)

cox_hr

1.706

0.3048

High

0.08795

0.1319

(Low, Medium)

cox_hr

0.4772

0.08128

Low

0.6332

0.6332

Last updated

Was this helpful?