Skip to content

survival analysis: plot.survfit

2 messages · Ruth Meili, Thomas Lumley

#
Hello everybody,
does anybody know how the function plot.survfit exactly works?

I'd like to plot the log of the cummulative hazard against the
log time by using plot.survfit(...fun="cloglog") which does not
work correctly. The scales are wrong and there is an error
message about infinit numbers. It must have something to do with
the censored data, doesn't it?

#Example: 
motorette <- 
 read.table("http://stat.ethz.ch/Teaching/Datasets/NDK/motorette.dat",header=T)
km <- survfit(Surv(time,status)~1,data=motorette,type="kaplan-meier")

plot(km,fun="cloglog") # Error message and wrong scales
plot(km,fun="cumhaz",log="xy") # Does the same.


#If I do the plot "by hand", it does work:
log.cum.H <- log(-log(km$surv))
log.t <- log(summary(km,censored=T)$time)
plot(log.t,log.cum.H,type="s")

regards
Ruth
#
On Fri, 2 Aug 2002, Ruth Meili wrote:

            
I don't get an error message. I get a warning that values <=0 have been
omitted. I don't think it has anything to do with censoring.

Also, the scales are correct (though the x-axis limits are not well
chosen).  The x-axis is not log(time), but time on a logarithmic scale.
I get a plot that looks very much like yours with

plot(km,fun="cloglog",xlim=c(200,10000),conf=FALSE)

where conf=FALSE leaves out the confidence intervals and the xlim command
chooses better x-axis limits.

The axis labels are still different as plot.survfit uses the actual time
not the log time as the label.

I'll look into removing the warning about values <=0.  It happens because
time=0 is the first point on the x-axis, which doesn't like being
log-transformed.  It might also be possible to get better automatic x-axis
limits.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._