Aalen Johansen Competing Risks Learner
Source:R/LearnerCompRisksAalenJohansen.R
mlr_learners_cmprsk.aalen.Rd
This learner estimates the Cumulative Incidence Function (CIF) for competing risks using the empirical Aalen-Johansen (AJ) estimator.
Transition probabilities to each event are computed from the training data via the survfit function and predictions are made at all unique times (both events and censoring) observed in the training set.
Dictionary
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():
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.
Super classes
mlr3::Learner
-> mlr3proba::LearnerCompRisks
-> LearnerCompRisksAalenJohansen
Examples
library(mlr3)
# Define the Learner
learner = lrn("cmprsk.aalen")
learner
#>
#> ── <LearnerCompRisksAalenJohansen> (cmprsk.aalen): Aalen Johansen Estimator ────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3proba, and survival
#> • Predict Types: [cif]
#> • Feature Types: logical, integer, numeric, and factor
#> • Encapsulation: none (fallback: -)
#> • Properties: weights
#> • Other settings: use_weights = 'use'
# Define a Task
task = tsk("pbc")
# Stratification based on event
task$set_col_roles(cols = "status", add_to = "stratum")
# Create train and test set
part = partition(task)
# Train the learner on the training set
learner$train(task, row_ids = part$train)
learner$model
#> Call: survfit(formula = task$formula(1), data = task$data(cols = task$target_names))
#>
#> n nevent rmean se(rmean)*
#> (s0) 184 0 91.573442 4.130078
#> 1 184 12 7.761548 2.157753
#> 2 184 74 49.665011 4.148925
#> *restricted mean time in state (max time = 149 )
# Make predictions for the test set
predictions = learner$predict(task, row_ids = part$test)
predictions
#>
#> ── <PredictionCompRisks> for 92 observations: ──────────────────────────────────
#> row_ids time event CIF
#> 9 1 2 <list[2]>
#> 11 9 2 <list[2]>
#> 20 22 2 <list[2]>
#> --- --- --- ---
#> 208 27 1 <list[2]>
#> 256 29 1 <list[2]>
#> 262 17 1 <list[2]>
# Score the predictions
# AUC(t = 100), weighted mean score across causes (default)
predictions$score(msr("cmprsk.auc", cause = "mean", time_horizon = 100))
#> cmprsk.auc
#> 0.5
# AUC(t = 100), 1st cause
predictions$score(msr("cmprsk.auc", cause = 1, time_horizon = 100))
#> cmprsk.auc
#> 0.5
# AUC(t = 100), 2nd cause
predictions$score(msr("cmprsk.auc", cause = 2, time_horizon = 100))
#> cmprsk.auc
#> 0.5