Skip to content

Competing Risks & Fine-Gray

In clinical data, events compete. A patient who dies in remission can never relapse, so death does more than hide the relapse time: it removes the possibility of relapse. A Kaplan-Meier analysis of relapse that codes those deaths as censored assumes that the dead patients could still relapse later, and it returns a relapse probability that is too high.

This page estimates the cumulative incidence of relapse with death as a competing event, shows how far one minus Kaplan-Meier overshoots it, and then fits three regression models: a cause-specific Cox model for each event and the Fine-Gray model for relapse.

Use them when more than one kind of event can end a patient’s time at risk and one kind prevents the other: relapse and death in remission, death from cancer and death from another cause, discharge alive and death in hospital. The question decides the method. The probability that a patient relapses by 30 months calls for the cumulative incidence. The effect of a treatment on the relapse rate among patients who are still at risk calls for a cause-specific hazard.

Download competing.csv into your working directory. The invented table holds 200 patients, one row per patient, with three columns: time is the follow-up in months, status is 0 for a censored time, 1 for a relapse, and 2 for a death without relapse, and group is 0 for control and 1 for treated.

The times come from a simulation with known answers. The relapse hazard is 0.05 per month in the control arm, and treatment multiplies it by 0.55. The death hazard is 0.03 per month in both arms, so treatment has no effect on death. The data cutoff falls at 30 months.

library(survival)
library(tidycmprsk)
library(ggplot2)
df <- read.csv("competing.csv")
df$arm <- factor(df$group, levels = c(0, 1),
labels = c("control", "treated"))
df$event_type <- factor(df$status, levels = c(0, 1, 2),
labels = c("censored", "relapse", "death"))
dir.create("outputs", showWarnings = FALSE)
print(table(df$arm, df$event_type))
censored relapse death
control 13 59 33
treated 12 40 43

The treated arm has fewer relapses, 40 of 95 patients against 59 of 105. It also has more deaths, 43 against 33. The simulation gave both arms the same death hazard, so the surplus is partly chance and partly arithmetic: a treated patient who does not relapse stays at risk of death for longer. Keep the surplus in mind, because it shapes every result below.

The cumulative incidence function gives the probability that a patient has had the event of interest by each time, in a world where the competing event also happens. A death removes the patient from the risk set and adds nothing to the relapse curve afterward. The estimator is called Aalen-Johansen.

In R, cuminc() from tidycmprsk needs the status as a factor whose first level is the censored level. It also runs Gray’s test, which compares the cumulative incidence curves of the arms in the way that the log-rank test compares survival curves. In Python, AalenJohansenFitter from lifelines takes the numeric status and the code of the event of interest. lifelines has no Gray’s test.

cif <- cuminc(Surv(time, event_type) ~ arm, data = df)
at_30 <- tidy(cif, times = 30)
at_30 <- at_30[at_30$outcome == "relapse", ]
cat(sprintf("%s: relapse by 30 months = %.3f, 95%% CI %.3f to %.3f\n",
at_30$strata, at_30$estimate, at_30$conf.low, at_30$conf.high),
sep = "")
gray <- glance(cif)
cat(sprintf("Gray's test for %s: statistic = %.2f, p = %.3f\n",
gray$outcome_1, gray$statistic_1, gray$p.value_1))
control: relapse by 30 months = 0.562, 95% CI 0.460 to 0.652
treated: relapse by 30 months = 0.421, 95% CI 0.320 to 0.519
Gray's test for relapse: statistic = 3.88, p = 0.049

By 30 months, 56.2% of the control arm and 42.1% of the treated arm have relapsed, a difference of 14 percentage points. Each interval is close to 20 points wide. Gray’s test gives p = 0.049.

The estimates agree to three decimals. The limits differ in the third decimal because the two packages estimate the standard error with different formulas.

Each arm has one pair of events at the same time, and the Aalen-Johansen code in lifelines does not accept ties. It shifts each event time by a random amount of at most 0.0001 month and warns that “Tied event times were detected”. The seed argument makes the shift repeatable, and a shift that small does not change the three decimals above.

Sort the two interval limits before you print them. lifelines 0.30 puts the lower limit in the column that it labels upper and the upper limit in the column that it labels lower.

The common mistake is to code a death as censored, fit a Kaplan-Meier curve for relapse, and report one minus the curve as the probability of relapse. This block computes that number for each arm and prints it beside the cumulative incidence. It then does the same for death and adds the two naive numbers.

naive_fit <- survfit(Surv(time, event_type == "relapse") ~ arm, data = df)
naive <- 1 - summary(naive_fit, times = 30)$surv
cat(sprintf("%s: 1 - Kaplan-Meier = %.3f, cumulative incidence = %.3f\n",
at_30$strata, naive, at_30$estimate), sep = "")
naive_death_fit <- survfit(Surv(time, event_type == "death") ~ arm,
data = df)
naive_death <- 1 - summary(naive_death_fit, times = 30)$surv
cat(sprintf("%s: naive relapse %.3f + naive death %.3f = %.3f\n",
at_30$strata, naive, naive_death, naive + naive_death),
sep = "")
control: 1 - Kaplan-Meier = 0.735, cumulative incidence = 0.562
treated: 1 - Kaplan-Meier = 0.620, cumulative incidence = 0.421
control: naive relapse 0.735 + naive death 0.533 = 1.268
treated: naive relapse 0.620 + naive death 0.668 = 1.288

One minus Kaplan-Meier puts the 30-month relapse probability of the control arm at 73.5%. The cumulative incidence is 56.2%, and the count agrees with it: 59 of 105 control patients relapsed, which is 56.2%. The naive number is 17 points too high in the control arm and 20 points too high in the treated arm.

The second pair of lines shows why the naive number cannot be a probability in this population. In the control arm, the naive relapse and death probabilities add up to 1.268. Each naive curve estimates a probability for a hypothetical population in which the other event cannot happen. The two numbers belong to two different populations, so nothing keeps their sum at or below 1. The counts of the first table give the total that a pair of probabilities must respect: 59 relapses and 33 deaths among 105 control patients is 0.876, and the remaining 0.124 is the 13 patients who reached 30 months alive and in remission.

The figure draws both estimates for each arm.

naive_curve <- survfit0(naive_fit)
naive_data <- data.frame(time = naive_curve$time,
arm = rep(levels(df$arm), naive_curve$strata),
estimate = 1 - naive_curve$surv,
method = "1 - Kaplan-Meier")
relapse_curve <- cif$tidy[cif$tidy$outcome == "relapse", ]
cif_data <- data.frame(time = relapse_curve$time,
arm = relapse_curve$strata,
estimate = relapse_curve$estimate,
method = "Cumulative incidence")
cif_plot <- ggplot(rbind(cif_data, naive_data),
aes(x = time, y = estimate, color = arm,
linetype = method)) +
geom_step(linewidth = 0.8) +
scale_color_manual(values = c("#e07a5f", "#1f4e5f")) +
scale_linetype_manual(values = c("dashed", "solid")) +
scale_x_continuous(breaks = seq(0, 30, 6)) +
labs(x = "Time (months)", y = "Probability of relapse", color = NULL,
linetype = NULL) +
theme_minimal(base_size = 13)
ggsave("outputs/cif-r.png", cif_plot, width = 7, height = 4.5, dpi = 150)

Step curves from ggplot2 for the probability of relapse over 30 months in the control and treated arms. In each arm the dashed curve of one minus Kaplan-Meier rises above the solid cumulative incidence curve, and the gap widens with time.

The curves start together and separate as deaths accumulate. The gap is small while few patients have died, which is why the mistake goes unnoticed in studies with short follow-up or a rare competing event.

A cause-specific hazard is the rate of one event among the patients who have had no event yet. A Cox model estimates its ratio between arms when the other event is coded as censored. That coding was wrong for a probability, and it is right for a rate, because a patient who has died is no longer at risk of relapse. Fit one model for each event.

relapse_fit <- coxph(Surv(time, event_type == "relapse") ~ arm, data = df)
death_fit <- coxph(Surv(time, event_type == "death") ~ arm, data = df)
ratio_columns <- c("exp(coef)", "lower .95", "upper .95")
cause_specific <- rbind(relapse = summary(relapse_fit)$conf.int[1, ],
death = summary(death_fit)$conf.int[1, ])
print(round(cause_specific[, ratio_columns], 3))
exp(coef) lower .95 upper .95
relapse 0.723 0.484 1.081
death 1.389 0.882 2.188

Among patients who are alive and in remission, the treated relapse at 0.72 times the rate of the controls. The interval, 0.48 to 1.08, contains 1 and also contains the true ratio of the simulation, 0.55. The death rate in the treated arm is 1.39 times that of the control arm, with an interval from 0.88 to 2.19. The simulation gave both arms the same death hazard, so the distance of this ratio from 1 is chance, and the interval contains 1.

The Fine-Gray model is a regression for the cumulative incidence itself. It models the subdistribution hazard, a rate computed with the patients who had the competing event left in the risk set, and its ratio describes how a covariate moves the cumulative incidence curve.

fine_gray <- crr(Surv(time, event_type) ~ arm, data = df)
shr <- tidy(fine_gray, exponentiate = TRUE, conf.int = TRUE)
cat(sprintf("Subdistribution hazard ratio for relapse: %.3f\n",
shr$estimate))
cat(sprintf("95%% CI %.3f to %.3f, p = %.3f\n", shr$conf.low,
shr$conf.high, shr$p.value))
Subdistribution hazard ratio for relapse: 0.668
95% CI 0.448 to 0.997, p = 0.048

The subdistribution hazard ratio is 0.67, and its interval runs from 0.45 to 0.997. The data are compatible with a treatment that halves the subdistribution hazard and with one that changes it by less than 1 percent. The p-value of 0.048 sits beside a threshold and carries no more than the interval does: the direction favors treatment, and the size is poorly determined.

The three ratios are 0.72 for the cause-specific hazard of relapse, 1.39 for the cause-specific hazard of death, and 0.67 for the subdistribution hazard of relapse. The Fine-Gray ratio is farther from 1 than the cause-specific ratio for the same event, and the death ratio explains the gap.

The cumulative incidence of relapse depends on both cause-specific hazards. It falls when patients relapse at a lower rate, and it also falls when patients die at a higher rate, because a patient who has died cannot relapse. In this table the treated arm does both: a relapse rate 0.72 times that of the controls and a death rate 1.39 times theirs. The Fine-Gray ratio describes the distance between the two cumulative incidence curves, so it absorbs both mechanisms.

That is the trap for a treatment that changes the competing event. A drug that left the relapse rate alone and raised the death rate would still lower the cumulative incidence of relapse, and its Fine-Gray ratio for relapse would be below 1. A reader who saw that ratio alone would credit the drug with preventing relapse. Report the cause-specific ratio for every event next to the Fine-Gray ratio, and the cumulative incidence of every event next to both.

A subdistribution hazard ratio also has no reading as a rate among patients at risk, since its risk set contains patients who have died. Use its direction, and take the size of the effect from the cumulative incidence: 42.1% against 56.2% relapsed by 30 months.

  • One minus Kaplan-Meier with the competing event coded as censored is not the probability of the event. It was 17 to 20 points too high here. Use the cumulative incidence.
  • Cause-specific and subdistribution hazard ratios answer different questions. The cause-specific ratio describes the rate among patients still at risk and suits a question about mechanism. The subdistribution ratio describes the cumulative incidence and suits a question about prognosis. Neither one replaces the other.
  • A treatment that lowers the cumulative incidence of one event may do it by raising the rate of the competing event. Read the result for the competing event before you interpret the result for the event of interest.
  • Check which event the software treats as the event of interest. crr() takes the first level after the censored level unless failcode names another, and AalenJohansenFitter needs event_of_interest on every call.
  • When one event prevents another, the cumulative incidence function gives the probability of each event, and Gray’s test compares it between groups.
  • One minus Kaplan-Meier overstates that probability, and the excess grows with the number of competing events.
  • A cause-specific Cox model for each event and a Fine-Gray model answer different questions, so report them together with the cumulative incidence.
  • R and lifelines agree on the cumulative incidence and on the cause-specific hazard ratios. The Fine-Gray model is fitted in R.

The tidycmprsk package by Sjoberg and Fei supplies competing risks estimation in R.

The survival package by Therneau supplies the Kaplan-Meier, Cox, and parametric survival models in R.

Davidson-Pilon, 2019 describes lifelines, the Python library for survival analysis.

Gray, 1988 describes the test that compares the cumulative incidence of a competing risk between groups.

Fine and Gray, 1999 describe the proportional hazards model for the subdistribution of a competing risk.

Latouche and colleagues, 2013 show why a competing risks analysis should report all cause-specific hazards and all cumulative incidence functions.

Austin, Lee, and Fine, 2016 introduce competing risks for clinical readers, with a worked comparison of cause-specific and subdistribution hazard models. Read it for the choice between the two models.

The tidycmprsk cumulative incidence reference explains the event factor, the interval formula, and Gray’s test. The competing risks regression reference documents failcode, which selects the event of interest for the Fine-Gray fit.

The survival package vignette on multi-state models and competing risks shows the same estimates with survfit() and finegray(), for readers who prefer to stay inside one package.

The AalenJohansenFitter reference documents the jitter of tied event times and the seed argument.

The Cox regression lesson covers the model behind the cause-specific fits, and the Kaplan-Meier lesson covers the estimator that this page compares against.