[R] Having trouble with plot.survfit and fun="cloglog"

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Thu Mar 16 04:09:26 CET 2006


I'm having trouble getting fun="cloglog" to work with plot on
a survfit object.  Here are the data I used for the commands
that follow.

days status
2 0
2 0
5 1
9 0
14 1
16 0
16 0
17 0
29 1
30 0
37 1
37 0
39 1
44 0
44 0
58 0
60 1
67 1
68 1
82 1
82 1
86 0
86 0
89 1
93 0
97 1
100 0
100 0
100 0


 > library(survival)
Loading required package: splines
 > eg1.km <- survfit(Surv(days,status),data=eg1)
 > plot(eg1.km,mark.time=FALSE,conf.int=FALSE)  # Works
 > plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun="cumhaz")  # Works
 > plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun="cloglog")  # Error
Error in rep.default(2, n2 - 1) : invalid number of copies in rep()
In addition: Warning message:
2 x values <= 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, ylabel
, log)

The axes are set and drawn up but nothing else is plotted.

 > plot(eg1.km,mark.time=FALSE,conf.int=FALSE,fun="cumhaz",log="xy") # OK
Warning messages:
1: 2 x values <= 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, yla
bel, log)
2: 1 y value <= 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, ylab
el, log)

This does display the right plot but I am confused about how the xaxis
is computed.  The first tick mark is labeled with 100, the next with
200 right up to 600, but the entire plot is drawn between 0 and 100.

Please elighten me as to what I'm not understanding about fun="cloglog"
and log scales.

 > R.version
          _
platform i686-pc-linux-gnu
arch     i686
os       linux-gnu
system   i686, linux-gnu
status   Patched
major    2
minor    2.1
year     2006
month    03
day      13
svn rev  37540
language R

The survival package is version 2.21

Thank you,

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.946.8081  Fax: 416.946.3297




More information about the R-help mailing list