Re: [R] Error in using coxph()

About this list Date view Thread view Subject view Author view Attachment view

From: Göran Broström (gb@stat.umu.se)
Date: Mon 17 May 2004 - 00:05:57 EST


Message-id: <20040516140557.GA23967@stat.umu.se>

On Sun, May 16, 2004 at 02:25:07PM +0200, Peter Dalgaard wrote:
> Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:
>
> > Note you said you used 1-F but the output said you used F. You also say
> > `1-F is a vector of '0's' so I think you may have declared that all
> > observations are right-censored. (NB if you give Surv an event vector of
> > all 1's it is ambiguous, so don't do this.)
>
> Actually, it *is* documented that this is interpreted as "all-died"
> and the advice in ?Surv is just to avoid 1/2 coding if all data are
> censored. It's a bit puzzling that we don't allow explicit
> disambiguation (e.g., by passing the event as a two-level factor),
> though.

But note the following:

> library(survival)

> enter <- c(0,0,0)
> exit <- c(1,2,3)
> event <- c(0,0,0)
> x <- c(1,0,1)
> coxph(Surv(exit, event) ~ x)
Call:
coxph(formula = Surv(exit, event) ~ x)

  coef exp(coef) se(coef) z p
x 0 1 0 NaN NaN

Likelihood ratio test=0 on 1 df, p=1 n= 3
Warning message:
Ran out of iterations and did not converge in:
fitter(X, Y, strats, offset, init, control, weights = weights,

But:

> coxph(Surv(enter, exit, event) ~ x)
Error in fitter(X, Y, strats, offset, init, control, weights = weights, :
        Can't fit a Cox model with zero failures

This is the kind of message we want (before this check was introduced,
coxph crashed (segfault) if there were no events).

Recommendation 1: Give 'Surv' three arguments! (time, time2, event)

Recommendation 2: 'event' should be a logical, with 'FALSE' = 'censored'.
Meaning that if event is numeric, '0' = 'censored', anything else is an
event. This is advantageous when you have data with several types of
events. For instance, event = 0: censored, event = 1: death of cause 1,
event = 2: death of cause 2. Then you can (i) use event as is for total
mortality, (event == x) for for cause-specific mortality, x = 1, 2.

You can get this behaviour now by using (event != 0) for total mortality,
of course.

Göran

> --
> O__ ---- Peter Dalgaard Blegdamsvej 3
> c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
 Göran Broström                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Umeå University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Umeå, Sweden             e-mail: gb@stat.umu.se

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST