rsfes: Grow a random survival forest with space extensions

Description Usage Arguments Details Author(s) References Examples

Description

Grow a random survival forest with space extensions

Usage

1
rsfes(x, y, trlength = 500, mtry = floor(sqrt(ncol(x))), control = control, na.action = na.omit)

Arguments

x
y
trlength
mtry
control
na.action

Details

Grow a random survival forest with space extensions

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
40
41
42
43
44
45
46
47
48
49
50
51
52
##---- 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 (x, y, trlength = 500, mtry = floor(sqrt(ncol(x))), 
    control = control, na.action = na.omit) 
{
    Call <- match.call()
    if (!inherits(y, "Surv")) 
        stop("Response must be a 'survival' object - use the 'Surv()' function")
    ny <- ncol(y)
    n <- nrow(y)
    status <- y[, ny]
    survtime = y[, 1L]
    if (any(survtime <= 0)) 
        stop("Observation time must be > 0")
    if (all(status == 0)) 
        stop("No deaths in training data set")
    if (!missing(control)) 
        controls[names(control)] <- control
    pectrees <- vector(mode = "list", length = trlength)
    colindexes <- vector(mode = "list", length = trlength)
    newindexes <- vector(mode = "list", length = trlength)
    varimp <- NULL
    for (i in 1:trlength) {
        if (ncol(x) <= 100) {
            newx = extspace_dat(x)
            newindexes[[i]] = newx$ncombsub
            colindex = sample(ncol(newx$newxdata), size = mtry * 
                2)
            colindexes[[i]] = colindex
            newxdata = newx$newxdata[, colindex]
        }
        else {
            colindex = sample(ncol(x), size = mtry)
            colindexes[[i]] = colindex
            newx = extspace_dat(x[, colindex])
            newindexes[[i]] = newx$ncombsub
            newxdata = newx$newxdata
        }
        mf = data.frame(y[, 1], y[, 2], newxdata)
        colnames(mf)[c(1, 2)] = c("time", "status")
        trainindex = sample(nrow(mf), replace = T)
        trset = mf[trainindex, ]
        pectrees[[i]] = pecRpart(Surv(time, status) ~ ., data = trset)
    }
    fit = pectrees
    class(fit) <- "rsfes"
    return(list(pectrees = pectrees, colindexes = colindexes, 
        newindexes = newindexes))
  }

whcsu/rsfse documentation built on Dec. 4, 2019, 2:10 p.m.