hazardous.metrics.aj_calibration_at_t#
- hazardous.metrics.aj_calibration_at_t(y_calibration, times, pred_calibration, event_of_interest=None)#
Pointwise AJ calibration error at each time point.
For each event \(k\), computes the difference between the mean predicted CIF and the marginal Aalen-Johansen CIF at every time in
times:\[AJ_k(t) = |\bar{F}_k(t) - \hat{F}^{AJ}_k(t)|\]where \(\bar{F}_k(t) = \frac{1}{n} \sum_{i=1}^n \hat{F}_k(t \mid \mathbf{x}_i)\) is the mean predicted cumulative incidence for event \(k\) across the calibration set, and \(\hat{F}^{AJ}_k(t)\) is the marginal Aalen-Johansen CIF for event \(k\) fitted on the same set. The survival probability (event 0) is compared against the Kaplan-Meier estimate via
km_calibration().- Parameters:
- y_calibrationarray-like of shape (n_samples, 2)
Survival outcomes of the calibration set, with columns
"event"(0 for censoring, positive integers for each cause of event) and"duration"(observed time).- timesarray-like of shape (n_times,)
Time points at which the CIFs were predicted. Need not be sorted; the last axis of
pred_calibrationmust share the same ordering.- pred_calibrationarray-like of shape (n_samples, n_events+1, n_times)
Predicted incidence probabilities at
timesfor the calibration set. The second axis is indexed by event identifier in sorted order: index 0 holds the survival probability, indices 1, 2, … hold cause-specific CIFs.- event_of_interestint or None, default=None
If provided, return only the difference array for that event. If
None, return a dict with one array per event.
- Returns:
- differencesdict of {int: ndarray of shape (n_times,)}
Pointwise difference \(AJ_k(t)\) for each event identifier, in ascending time order. Only the entry for
event_of_interestis returned when that parameter is set.
See also
aj_calibration_per_eventIntegrate these differences into a scalar score per event.
km_calibrationKM-based calibration used for event 0.
References
[Alberge2026]J. Alberge, T. Haugomat, G.Varoquaux,J. Abecassis, “On the calibration of survival models with competing risks”, AISTATS 2026. <https://arxiv.org/pdf/2602.00194>