
Aalen Johansen Competing Risks Learner
Source:R/LearnerCompRisksAalenJohansen.R
mlr_learners_cmprsk.aalen.RdThis learner estimates the Cumulative Incidence Function (CIF) for competing risks using the empirical Aalen-Johansen (AJ) estimator.
Transition probabilities to each competing event are computed from the training
data via the survival::survfit.formula() function.
Each predicted CIF is evaluated on its cause's unique training event times.
The grid uses the fitted times, so survfit() can group nearly identical event
times into a single time point.
With observation weights, a time appears in a cause's grid only if the total
weight of that cause's events at that time is positive.
These numeric grids are stored in the prediction's $times field.
Causes without training events have a zero CIF anchored at time 0.
Dictionary
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
Meta Information
Task type: “cmprsk”
Predict Types: “cif”
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”, “POSIXct”, “Date”
Required Packages: mlr3, mlr3cmprsk, survival
References
Aalen, O O, Johansen, Soren (1978). “An empirical transition matrix for non-homogeneous Markov chains based on censored observations.” Scandinavian journal of statistics, 141–150.
See also
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html#sec-learners
as.data.table(mlr_learners)for a table of available Learners in the running sessionmlr3pipelines to combine learners with pre- and postprocessing steps
mlr3tuning for tuning of hyperparameters
Other competing risk learners:
mlr_learners_cmprsk.fg
Super classes
mlr3::Learner -> LearnerCompRisks -> LearnerCompRisksAalenJohansen
Active bindings
native_model(survival::survfit)
The fitted model.
Methods
LearnerCompRisksAalenJohansen$importance()
All features have a score of 0 for this learner.
This method exists solely for compatibility with the mlr3 ecosystem,
as this learner is used as a fallback for other survival learners that
may require an importance() method.
Returns
Named numeric().
LearnerCompRisksAalenJohansen$selected_features()
Selected features are always the empty set for this learner.
This method is implemented only for compatibility with the mlr3 API,
as this learner does not perform feature selection.
Examples
# Define a task
task = tsk("pbc")
task$select(c("age", "chol", "albumin", "ast", "bili", "protime"))
# Stratify by event status
task$set_col_roles(cols = "status", add_to = "stratum")
task
#>
#> ── <TaskCompRisks> (276x8): Mayo Clinic Primary Biliary Cholangitis Data ───────
#> • Target: time and status
#> • Properties: strata
#> • Features (6):
#> • dbl (4): albumin, ast, bili, protime
#> • int (2): age, chol
#> • Strata: status
#> • Causes (2):
#> • 1 (Liver transplantation): 18 (6.5%)
#> • 2 (Death without transplantation): 111 (40.2%)
#> • Censored: 147 (53.3%)
# Create training and test sets
set.seed(42L)
part = partition(task)
# Define the learner
learner = lrn("cmprsk.aalen")
# Train on the training set
learner$train(task, row_ids = part$train)
learner$native_model
#> Call: survfit(formula = task$formula("1"), data = task$data(cols = task$target_names),
#> weights = NULL)
#>
#> n nevent rmean se(rmean)*
#> (s0) 184 0 2769.9515 123.93141
#> Liver transplantation 184 12 243.9978 68.02923
#> Death without transplantation 184 74 1542.0507 123.46668
#> *restricted mean time in state (max time = 4556 )
# Predict CIFs for the test set
predictions = learner$predict(task, row_ids = part$test)
predictions
#>
#> ── <PredictionCompRisks> for 92 observations: ──────────────────────────────────
#> row_ids time event CIF
#> 1 400 2 <list[2]>
#> 10 3762 2 <list[2]>
#> 16 131 2 <list[2]>
#> --- --- --- ---
#> 157 2241 1 <list[2]>
#> 208 837 1 <list[2]>
#> 213 1435 1 <list[2]>
# Score predictions
predictions$score()
#> cmprsk.ibs
#> 0.1775434