0

I draw Kaplan-Meier survival curve using survfit and ggsurvplot (60 months survival) :

surv <- survfit(Surv(time, status) ~ group, data = dataK)

ggsurvplot(surv,size = 1, censor.size = 6,risk.table = TRUE,pval = TRUE, conf.int = F,pval.coord = c(45,1), xlim = c(0,60),xlab = "Time in months",ylab = "survival",break.time.by = 12, risk.table.y.text.col = T,risk.table.y.text = T, legend.title = "",legend.labs = c("hi", "low")

survival fit

Because I don't have enough subjects for 60 months analysis, I want to restrict my log rank analysis to a 24 months survival analysis (see dotted line).

I can't find a way to do this. I restricted ggplot2 timeline by changing xlim = c(0,60) to xlim = c(0,24) but it only change the graph aspect and does not censor upcoming data (the p-value does not change).

B_slash_
  • 309
  • 2
  • 17
  • 1
    I'm trying to understand the statistical problem here. Are you asking whether the survival to 24 months is statistically different (at the standard 95% confidence level)? If so why not simply consider any survival time greater than 24 mo to be censored at 24 mo? And are you hoping to draw confidence bands or error bars around the KM curves up to that point? (Seems like the same dataset as constructed for the first question should suffice for the second question.) Voting to close for lack of a [MCVE], i.e. needs more details for anything other than statistical advice which is OFF-TOPIC HERE. – IRTFM Jun 23 '21 at 01:43
  • "If so why not simply consider any survival time greater than 24 mo to be censored at 24 mo?" => yes, this is what I want to do! Is there a function to do this inside "survfit" function? I could also create a new variable "status_censored" <- if(time>24 mo) then(status=alive)... but If there is a way to do this inside survfit it would be easier! – B_slash_ Jun 23 '21 at 09:05
  • I cannot think of a reason why Therneau would have created such a feature in `survfit`, but perhaps you want to look at `summary.survfit` or `predict.survfit`. It's going to depend on the exact statistical question which to my mind has not yet been articulated. – IRTFM Jun 23 '21 at 17:31

1 Answers1

1

I finally found a fast and simple solution:

Create two new variables at the desired cutt-off (example below for 24 months censored survival):

database$status_survival_censored <- ifelse(database$survival_time > 24, 0, database$status_survival)
database$survival_time_censored <- ifelse(database$survival_time > 24, 24, database$survival_time)

Run the new survival plot:

surv <- survfit(Surv(survival_time_censored, status_survival_censored) ~ group, data = database)
ggsurvplot(surv)
B_slash_
  • 309
  • 2
  • 17