View source: R/tune.treesize.rhf.R
| tune.treesize.rhf | R Documentation |
Tune the treesize for a Random Hazard Forest using either
out-of-bag (OOB) empirical risk or an OOB integrated AUC computed by
auct.rhf.
tune.treesize.rhf(
formula,
data,
ntree = 500,
nsplit = 10,
nodesize = NULL,
perf = c("risk", "iAUC"),
auct.args = NULL,
lower = 2L,
upper = NULL,
C = 3,
method = c("golden", "bisect"),
max.evals = 20L,
bracket.tol = 2L,
seed = NULL,
verbose = TRUE,
forest = TRUE,
...
)
tune.iAUC.rhf(
formula,
data,
auct.args = NULL,
...
)
## S3 method for class 'tune.treesize.rhf'
plot(x, ylab = NULL, main = NULL,
se.band = TRUE, se.mult = 1, ylim = NULL, ...)
formula |
Survival formula for |
data |
Counting-process data frame containing the variables in
|
ntree |
Number of trees grown at each candidate |
nsplit |
Number of random split points tried per variable. |
nodesize |
Minimum number of events in a terminal node; passed to
|
perf |
Tuning criterion. |
auct.args |
Optional list of arguments passed to
|
lower |
Smallest |
upper |
Largest |
C |
Multiplier used when computing the default upper bound if
|
method |
Discrete search strategy: |
max.evals |
Maximum number of distinct |
bracket.tol |
Tolerance for the bracketing interval width used by the search algorithms. |
seed |
Optional random seed for reproducible comparisons across tree sizes. |
verbose |
Logical; if |
forest |
Logical; if |
... |
Additional arguments passed to |
x, ylab, main, se.band, se.mult, ylim |
Arguments to
customize |
The alias tune.rhf is provided for convenience.
Rpeatedly fits a hazard forest with different values of treesize
and selects the value that optimizes the chosen criterion
perf. When perf = "risk", the criterion is the mean OOB
risk. When perf = "iAUC", auct.rhf is applied to
each fit and the criterion is 1 - iAUC.uno. tune.iAUC is
a wrapper around tune.rhf with perf = "iAUC", using
default auct.rhf settings when auct.args = NULL.
An object of class "tune.treesize.rhf" with components
best.size: optimal treesize;
best.err: minimal criterion value (mean OOB risk if
perf = "risk", or 1 - iAUC.uno if perf = "iAUC");
path: data frame with evaluated treesize values and
corresponding criterion values (and an iAUC column when
perf = "iAUC");
forest: RHF fit at best.size when
forest = TRUE.
rhf, auct.rhf
## ------------------------------------------------------------
## Example: tuning treesize by OOB empirical risk
## ------------------------------------------------------------
set.seed(7)
d <- hazard.simulation(1)$dta
f <- "Surv(id, start, stop, event) ~ ."
## tune.rhf is an alias for tune.treesize.rhf
tuneRisk <- tune.rhf(f, d) ## same as tune.treesize.rhf(f, d)
oldpar <- par(mfrow = c(1, 1))
plot(tuneRisk)
par(oldpar)
tuneRisk$best.size # treesize minimizing mean OOB risk
tuneRisk$best.err
## Access the tuned forest and refit AUC diagnostics if desired
best.forest <- tuneRisk$forest
a.risk <- auct.rhf(best.forest)
print(a.risk$iAUC.uno)
## ------------------------------------------------------------
## Example: tuning treesize by iAUC
## ------------------------------------------------------------
set.seed(7)
tuneiAUC <- tune.iAUC(f, d)
oldpar <- par(mfrow = c(1, 1))
plot(tuneiAUC)
par(oldpar)
print(tuneiAUC$best.size)
print(1 - tuneiAUC$best.err)
best.forest.iauc <- tuneiAUC$forest
a.iauc <- auct.rhf(best.forest.iauc)
print(1 - a.iauc$iAUC.uno)
## ------------------------------------------------------------
## Example: tuning treesize by iAUC with bootstrap s.e.
## ------------------------------------------------------------
set.seed(7)
tuneiAUC.boot <- tune.iAUC(f, d, auct.args=list(bootstrap.rep=25))
oldpar <- par(mfrow = c(1, 1))
plot(tuneiAUC.boot)
par(oldpar)
## ------------------------------------------------------------
## Example: tuning by hazard-based incident AUC
## ------------------------------------------------------------
set.seed(7)
tuneHazInc <- tune.iAUC(
f, d,
auct.args = list(
marker = "hazard",
method = "incident"
)
)
oldpar <- par(mfrow = c(1, 1))
plot(tuneHazInc)
par(oldpar)
print(tuneHazInc$best.size)
print(tuneHazInc$best.err)
## Confirm the tuned incident AUC on the selected forest
best.forest.haz <- tuneHazInc$forest
aHazInc <- auct.rhf(
best.forest.haz,
marker = "hazard",
method = "incident"
)
print(aHazInc)
print(1 - aHazInc$iAUC.uno)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.