smoothed.hazard.rhf.RdCompute smoothed case-specific hazard curves (and corresponding
cumulative hazards) from a Random Hazard Forest (RHF) object. The
returned object is a lightweight list designed to be directly usable by
plot.rhf.
smoothed.hazard.rhf(
o,
method = c("median.loess", "loess"),
oob = TRUE,
span = 0.35,
degree = 1,
family = NULL,
eps = 1e-12,
suppress.warnings = TRUE,
trace = FALSE
)A fitted RHF object or predict object.
Smoothing strategy.
See Details for definitions of "loess" and "median.loess".
By default out-of-bag (OOB) values are returned for RHF
objects, but inbag values can be requested by setting this option
to FALSE. Does not apply to RHF predict objects.
Loess span passed to loess.
Loess degree passed to loess.
Loess family passed to loess.
Must be "gaussian" or "symmetric".
If NULL, defaults to "gaussian" for method="median.loess"
and "symmetric" for method="loess".
Small positive constant added before log-transforming hazards: log(h + eps).
If TRUE, warnings arising from loess() fitting/prediction are suppressed.
If TRUE, print progress messages.
Hazard curves are computed/smoothed on the grid o$time.interest.
Smoothing is performed on the log-hazard scale: log(hazard +
eps), and then back-transformed to the hazard scale.
method="loess"Applies loess smoothing to an already-constructed hazard matrix
stored in o (e.g. o$hazard.oob and/or
o$hazard.inbag), independently for each subject.
method="median.loess"For each subject and time bin, computes the median across trees of
the terminal-node (leaf) log-hazard log(h + eps) (using a
native C routine), then applies loess smoothing to the resulting
median log-hazard curve and back-transforms. This method requires
the fitted object to retain tree-specific hazard and membership
structures (e.g., o$forest$t.hazard and related arrays).
A list containing:
id, ensemble.id, yvar, time.interest copied from o.
Depending on target:
hazard.oob, chf.oob (out-of-bag), matrices of dimension
nSubj x length(time.interest).
hazard.inbag, chf.inbag (in-bag), matrices of dimension
nSubj x length(time.interest).
hazard.test, chf.test (test), matrices of dimension
nSubjTest x length(time.interest).
# \donttest{
## ------------------------------------------------------------
## canonical example using synthetic data
## includes both train/test scenarios
## ------------------------------------------------------------
simID <- 1
trn <- hazard.simulation(simID)$dta
tst <- hazard.simulation(simID)$dta
f <- "Surv(id, start, stop, event) ~ ."
## training/testing
o <- rhf(f, trn)
p <- predict(o, tst)
## default: median(log leaf hazard) + loess
so <- smoothed.hazard(o)
sp <- smoothed.hazard(p)
## the returned object can be passed directly to plot.rhf()
oldpar <- par(mfrow=c(1,1))
plot.rhf(so)
plot.rhf(sp)
par(oldpar)
## ------------------------------------------------------------
## peak vo2
## ------------------------------------------------------------
data(peakVO2, package = "randomForestSRC")
d <- convert.counting(Surv(ttodead, died)~., peakVO2)
f <- "Surv(id, start, stop, event) ~ ."
## training
o <- rhf(f, d)
oldpar <- par(mfrow=c(1,1))
## median loess
s0 <- smoothed.hazard(o)
ids <- o$ensemble.id[1:3]
plot.rhf(s0, idx = ids)
## loess smoothing
s1 <- smoothed.hazard(o, method = "loess")
plot.rhf(s1, idx = ids)
par(oldpar)
# }