
Integrated Brier Score Competing Risks Measure
Source:R/MeasureCompRisksIntegratedBrierScore.R
mlr_measures_cmprsk.ibs.RdCalculates the integrated competing risks prediction error (integrated Brier score, IBS) using IPCW as described in Schoop et al. (2011).
Details
By default, this measure returns a cause-independent IBS (or all-cause)
score, calculated as a weighted average of the cause-specific integrated Brier scores.
The weights correspond to the relative event frequencies of each cause,
following Equation (8) in Spitoni et al. (2018).
User-supplied weights are also supported through cause_weights.
See the Cause weights section for weighting rules.
Alternatively, users can obtain the cause-specific IBS for any
individual cause by specifying the cause parameter.
Calls riskRegression::Score() with:
metric = "brier"summary = "ibs"cens.method = "ipcw"cens.model = "km"
Notes on the riskRegression implementation:
IPCW weights are estimated using the test data only, so smaller test sets may lead to less stable estimates.
Evaluation is limited to the maximum observed test-set follow-up time. See the Integration grid section for how this restriction is applied.
Dictionary
This Measure can be instantiated via the dictionary mlr_measures or with the associated sugar function msr():
Meta Information
Task type: “cmprsk”
Range: \([0, \infty)\)
Minimize: TRUE
Average: macro
Required Prediction: “cif”
Required Packages: mlr3, mlr3cmprsk, riskRegression, prodlim
Parameters
| Id | Type | Default | Range |
| cause | integer | - | \([1, \infty)\) |
| cause_weights | untyped | NULL | - |
| times | untyped | NULL | - |
| ntimes | untyped | 100L | - |
| t_max | untyped | NULL | - |
| t_quantile | untyped | NULL | - |
Parameter details
cause(numeric(1)|"mean")
Integer number indicating which cause to use. Default value is"mean"which returns an event-frequency weighted mean of the cause-specific integrated Brier scores.cause_weights(numeric()|NULL)
Optional custom weights forcause = "mean". See the Cause weights section for weighting rules.times(numeric()|NULL)
Explicit integration grid, supplied as a sorted vector of at least two distinct, finite, non-negative time points. Default isNULL, which uses an automatically generated grid.t_maxandt_quantilemust both beNULLwhen supplying explicittimes.ntimes(integer(1))
Number of points in an automatically constructed integration grid, including time 0 and the upper integration horizon. Must be at least 2; default is 100. Ignored when supplying explicittimes.t_max(numeric(1)|NULL)
Finite, non-negative upper integration horizon; default isNULL. Mutually exclusive witht_quantile.t_quantile(numeric(1)|NULL)
Quantile probability of observed test-set follow-up times used to determine the upper integration horizon. Must be finite and between 0 and 1, inclusive. Default isNULL, which uses the 90th percentile whent_maxis alsoNULL. Mutually exclusive witht_max.
Cause weights
Cause weights are used only for cause = "mean".
The cause_weights parameter is ignored when scoring a specific cause.
With cause_weights = NULL, weights are the relative frequencies of observed
non-censored events from the test set.
Causes without observed events receive zero weight, are listed in a warning and
are skipped when calculating the mean score.
If no events from any cause are observed, weights are undefined, and the
measure warns and returns NA_real_.
Alternatively, the user can supply custom weights via cause_weights.
Weights must be finite, non-negative, sum to 1, and contain one entry per predicted cause.
Entries must match the order of the predicted CIFs cause names.
If any user-supplied weight happens to be zero, it is skipped silently.
In general, non-finite scores from positive-weight causes propagate to the mean,
causing the measure to return NaN and a warning identifies the causes with
non-finite scores.
Integration grid
The integration grid contains the time points at which Brier scores are evaluated for numerical integration. Its largest time point is the upper integration horizon. All causes use the same grid, with their predicted CIFs constantly interpolated to these times. The observed follow-up times come from the supplied prediction. By default, resampling supplies predictions for the test set.
If the user explicitly provides times, the supplied grid is used directly.
Points beyond the maximum observed follow-up are removed with a warning due to
the limitations of riskRegression::Score().
At least two distinct evaluation times must remain.
When times = NULL, the upper integration horizon is determined first.
By default, it is the 90th percentile of observed follow-up times,
including both events and censored observations.
Set t_quantile to change the quantile probability (e.g., 0.8 for the 80th
percentile), or supply t_max to specify the time horizon directly.
If t_max exceeds the maximum observed follow-up, it is reduced to that maximum
before constructing the grid, and a warning reports the effective horizon.
The automatic grid is then generated and contains exactly ntimes equally
spaced points from time 0 to the horizon, including both endpoints.
Thus, the default grid consists of 100 points from 0 to the 90th percentile
of observed follow-up times.
Note that the generated grid is completely independent of the time grids of
the predicted CIFs.
The default 90th percentile is chosen to limit evaluation at extreme follow-up times, where IPCW weights may be large or CIF extrapolation beyond the last predicted time point may be needed.
References
Schoop, Roland, Beyersmann, Jan, Schumacher, Martin, Binder, Harald (2011). “Quantifying the predictive accuracy of time-to-event models in the presence of competing risks.” Biometrical Journal, 53(1), 88–112. doi:10.1002/BIMJ.201000073 .
Spitoni, Claudia, Lammens, Valerie, Putter, Hein (2018). “Prediction errors for state occupation and transition probabilities in multi-state models.” Biometrical Journal, 60(1), 34–48. ISSN 0323-3847. doi:10.1002/BIMJ.201600191 .
Super classes
mlr3::Measure -> MeasureCompRisks -> MeasureCompRisksIntegratedBrierScore
Methods
MeasureCompRisksIntegratedBrierScore$eval_times()
Returns the time points used to integrate the Brier score for a prediction. The grid follows the validation and truncation rules described in the Integration grid section.
Arguments
prediction(PredictionCompRisks)
A prediction object, usually containing the test set observations to be scored.
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.fg")
# Train on the training set
learner$train(task, row_ids = part$train)
learner$native_model
#> $`1`
#> convergence: TRUE
#> coefficients:
#> age albumin ast bili chol protime
#> -0.0980000 -0.4300000 -0.0020780 -0.0006369 0.0009530 -0.2304000
#> standard errors:
#> [1] 0.028100 0.954300 0.003896 0.078480 0.001298 0.398700
#> two-sided p-values:
#> age albumin ast bili chol protime
#> 0.00049 0.65000 0.59000 0.99000 0.46000 0.56000
#>
#> $`2`
#> convergence: TRUE
#> coefficients:
#> age albumin ast bili chol protime
#> 4.616e-02 -1.043e+00 3.302e-03 1.210e-01 2.155e-05 2.181e-01
#> standard errors:
#> [1] 0.0134800 0.2482000 0.0019800 0.0175100 0.0004066 0.1088000
#> two-sided p-values:
#> age albumin ast bili chol protime
#> 6.2e-04 2.6e-05 9.5e-02 4.9e-12 9.6e-01 4.5e-02
#>
#> attr(,"class")
#> [1] "fine_gray"
# 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]>
# IBS over 100 equally spaced points from 0 to the 90th test-set follow-up percentile,
# weighted by event frequencies
predictions$score(msr("cmprsk.ibs"))
#> cmprsk.ibs
#> 0.1107625
# IBS with an upper integration horizon of 100 months
predictions$score(msr("cmprsk.ibs", t_max = 100))
#> cmprsk.ibs
#> 0.004635376
# IBS up to the 85th percentile of test-set follow-up times
predictions$score(msr("cmprsk.ibs", t_quantile = 0.85))
#> cmprsk.ibs
#> 0.1065698
# IBS over 20 equally spaced points up to the default 90th percentile
predictions$score(msr("cmprsk.ibs", ntimes = 20L))
#> cmprsk.ibs
#> 0.1067466
# Inspect the integration grid for the test predictions
msr("cmprsk.ibs", ntimes = 20L)$eval_times(predictions)
#> [1] 0.0000 197.7105 395.4211 593.1316 790.8421 988.5526 1186.2632
#> [8] 1383.9737 1581.6842 1779.3947 1977.1053 2174.8158 2372.5263 2570.2368
#> [15] 2767.9474 2965.6579 3163.3684 3361.0789 3558.7895 3756.5000
# Define the integration grid in months
times = seq(0, 100, by = 5)
# IBS from 0 to 100 months on a 5-month grid, weighted by event frequencies
predictions$score(msr("cmprsk.ibs", times = times))
#> cmprsk.ibs
#> 0.004142072
# IBS from 0 to 100 months on a 5-month grid, with equal weights for both causes
predictions$score(msr("cmprsk.ibs", times = times, cause_weights = c(0.5, 0.5)))
#> cmprsk.ibs
#> 0.00240688
# IBS from 0 to 100 months on a 5-month grid, with custom weights for transplant and death
predictions$score(msr("cmprsk.ibs", times = times, cause_weights = c(0.2, 0.8)))
#> cmprsk.ibs
#> 0.003851008
# IBS from 0 to 100 months on a 5-month grid, for transplant only
predictions$score(msr("cmprsk.ibs", times = times, cause = 1))
#> cmprsk.ibs
#> 0
# IBS from 0 to 100 months on a 5-month grid, for death only
predictions$score(msr("cmprsk.ibs", times = times, cause = 2))
#> cmprsk.ibs
#> 0.00481376