predict.icrf: icrf predictions

predict.icrfR Documentation

icrf predictions

Description

Prediction method of test data using interval censored recursive forest. (Quoted statements are from randomForest by Liaw and Wiener unless otherwise mentioned.)

Usage

## S3 method for class 'icrf'
predict(
  object,
  newdata,
  predict.all = FALSE,
  proximity = FALSE,
  nodes = FALSE,
  smooth = TRUE,
  ...
)

Arguments

object

an object of icrf class generated by the function icrf.

newdata

'a data frame or matrix containing new data. (Note: If not given, the predicted survival estimate of the training data set in the object is returned.)'

predict.all

'Should the predictions of all trees be kept?'

proximity

'Should proximity measures be computed?'

nodes

'Should the terminal node indicators (an n by ntree matrix) be returned? If so, it is in the "nodes" attribute of the returned object.'

smooth

Should smoothed curve be returned?

...

'not used currently.'

Value

A matrix of predicted survival probabilities is returned where the rows represent the observations and the columns represent the time points. 'If predict.all=TRUE, then the returned object is a list of two components: aggregate, which is the vector of predicted values by the forest, and individual, which is a matrix where each column contains prediction by a tree in the forest.' The forest is either the last forest or the best forest as specified by returnBest argument in icrf function.

'If proximity=TRUE, the returned object is a list with two components: pred is the prediction (as described above) and proximity is the proximitry matrix.'

'If nodes=TRUE, the returned object has a "nodes" attribute, which is an n by ntree matrix, each column containing the node number that the cases fall in for that tree.'

Author(s)

Hunyong Cho, Nicholas P. Jewell, and Michael R. Kosorok.

References

Cho H., Jewell N. J., and Kosorok M. R. (2020+). "Interval censored recursive forests"

Examples

# rats data example
# Note that this is a toy example. Use a larger ntree and nfold in practice.
library(survival)  # for Surv()
data(rat2)
set.seed(1)
samp <- sample(1:dim(rat2)[1], 200)
rats.train <- rat2[samp, ]
rats.test <- rat2[-samp, ]
L = ifelse(rats.train$tumor, 0, rats.train$survtime)
R = ifelse(rats.train$tumor, rats.train$survtime, Inf)

 set.seed(2)
 rats.icrf.small <-
   icrf(survival::Surv(L, R, type = "interval2") ~ dose.lvl + weight + male + cage.no,
        data = rats.train, ntree = 10, nfold = 3, proximity = TRUE)

 # predicted survival curve for the training data
 predict(rats.icrf.small)
 predict(rats.icrf.small, smooth = FALSE) # non-smoothed

 # predicted survival curve for new data
 predict(rats.icrf.small, newdata = rats.test)
 predict(rats.icrf.small, newdata = rats.test, proximity = TRUE)

 # time can be extracted using attr()
 newpred = predict(rats.icrf.small, newdata = rats.test)
 attr(newpred, "time")

 newpred2 = predict(rats.icrf.small, newdata = rats.test, proximity = TRUE)
 attr(newpred2$predicted, "time")





icrf documentation built on Oct. 30, 2022, 1:05 a.m.

Related to predict.icrf in icrf...