s-news
[Top] [All Lists]

[S] Problems with Surv

To: s-news@wubios.wustl.edu
Subject: [S] Problems with Surv
From: molinari@kispi.unizh.ch (Luciano Molinari)
Date: Mon, 27 Apr 1998 12:51:22 +0100
Sender: owner-s-news@wubios.wustl.edu
I am working with S+4 under Windows NT4 and I have been having problems with
Surv.
According to the help:
--------------
USAGE

Surv(time, event)
or
Surv(time, time2, event, type=<<see below>>, origin=0)
-----
Surv can be called in two different ways. However, when called in the first way,
-----------------
S+>Surv(avb$V7,event=avb$c=="N")
Error in Surv: Argument "time2" is missing, with no default: Surv(avb$V7,
event = avb$c == 
"N")
Dumped
----------
it does not work. The error originates in the following section of the code:
---------
...
else if(type == "right" || type == "left") {
                if(!is.numeric(time))
                        stop("Time variable is not numeric")
                else if(any(time[who] < 0))
                        stop("Time variable must be >= 0")
                if(length(time2) != nn)
                        stop("Time and status are different lengths")
                if(is.logical(time2))
                        status <- 1 * time2
                else if(is.numeric(time2)) {
                        who2 <- !is.na(time2)
                        status <- time2 - (max(time2[who2]) - 1)
                        if(any(status[who2] != 0 & status[who2] != 1))
                                stop("Invalid status value")
                }
                else stop("Invalid status value")
                ss <- cbind(time, status)
                dimnames(ss) <- list(NULL, c("time", "status"))
        }
...
-----------------
more specifically at
-----
if(length(time2) != nn)
                        stop("Time and status are different lengths")
---------
Then, after trying a few different things and to decode the somewhat
cryptical Help, I decided to replace all occurrences of "time2" in the above
code by "event", and, see, it now worked, as expected I guess (at least it
produces the same curves as the deprecated surv.fit).

Is this just a bug? If yes, is my fix OK? In all cases? Or am I missing
something?
BTW, in contrast with the help for survfit and surv.fit I was not able to
obtain confidence intervals for the survival curves in the case of two groups.
                
Any comment?
L. Molinari

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>