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.
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)
CodePudding user response:
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