tune.treesize.rhf.RdTune 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, ...)Survival formula for rhf, typically
Surv(id, start, stop, event) ~ ..
Counting-process data frame containing the variables in
formula.
Number of trees grown at each candidate treesize.
Number of random split points tried per variable.
Minimum number of events in a terminal node; passed to
rhf.
Tuning criterion. "risk" minimizes mean OOB risk;
"iAUC" maximizes integrated AUC obtained using
auct.rhf.
Optional list of arguments passed to
auct.rhf when perf = "iAUC".
Smallest treesize considered.
Largest treesize considered.
Multiplier used when computing the default upper bound if
upper is NULL.
Discrete search strategy: "golden" (golden-section
search) or "bisect" (bisection-style search).
Maximum number of distinct treesize values
evaluated by the search.
Tolerance for the bracketing interval width used by the search algorithms.
Optional random seed for reproducible comparisons across tree sizes.
Logical; if TRUE, print progress messages when
evaluating new treesize values.
Logical; if TRUE, return the RHF object at the
best treesize.
Additional arguments passed to rhf.
Arguments to
customize plot.
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.
# \donttest{
## ------------------------------------------------------------
## 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)
# }