[R] How to set type of censored data in coxph regression

Hung-Hsuan Chen (Sean) sandwichc at gmail.com
Thu Mar 13 10:17:08 CET 2008


Dear R users,
I tried to analysis the hazard function of some data by coxph function
in survival package.
The type of the data include "left-censored", "right-censored", "both
right-censored and
left-censored" (btw, does this has a technical term?), and "complete" ones.

I noticed that event (one parameter in "Surv()") might be an indicator
for the censored
type. However, whenever I set event to 2 or 3, the Surv() function
always returns error msg.

Take the following code segment for example,
> state = c(0, 0, 1, 1, 2, 2, 3, 3, 0, 1)
> begin = c(0, 0, 1, 1, 1, 2, 2, 1, 0, 1)
> end   = c(8, 8, 9, 7, 8, 6, 9, 8, 8, 9)
> Surv(begin, end, state)
will get err msg: Surv(begin, end, state) : Invalid status value

When trying the following code segment:
> state = c(0, 0, 1, 1, 0, 1, 0, 1, 0, 1)
> Surv(begin, end, state)
will get [1] (0,8+] (0,8+] (1,9 ] (1,7 ] (1,8+] (2,6 ] (2,9+] (1,8 ]
(0,8+] (1,9 ]

I can understand the second code segment, but I cannot understand why
the first code
segments failed.

Can anyone give me some examples or suggestions? Thanks a lot.



More information about the R-help mailing list