Closed DarioS closed 2 years ago
Read the help file, i.e. help(Surv). The 'value' section will tell you that a Surv object is, under the covers, a matrix. So your xgboost function is
> library(survival)
> temp <- Surv(1:6, c(1,0,1,0,1,1))
> temp
[1] 1 2+ 3 4+ 5 6
> ifelse(temp[,2]==1, temp[,1], -temp[,1])
[1] 1 -2 3 -4 5 6
I would like to create a convenience function that converts a
Surv
object into the format required by xgboost for itssurvival:cox
objective. Bizarrely, it only accepts a vector of numbers, with negative numbers indicating censored observations. If there were accessors such astime(surv)
andevent(surv)
it would be easy to extract the vectors and convert the data into the silly xgboost format.Or, could
as.vector
be changed to produce the silly xgboost format instead of what it does now?