kogalur / randomForestSRC

DOCUMENTATION:
https://www.randomforestsrc.org/
GNU General Public License v3.0
119 stars 18 forks source link

competing risk survival analysis #9

Closed haolu23 closed 6 years ago

haolu23 commented 6 years ago

I am using rfsrc to build competing risk survival random forest. The model builds fine without error but failed at prediction. The following is an example I taken from "survival" package's vignette "compete":

data("mgus2")
etime <- with(mgus2, ifelse(pstat==0, futime, ptime))
event <- with(mgus2, ifelse(pstat==0, 2*death, 1))
event <- factor(event, 0:2, labels=c("censor", "pcm", "death"))
mgus2$etime <- etime
mgus2$event <- event
xx <- rfsrc(Surv(etime, event)~sex, data=mgus2)
predict(xx)

I got error :

Error in Math.factor(cens) : ‘floor’ not meaningful for factors

Enter a frame number, or 0 to exit

1: predict(xx) 2: predict.rfsrc(xx) 3: generic.predict.rfsrc(object, newdata, m.target = m.target, importance = importance, err.block = err.block, na.action = na 4: get.event.info(object) 5: Math.factor(cens)

After I looking into function "get.event.info", I see it fails at

      if (!all(floor(cens) == abs(cens), na.rm = TRUE)) {
        stop("for survival families censoring variable must be coded as a non-negative integer")
      }

This stop information contradicts with competing risk analysis's requirement that the event should be a factor. Is there a misunderstanding from me or the package doesn't support competing risk survival?

My system information

version _
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 4.4
year 2018
month 03
day 15
svn rev 74408
language R
version.string R version 3.4.4 (2018-03-15) nickname Someone to Lean On
randomForestSRC version: 2.6.0 survival version: 2.41-3

kogalur commented 6 years ago

From the documentation:

"Censoring must be coded as a non-negative integer, where 0 indicates right-censoring, and non-zero values indicate different event types. While {0,1,2,..,J} is standard, and recommended, events can be coded non-sequentially, although 0 must always be used for censoring."