utilities_internal.RdThese helper functions support advanced random-hazard-forest workflows, including data conversion, simulation, and predictor weighting.
convert.counting(f, dta, scale = FALSE)
convert.standard.counting(formula, data,
scale = FALSE,
rescale.from.attr = FALSE,
keep.id = FALSE,
keep.row_index = FALSE,
sorted = FALSE,
id.default = "id",
eps = 1e-8,
landmark.time = NULL,
landmark.use.tminus = TRUE,
return.type = c("survival", "x"),
keep.landmark.cols = FALSE)
hazard.simulation(type = 1,
n = 500, p = 10, nrecords = 7,
scale = FALSE, ngrid = 1e5, ...)
xvar.wt.rhf(f, d, scale = 4, parallel = TRUE)A survival formula. convert.counting() expects a
standard survival formula such as Surv(time, event) ~ ..
convert.standard.counting() expects counting-process style input such
as Surv(id, start, stop, event) ~ . or
Surv(start, stop, event) ~ ..
Input data frame.
Logical or numeric time-scaling control, depending on the helper being used.
Logical; if TRUE,
convert.standard.counting() rescales times using attributes stored on
the counting-process data.
Logical; if TRUE, retain the subject identifier in the
returned data frame from convert.standard.counting().
Logical; if TRUE, include the source row index
in the output of convert.standard.counting().
Logical; indicates whether the counting-process input is already sorted by subject and time.
Default subject identifier column name used when
formula omits an explicit id term.
Small positive tolerance used in internal time comparisons.
Optional landmark time passed to
convert.standard.counting().
Logical; controls how landmark covariates are
selected when landmark.time is supplied.
Character string specifying whether
convert.standard.counting() returns a standard survival outcome plus
covariates ("survival") or only the covariate frame ("x").
Logical; if TRUE, keep auxiliary landmark
columns in the output of convert.standard.counting().
Simulation scenario. May be given numerically
(1, 2, 3) or by name.
Simulation controls used by
hazard.simulation().
Additional arguments passed to the selected simulation engine.
Logical; if TRUE, allow parallel work in
xvar.wt.rhf().
convert.counting() converts standard right-censored survival data to the
counting-process representation expected by rhf().
convert.standard.counting() converts counting-process style RHF data to
a conventional survival-analysis data frame or to a predictor-only frame.
hazard.simulation() generates synthetic counting-process data together
with the corresponding theoretical hazard function.
xvar.wt.rhf() computes variable weights that can be supplied to
rhf(..., xvar.wt = ...).
The returned value depends on the helper:
convert.counting(): a data frame with columns
id, start, stop, event, followed by the predictor
columns from the input data.
convert.standard.counting(): a data frame in the format requested
by return.type. With return.type = "survival", the leading
columns are time and event; additional covariate and optional
helper columns may also be present. The function may return an empty data
frame when no valid rows remain after filtering.
hazard.simulation(): a list with components dta
(simulated counting-process data frame), haz
(a function that evaluates the true hazard on a supplied time grid), and
scale (the time-scaling factor used in the simulation).
xvar.wt.rhf(): a named numeric vector of predictor weights for
the xvar.wt argument of rhf().