extspace_dat: space extension for training data

Description Usage Arguments Details Author(s) References Examples

View source: R/extspace_dat.R

Description

space extension for training data

Usage

1
extspace_dat(xdata)

Arguments

xdata

space extension for training data

Details

space extension for training data

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
##---- 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 (xdata) 
{
    xdata = model.matrix(~0 + ., as.data.frame(xdata))
    p = ncol(xdata)
    d = p
    ncomb <- combn(p, 2)
    ncombsub <- ncomb[, sample(choose(p, 2), d)]
    newx <- vector(mode = "list", length = d)
    newx <- NULL
    new_names <- paste("newvar", 1:d, sep = "_")
    for (i in 1:p) {
        newx = cbind(newx, xdata[, ncombsub[2, i]] - xdata[, 
            ncombsub[1, i]])
    }
    colnames(newx) <- new_names
    newxdata = cbind(xdata, newx)
    return(list(newxdata = newxdata, ncombsub = ncombsub))
  }

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