Closed tengfei-emory closed 1 year ago
Hey @tengfei-emory !
Ideally, I don't think you should include obs with no follow-up time. Other software, such as Stata, will exclude observations with no follow-up by default (like missing data, because a unit of analysis is followup time, of which, there is none).
R is unique in allowing zero followup time (and negative times 😱 ). But I think this is something that should be handled in your data setup rather than handled by a package. You'll see that our risk table numbers match how this is handled within the survival package (see below).
library(ggsurvfit)
#> Loading required package: ggplot2
df_colon2 <- df_colon
df_colon2$time[1] = 0
sf <- survfit2(Surv(time, status) ~ 1, data = df_colon2)
summary(sf, times = 0)
#> Call: survfit(formula = Surv(time, status) ~ 1, data = df_colon2)
#>
#> time n.risk n.event survival std.err lower 95% CI upper 95% CI
#> 0 929 1 0.999 0.00108 0.997 1
ggsurvfit(sf) +
add_risktable()
Created on 2023-04-11 with reprex v2.0.2
This scenario happens frequently in landmark setting. It makes sense to just exclude events at time 0.
Thanks @ddsjoberg !
I used the risk table feature for a survival curve with events observed at time 0.
In that case, the number of at risk will still be the sample size while the number of events will also be larger than zero, such that the sum of at-risk and events at time 0 will be larger than the sample size. I am not sure if that's the ideal way of showing the data.
The following is a toy example: