Entering edit mode
3.7 years ago
Apprentice
▴
170
I have the following data "dat" in counting process format with time-dependent covariates. This data means that a patient with ID=5 is observed 3 times. Using this data, I would like to draw a Kaplan-Meier curve and mark at the censoring time. I conducted the following command to draw it. As a result, the censoring is marked at three places. I think the survival curve should show only one censoring time mark per patient. How can I do this using survival package of R?
#data
dat<-data.frame(ID=c(5,5,5),time1=c(0,90,120),time2=c(90,120,185),death=c(0,0,0),x=c(1,2,3))
#survival analysis
library(survival)
sf <- survfit(Surv(time1,time2,death)~cluster(ID),data=dat)
plot(sf,mark.t=TRUE)
Kaplan-Meier curve shows the time until the event - this event can't be observed multiple times. Thus, it does not make sense to keep the same patient records for different time points - only the longest one. I'd keep only the longest observation time data in your dataset.
Thank you for your reply. I would like to do survival analysis with time-dependent covariates like X column in this data set. In this case, in this counting process format with time-dependent covariates like this data set is common. I would like to know how to draw Kaplan-Meyer curve considering time-dependent covariates using this data set.
So, you want to change the shape of the "ticks" on the plot - "intermediate measure" shown as a circle and the "event" is a star, for example?
In Kaplan-Meier, my request is to not mark the censoring in the middle of tracking for each sample, but only to mark the censoring at the end.