rsfes.bs_predict: Prediction with new data and return a saved forest brier...

Description Usage Arguments Details Author(s) References Examples

View source: R/rsfes.bs_predict.R

Description

Prediction with new data and return a saved forest brier score function

Usage

1
rsfes.bs_predict(rsfesfit, testdat, rii, trlength = 500)

Arguments

rsfesfit
testdat
rii
trlength

Details

Prediction with new data and return a saved forest brier score function

Author(s)

HONG WANG

References

Random Survival Forest with Space Extensions for Censored Data, submitted to Artificial Intelligence in Medicine

Examples

 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
35
36
37
38
39
##---- 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, testdat, rii, trlength = 500) 
{
    trees = rsfesfit$pectrees
    colindexes = rsfesfit$colindexes
    newindexes = rsfesfit$newindexes
    newdata = testdat[, -c(rii)]
    if (trlength > length(rsfesfit$pectrees)) 
        stop("Number of Trees for prediction should not be more than Number of Trees Fitted")
    testpre <- NULL
    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]])
            }
            newtestdat = cbind.data.frame(testdat[, c(rii)], 
                testdata)
            pecerror <- pec(list(rsfse = trees[[i]]), formula = Surv(time, 
                status) ~ ., data = newtestdat, cens.model = "marginal", 
                reference = FALSE)
            print((pecerror))
            pecerror$AppErr$rsfse[is.na(pecerror$AppErr$rsfse)] = 0
            predicts = crps(pecerror)[1]
            print(crps(pecerror))
            testpre <- cbind(predicts, testpre)
        }
    }
    ensemble_predictions <- rowMeans(testpre)
    return(ensemble_predictions)
  }

whcsu/sfse documentation built on Dec. 4, 2019, 2:11 p.m.