[R] survival analysis: plot.survfit
Thomas Lumley
tlumley at u.washington.edu
Fri Aug 2 20:41:09 CEST 2002
On Fri, 2 Aug 2002, Ruth Meili wrote:
> 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?
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.
> #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.
>
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list