Why doesn't this survfit plot start at 100%

375 views Asked by At

When I plot the survfit plot of data with two different censoring events, the overall plot (s0) doesnt start at time = 0, pstate = 100%, but jumps to 100% when the first cencoring event occurs.

Jumping survival fit

Here you can see in an example, where the jump occurs at time 1, that is the first cencoring event.

library(survival)
library(ggfortify)
library(tidyverse)
set.seed(1337)

dummy_data = tibble(time = sample.int(100, 100, replace = TRUE),
                    event = sample.int(3, 100, replace = TRUE))%>%
  mutate(event = factor(event))

kaplanMeier <- survfit(Surv(time, event) ~ 1, data=dummy_data)
autoplot(kaplanMeier, facets = TRUE)
1

There are 1 answers

1
Allan Cameron On BEST ANSWER

This does seem to be a bug in ggfortify. As a temporary fix, you can set the survival percentage at t = 0 to 100% by doing:

p <- autoplot(kaplanMeier, facets = TRUE)

p$layers[[1]]$data[1, c(5, 7, 8)] <- 1
p

enter image description here