Predictions from gradient boosting for competing risks
Source:R/boosting.R
predict.survival_boost.Rdpredict() gives the cumulative incidence of each cause, or the probability of being free of
any event, for each row of newdata (or for the subjects the model was fit to), at times.
At each time, these are the softmax of the class scores, so the incidences of all the causes
and the probability of being free of any event add up to 1. The curves aren't constrained to
be monotone in time.
Arguments
- object
A
survival_boost()fit.- newdata
A data frame with the covariates of the subjects to predict for. The default is the data the model was fit to.
- type
"cif"(the default) for the cumulative incidence of each cause, or"survival"for the probability of being free of any event.- times
The times to evaluate at. The default is the time grid of the fit (see the
n_time_grid_stepsargument ofsurvival_boost()).- ...
Unused.
Value
A data frame. For "cif", one row per subject, cause, and time: subject (the row of
newdata), cause, time, and estimate. For "survival", one row per subject and time:
subject, time, and estimate. A row with a missing covariate gets NA.
Examples
mgus <- data.frame(
time = c(30, 45, 60, 72, 80, 95, 110, 120, 130, 150, 160, 180, 200, 210, 220, 240, 45, 95,
35, 140),
status = c(1, 2, 0, 2, 1, 2, 0, 1, 2, 2, 0, 1, 1, 2, 0, 2, 0, 1, 2, 1),
age = c(62, 75, 58, 80, 66, 71, 59, 64, 77, 82, 60, 68, 55, 79, 63, 74, 70, 61, 81, 57),
hgb = c(13, 12, 14, 11, 13, 12, 15, 12, 11, 10, 14, 13, 12, 11, 15, 12, 13, 12, 10, 14)
)
mgus$event <- factor(mgus$status, levels = 0:2, labels = c("censor", "pcm", "death"))
set.seed(1)
fit <- survival_boost(Surv(time, event) ~ age + hgb,
data = mgus, n_estimators = 30, max_depth = 2, min_samples_leaf = 5
)
newdata <- data.frame(age = c(60, 80), hgb = c(14, 10))
predict(fit, newdata = newdata, times = 100)
#> subject cause time estimate
#> 1 1 pcm 100 0.20225751
#> 2 1 death 100 0.09326811
#> 3 2 pcm 100 0.08654087
#> 4 2 death 100 0.42120274
predict(fit, newdata = newdata, type = "survival", times = c(50, 100, 200))
#> subject time estimate
#> 1 1 50 0.8475447
#> 2 1 100 0.7044744
#> 3 1 200 0.2483512
#> 4 2 50 0.7147971
#> 5 2 100 0.4922564
#> 6 2 200 0.1482115