Description Usage Arguments Details Author(s) References Examples
View source: R/rsfes.surv_predict.R
Prediction with new data and return a saved forest with mean surv prob at each time points
1 | rsfes.surv_predict(rsfesfit, newdata, uniquetimes, trlength = 500)
|
rsfesfit |
|
newdata |
|
uniquetimes |
|
trlength |
Prediction with new data and return a saved forest with mean surv prob at each time points
Hong Wang
Random Survival Forest with Space Extensions for Censored Data, submitted to Artificial Intelligence in Medicine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (rsfesfit, newdata, uniquetimes, trlength = 500)
{
trees = rsfesfit$pectrees
colindexes = rsfesfit$colindexes
newindexes = rsfesfit$newindexes
if (trlength > length(rsfesfit$pectrees))
stop("Number of Trees for prediction should not be more than Number of Trees Fitted")
testpre <- matrix(0, nrow = dim(newdata)[1], ncol = length(uniquetimes))
colnames(testpre) = paste0(uniquetimes)
for (i in 1:trlength) {
{
if (ncol(newdata) <= 100) {
testdata = extspace_testdat(newdata, newindexes[[i]])
testdata = testdata[, colindexes[[i]]]
}
else {
testdata = newdata[, colindexes[[i]]]
testdata = extspace_testdat(testdata, newindexes[[i]])
}
testdata = as.data.frame(testdata)
predicts = predictSurvProb(trees[[i]], testdata,
uniquetimes)
predicts[is.na(predicts)] = 0
colnames(predicts) = paste0(uniquetimes)
testpre <- testpre + predicts
}
}
return(testpre/trlength)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.