hazardous.metrics
.concordance_index_incidence#
- hazardous.metrics.concordance_index_incidence(y_test, y_pred, y_train=None, ipcw_estimator='km', time_grid=None, taus=None, event_of_interest=1, tied_tol=1e-08)#
Time-dependent concordance index for prognostic models with competing risks using inverse probability of censoring weighting.
This C-index is event-specific: we set the event of interest as a parameter, and all other event labels are considered to be competing events –except 0, which is the censoring event.
For example, if
y_test
has the following"event"
column:[1, 0, 2, 4]
, and the event of interest is set to2
, then we consider the following events:[2, 0, 1, 2]
, where 0, 1, 2 respectively denotes the censoring event, the event of interest and competing events.We define this C-index at time \(\tau\) as:
\[\mathrm{C}(\tau) = \frac{\sum_{i=1}^n \sum_{j=1}^n (A_{ij} \hat{W}_{ij, 1}^{-1} + B_{ij} \hat{W}_{ij, 2}^{-1}) Q_{ij}(\tau) N^1_i(\tau)} {\sum_{i=1}^n \sum_{j=1}^n (A_{ij} \hat{W}_{ij, 1}^{-1} + B_{ij} \hat{W}_{ij, 2}^{-1}) N^1_i(\tau)}\]where:
\[\begin{split}\begin{align} N^1_i(\tau) &= I\{t_i \leq \tau, \delta_i = 1\} \\ A_{ij} &= I\{t_i < t_j \cup (t_i = t_j \cap \delta_j = 0)\} \\ B_{ij} &= I\{t_i \geq t_j, \delta_j = 2\} \\ \hat{W}_{ij,1} &= \hat{G}(t_i| X = x_i) \hat{G}(t_i|X = x_j) \\ \hat{W}_{ij,2} &= \hat{G}(t_i|X = x_i) \hat{G}(t_j|X =x_j) \\ Q_{ij}(t) &= I\{F_k(\tau| X = x_i) > F_k(\tau| X = x_j)\} \end{align}\end{split}\]where:
\(t_i\) and \(\delta_i\) are the observed time-to-event and event for the individual i.
\(\delta = 0, 1, 2\) respectively denotes a censoring event, the event of interest and the competing events.
\(\hat{G}\) is a IPCW estimator.
\(Q_{ij}(\tau)\) is an indicator for the order of predicted risk at \(\tau\).
\(F_k\) is the predicted cumulative incidence function for the event of interest k.
The concordance index (C-index) is a common metric in survival analysis that evaluates whether the model predictions correctly order pairs of individuals with respect to the timing of the event of interest. It is defined as the probability that the prediction is concordant for a pair of individuals and is computed as the ratio of the number of concordant pairs to the total number of pairs. This implementation extends the C-index to the competing risks setting, where multiple alternative events are considered, aiming to determine which event occurs first and when, following the formulas and notations in [Wolbers2014].
Due to the right-censoring in the data, the order of some pairs is unknown, so we define the notion of comparable pairs, i.e. pairs for which we can compare the order of occurrence of the event of interest. A pair \((i, j)\) is comparable, with \(i\) experiencing the event of interest at time \(T_i\) if:
\(j\) is censored or experience any event at a strictly greater time \(T_j > T_i\) (pair of type A)
\(j\) is censored at the exact same time \(T_i = T_j\) (pair of type A).
\(j\) experiences a competing event before or at time \(T_i\) (pair of type B)
A pair is then considered concordant if the predicted incidence of the event of interest for \(i\) at time \(\tau\) is larger than the predicted incidence for \(j\). If both predicted incidences are ties, the pair is counted as \(1/2\) for the count of concordant pairs.
The C-index has been shown to depend on the censoring distribution, and an inverse probability of censoring weighting (IPCW) allows to overcome this limitation [Uno2011], [Gerds2013]. By default, the IPCW is implemented with a Kaplan-Meier estimator. Additionnally, the C-index is not a proper metric to evaluate a survival model [Blanche2019], and alternatives as the integrated Brier score (
integrated_brier_score_incidence
) should be considered. The C-index is a ranking metric and, unlike proper scoring rule metrics, cannot evaluate the calibration of the estimator.- Parameters:
- y_testarray, dict or dataframe of shape (n_samples, 2)
The test target, consisting in the ‘event’ and ‘duration’ columns.
- y_pred: array of shape (n_samples, n_time_grid)
Cumulative incidence for the event of interest, at the time points from the input time_grid.
- y_trainarray, dictionnary or dataframe of shape (n_samples, 2), default=None
The train target, consisting in the ‘event’ and ‘duration’ columns. Only used when ipcw_estimator = “km”.
- ipcw_estimatorNone, ‘km’, or fitted estimator, default=”km”
The inverse probability of censoring weighted (IPCW) estimator.
Pass None to set uniform weights to all samples.
Pass “km” to use the Kaplan-Meier IPCW estimator. It fits using y_train, which must be set.
- time_grid: array of shape (n_time_grid,), default=None
Time points used to predict the cumulative incidence.
- taus: float or array of shape (n_taus,), default=None
Timepoint(s) at which the concordance index is evaluated.
- event_of_interest: int, default=1
For competing risks, the event of interest.
- tied_tolfloat, default=1e-8
The tolerance range to consider two probabilities equal.
- Returns:
- cindex: array of shape (n_taus,)
Value of the concordance index for each tau in taus.
References
[Wolbers2014]M. Wolbers, P. Blanche, M. T. Koller, J. C. Witteman, T. A. Gerds, “Concordance for prognostic models with competing risks”, 2014
[Uno2011]H. Uno, T. Cai, M. J. Pencina, R. B. D’Agostino, L. J. Wei, “On the C-statistics for evaluating overall adequacy of risk prediction procedures with censored survival data”, 2011
[Gerds2013]T. A. Gerds, M. W. Kattan, M. Schumacher, C. Yu, “Estimating a time-dependent concordance index for survival prediction models with covariate dependent censoring”, 2013
[Blanche2019]P. Blanche, M. W. Kattan, T. A. Gerds, “The c-index is not proper for the evaluation of t-year predicted risks”, 2019