Hi, I am attempting to graph a Kaplan Meier estimate for some claims using the survfit function. However, I was wondering if it is possible to plot a cdf of the kaplan meier rather than the survival function. Here is some of my code: library(survival) Surv(claimj,censorj==0) survfit(Surv(claimj,censorj==0)~1) surv.all<-survfit(Surv(claimj,censorj==0)~1) summary(surv.all) plot(surv.all) I would really appreciate any assistance. Thank you. Regards, Andre [[alternative HTML version deleted]]
On Sep 9, 2010, at 8:50 PM, andre bedon wrote:> I am attempting to graph a Kaplan Meier estimate for some claims > using the survfit function. However, I was wondering if it is > possible to plot a cdf of the kaplan meier rather than the survival > function. Here is some of my code: >It's not really the cdf of the KM since the KM is just an estimator. Yeah, I know, picky, picky.> library(survival) > Surv(claimj,censorj==0)I'm reasonably sure you need to assign that to something (unless its purpose is just to test the syntax.)> survfit(Surv(claimj,censorj==0)~1) > surv.all<-survfit(Surv(claimj,censorj==0)~1) > summary(surv.all) > plot(surv.all) > I would really appreciate any assistance. Thank you.The survival function is just 1 minus the CDF, (and vice versa). You didn't provide any data, but we can use the aml dataframe in survival: library(survival) surv.all<-survfit(Surv(time,status)~1, data=aml) str(surv.all) # x-coord is "time" and S_KM(t) is "surv" plot(surv.all$time, 1-surv.all$surv, type="s", ylim=c(0,1)) So that's the KM estimator of the CDF. Doesn't inherit the nice features of the plot.survfit function, though. It's also going to be more messy if you have two/+ groups -- David Winsemius, MD West Hartford, CT
On 09/09/2010 08:50 PM, andre bedon wrote:> > Hi, > > > > I am attempting to graph a Kaplan Meier estimate for some claims > using the survfit function. However, I was wondering if it is > possible to plot a cdf of the kaplan meier rather than the survival > function. Here is some of my code: >Do you really want a CDF or just plot 1-KM. If you want to plot 1-KM, just fit your survival model as usual and plot() it with the plot argument fun="event".> > library(survival) Surv(claimj,censorj==0) > survfit(Surv(claimj,censorj==0)~1) > surv.all<-survfit(Surv(claimj,censorj==0)~1) summary(surv.all) > plot(surv.all) I would really appreciate any assistance. Thank you. > > > > Regards, > > > > Andre-- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.thorpe at utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016