utilities_internal: Advanced Utility Functions for RHF Workflows

internal.utilsR Documentation

Advanced Utility Functions for RHF Workflows

Description

These helper functions support advanced random-hazard-forest workflows, including data conversion, simulation, and predictor weighting.

Usage

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)

Arguments

f, formula

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) ~ ..

dta, data, d

Input data frame.

scale

Logical or numeric time-scaling control, depending on the helper being used.

rescale.from.attr

Logical; if TRUE, convert.standard.counting() rescales times using attributes stored on the counting-process data.

keep.id

Logical; if TRUE, retain the subject identifier in the returned data frame from convert.standard.counting().

keep.row_index

Logical; if TRUE, include the source row index in the output of convert.standard.counting().

sorted

Logical; indicates whether the counting-process input is already sorted by subject and time.

id.default

Default subject identifier column name used when formula omits an explicit id term.

eps

Small positive tolerance used in internal time comparisons.

landmark.time

Optional landmark time passed to convert.standard.counting().

landmark.use.tminus

Logical; controls how landmark covariates are selected when landmark.time is supplied.

return.type

Character string specifying whether convert.standard.counting() returns a standard survival outcome plus covariates ("survival") or only the covariate frame ("x").

keep.landmark.cols

Logical; if TRUE, keep auxiliary landmark columns in the output of convert.standard.counting().

type

Simulation scenario. May be given numerically (1, 2, 3) or by name.

n, p, nrecords, ngrid

Simulation controls used by hazard.simulation().

...

Additional arguments passed to the selected simulation engine.

parallel

Logical; if TRUE, allow parallel work in xvar.wt.rhf().

Details

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 = ...).

Value

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().

See Also

rhf, predict.rhf


randomForestRHF documentation built on April 24, 2026, 1:07 a.m.