Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using caret for survival analysis (random survival forest)

Tags:

r

r-caret

Is there a way to use caret for Survival Analysis. I really like how easy to use it is. I tried fitting a random survival forest using the party package, which is on caret's list.

This works:

library(survival)
library(caret)
library(party)


fitcforest <- cforest(Surv(futime, death) ~ sex+age, data=flchain,
                     controls = cforest_classical(ntree = 1000))

but using caret I get an error:

fitControl <- trainControl(## 10-fold CV
  method = "repeatedcv",
  number = 10,
  repeats = 2,
)

cforestfit <- train(Surv(futime, death) ~ sex+age,data=flchain, method="cforest",trControl = fitControl)

I get this error:

Error: nrow(x) == length(y) is not TRUE

Is there a way to make these Surv object work with caret? Can I use other survival analysis oriented packages with caret?

thanks

like image 485
spore234 Avatar asked Apr 30 '15 08:04

spore234


2 Answers

Not yet. That is one of two major updates that should be coming soon (the other expands pre-processing).

Contact me offline if you are interested in helping the development and/or testing of those features.

Thanks,

Max

like image 69
topepo Avatar answered Nov 16 '22 01:11

topepo


I have found no way to train survival models with caret. As an alternative, the mlr framework (1) has a set of survival learners (2). I have found mlr to be extremely user-friendly and useful.

  1. mlr: http://mlr-org.github.io/mlr-tutorial/release/html/
  2. survival learners in mlr: http://mlr-org.github.io/mlr-tutorial/release/html/integrated_learners/index.html#survival-analysis-15
like image 27
Michael Avatar answered Nov 15 '22 23:11

Michael