Skip to contents

competing_risk_forest() grows n_estimators trees for a competing-risks response, each on a bootstrap sample of the subjects, with a random subset of max_features covariates tried at each split. Each split is the one with the largest composite log-rank statistic over the causes, with the risk set of each cause keeping the subjects who had another cause earlier (as for the subdistribution hazard), so the splits separate the cumulative incidence curves directly. Each leaf holds the Aalen-Johansen cumulative incidence of every cause among its subjects, and a prediction is the average over the trees of the curves of the leaves the subject falls in. Like random_survival_forest(), the forest finds nonlinear effects and interactions without a model for the hazards (Ishwaran et al., 2014).

Usage

competing_risk_forest(
  formula,
  data,
  subset,
  na.action = stats::na.omit,
  n_estimators = 100,
  max_depth = NULL,
  min_samples_split = 6,
  min_samples_leaf = 3,
  max_features = "sqrt",
  bootstrap = TRUE,
  oob_score = FALSE
)

Arguments

formula

A formula with a competing-risks response on the left, Surv(time, event) with event a factor whose first level is censoring, and the covariates on the right, such as Surv(time, event) ~ age + sex. Factors are coded with treatment contrasts.

data

A data frame holding the variables in formula.

subset

An optional expression selecting the rows of data to use.

na.action

What to do with rows that have missing values. The default drops them.

n_estimators

The number of trees, at least 1. The default is 100.

max_depth

The largest number of splits from the first group to a leaf, or NULL (the default) for no limit.

min_samples_split

The smallest group that can be split, at least 2. The default is 6.

min_samples_leaf

The fewest subjects on each side of a split, at least 1. The default is 3.

max_features

The number of covariates tried at each split: "sqrt" (the square root of the number of columns, rounded down, the default), "log2", NULL (all of them), a whole number, or a fraction between 0 and 1 of the columns.

bootstrap

Whether to grow each tree on a bootstrap sample. The default is TRUE. The out-of-bag concordance and variable_importance() need it.

oob_score

Whether to compute the out-of-bag concordance. The default is FALSE.

Value

A competing_risk_forest object. Use predict() for cumulative incidence curves and risk scores, and variable_importance() for the permutation importance of each covariate. The object also holds times (the event times the curves are given at), states (the causes), oob_score (the out-of-bag concordance for the first cause, or NA), n, and n_event (the number of events of any cause).

Details

The statistic of a split pools the causes: with \(O_k - E_k\) the observed minus expected events of cause \(k\) in one child and \(V_k\) its hypergeometric variance, it's \((\sum_k (O_k - E_k))^2 / \sum_k V_k\). A node is split while it has min_samples_split subjects and at least one event, and every split leaves min_samples_leaf subjects on each side.

With bootstrap samples, each subject is left out of about a third of the trees. The out-of-bag concordance (with oob_score = TRUE) scores each subject with only those trees, using the risk score of the first cause and the other causes as censoring. variable_importance() measures how much worse that score gets when a covariate's values are shuffled. The forest uses R's random number generator, so call set.seed() first for results that can be repeated.

References

Ishwaran, H., Gerds, T. A., Kogalur, U. B., Moore, R. D., Gange, S. J., and Lau, B. M. (2014). Random survival forests for competing risks. Biostatistics, 15(4), 757-773.

See also

predict.competing_risk_forest(), aalen_johansen() for the curves without covariates, and fine_gray() for a regression model of one cause's cumulative incidence.

Examples

mgus <- data.frame(
  time = c(30, 45, 60, 72, 80, 95, 110, 120, 130, 150, 160, 180, 200, 210, 220, 240, 45, 95,
    50, 100, 140, 170, 190, 230),
  status = c(1, 2, 0, 2, 1, 2, 0, 1, 2, 2, 0, 1, 1, 2, 0, 2, 0, 1, 2, 1, 0, 2, 1, 2),
  age = c(62, 75, 58, 80, 66, 71, 59, 64, 77, 82, 60, 68, 55, 79, 63, 74, 70, 61, 78, 57, 69,
    81, 65, 73),
  hgb = c(13, 12, 14, 11, 13, 12, 15, 12, 11, 10, 14, 13, 12, 11, 15, 12, 13, 12, 11, 14, 13,
    10, 12, 11)
)
mgus$event <- factor(mgus$status, levels = 0:2, labels = c("censor", "pcm", "death"))

set.seed(1)
forest <- competing_risk_forest(Surv(time, event) ~ age + hgb,
  data = mgus, n_estimators = 50, oob_score = TRUE
)
forest
#> <competing_risk_forest> Surv(time, event) ~ age + hgb
#> 50 competing-risks log-rank trees, 1 of 2 features tried per split, bootstrap samples.
#> Causes: pcm, death. n = 24, events = 18
#> Out-of-bag concordance for pcm = 0.6495

# The cumulative incidence of death for two new subjects
newdata <- data.frame(age = c(60, 80), hgb = c(14, 11))
predict(forest, newdata = newdata, cause = "death", times = c(100, 200))
#>   subject time  estimate
#> 1       1  100 0.0000000
#> 2       1  200 0.0000000
#> 3       2  100 0.4042937
#> 4       2  200 0.7908175