| predict.rhf | R Documentation |
Obtain predicted values on test data using a trained random hazard forests.
## S3 method for class 'rhf'
predict(object, newdata, get.tree = NULL,
block.size = 10, membership = TRUE, seed = NULL, do.trace = FALSE,...)
object |
An |
newdata |
Test data frame. If omitted, the original training data is used and the full training forest is restored. |
get.tree |
Optional vector of integer indices specifying which trees to use for ensemble predictions. Defaults to using all trees in the forest. |
block.size |
Controls how cumulative error rate is reported. To obtain cumulative error every |
membership |
Logical flag indicating whether terminal node membership and inbag information should be returned. |
seed |
Negative integer specifying the random seed for reproducibility. |
do.trace |
Number of seconds between progress updates printed to the console. |
... |
Additional optional arguments passed to internal methods. |
Returns the predicted values for a random hazard forests.
An object of class c("rhf", "predict", family). The returned list
contains the fitted forest together with prediction summaries on the
evaluation grid time.interest. Important components include:
hazard.test, chf.test, risk.test, and
int.haz.test: test-set hazard, cumulative hazard, risk, and
integrated-hazard summaries when newdata is supplied.
hazard.oob, chf.oob, risk.oob, and
int.haz.oob: out-of-bag summaries for the training data.
hazard.inbag, chf.inbag, risk.inbag, and
int.haz.inbag: in-bag summaries when available.
id, yvar, and xvar: identifiers and processed
outcome/predictor data used by the returned prediction object.
pseudo.membership and inbag: terminal-node membership
and inbag information when membership = TRUE.
forest: the fitted forest object used to generate the
predictions.
If newdata is omitted, the function restores predictions for the
original training data using the stored forest and returns the same class of
object.
Hemant Ishwaran and Udaya B. Kogalur
Ishwaran H. and Kogalur U.B. (2007). Random survival forests for R, Rnews, 7(2):25-31.
Ishwaran H., Kogalur U.B., Blackstone E.H. and Lauer M.S. (2008). Random survival forests, Ann. App. Statist., 2:841-860.
Lee, D.K. and Chen N. and Ishwaran H (2021). Boosted nonparametric hazards with time-dependent covariates. Annals of Statistics, 49: 2101-2128.
rhf
## ------------------------------------------------------------
## canonical train/test example (synthetic data)
## ------------------------------------------------------------
simID <- 1
trn <- hazard.simulation(simID)$dta
tst <- hazard.simulation(simID)$dta
f <- "Surv(id, start, stop, event) ~ ."
## training
o <- rhf(f, trn, ntree = 3)
print(o)
## testing
p <- predict(o, tst)
print(p)
## ------------------------------------------------------------
## pbc: train/test example
## ------------------------------------------------------------
library("randomForestSRC")
data(pbc, package = "randomForestSRC")
pbc.raw <- na.omit(pbc)
trn <- sample(1:nrow(pbc.raw), size=nrow(pbc.raw) * .75, replace = FALSE)
d.trn <- convert.counting(Surv(days, status) ~ ., pbc.raw[trn,])
d.tst <- convert.counting(Surv(days, status) ~ ., pbc.raw[-trn,])
f <- "Surv(id, start, stop, event) ~ ."
## train/predict
o <- rhf(f, d.trn)
print(predict(o, d.tst))
## restore the forest
print(predict(o))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.