gradient_boosting_survival_analysis() builds a risk score \(F(x)\) as a sum of small
regression trees, in place of the linear predictor of cox_ph(). It starts from
\(F = 0\), and at each of n_estimators rounds fits a squared-error regression tree of depth
at most max_depth to the martingale residuals of the current score,
\(\delta_i - e^{F(x_i)} \hat H_0(t_i)\), which are the negative gradient of the negative log
partial likelihood, with \(\hat H_0\) the Breslow estimate of the baseline cumulative hazard.
The tree's predictions, shrunk by learning_rate, are added to the score. The trees can find
nonlinear effects and, with max_depth above 1, interactions, so no linear form is assumed
for the covariates, while the score still acts on the hazard proportionally.
Usage
gradient_boosting_survival_analysis(
formula,
data,
subset,
na.action = stats::na.omit,
n_estimators = 100,
learning_rate = 0.1,
max_depth = 3,
min_samples_leaf = 3,
subsample = 1,
max_features = NULL
)Arguments
- formula
A formula with a right-censored
Surv()response on the left and the covariates on the right, such asSurv(time, status) ~ age + sex. Factors are coded with treatment contrasts, and each column is split on separately.- data
A data frame holding the variables in
formula.- subset
An optional expression selecting the rows of
datato use.- na.action
What to do with rows that have missing values. The default drops them.
- n_estimators
The number of boosting rounds (trees), at least 1. The default is
100.- learning_rate
The shrinkage of each tree, a positive number. The default is
0.1.- max_depth
The largest depth of each tree, at least 1. The default is
3.- min_samples_leaf
The fewest subjects in each leaf of a tree, at least 1. The default is
3.- subsample
The share of the subjects each tree is grown on, greater than 0 and at most 1. The default is
1(all of them).- max_features
The number of covariates tried at each split:
NULL(all of them, the default),"sqrt"or"log2"(the square root or base-2 logarithm of the number of columns, rounded down), a whole number, or a fraction between 0 and 1 of the columns. At least one is always tried.
Value
A gradient_boosting_survival_analysis object. Use predict() for risk scores and
survival or cumulative hazard curves, and variable_importance() for the share of the
reduction in squared error credited to each covariate. The object also holds times and
cumhaz (the baseline cumulative hazard at the event times), n, and n_event.
Details
A smaller learning_rate needs more trees but usually predicts better. With subsample below
1, each tree is grown on a random share of the subjects (drawn without replacement, and at
least 2 * min_samples_leaf of them), which is stochastic gradient boosting. With
max_features smaller than the number of covariates, each split looks at a random subset of
them. Both use R's random number generator, so call set.seed() first for results that can be
repeated.
Survival curves are \(\exp\{-\hat H_0(t) e^{F(x)}\}\), with \(\hat H_0\) the Breslow estimate at the final scores.
References
Friedman, J. H. (2001). Greedy function approximation: a gradient boosting machine. The Annals of Statistics, 29(5), 1189-1232.
Ridgeway, G. (1999). The state of boosting. Computing Science and Statistics, 31, 172-181.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567, 144,
613, 707, 61, 88, 301, 81, 624, 371, 394, 520, 574, 118, 390, 12),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2),
age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68, 68, 60, 57, 67, 70, 63, 56, 57, 67,
49, 50, 58, 72, 70, 60, 70, 53, 74),
ph.ecog = c(1, 0, 0, 1, 0, 1, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 0, 1, 1, 2, 0, 0, 1, 1, 1, 1,
2, 1, 1)
)
fit <- gradient_boosting_survival_analysis(Surv(time, status) ~ age + ph.ecog,
data = lung, n_estimators = 50, learning_rate = 0.05, max_depth = 2
)
fit
#> <gradient_boosting_survival_analysis> Surv(time, status) ~ age + ph.ecog
#> 50 regression trees of depth at most 2, learning rate 0.05, Cox partial likelihood.
#> n = 30, events = 26, features = 2
# Risk scores and survival curves for two new subjects
newdata <- data.frame(age = c(55, 72), ph.ecog = c(0, 2))
predict(fit, newdata = newdata)
#> [1] 0.4488307 0.9364748
predict(fit, newdata = newdata, type = "survival", times = c(100, 300))
#> subject time estimate
#> 1 1 100 0.9292954
#> 2 1 300 0.8423486
#> 3 2 100 0.8581312
#> 4 2 300 0.6991020
variable_importance(fit)
#> term importance
#> 1 age 0.5056965
#> 2 ph.ecog 0.4943035