concordance_index_ipcw()

IPCW concordance index (Uno et al., 2011) for right-censored survival data.

Usage

Source

concordance_index_ipcw(
    surv,
    risk,
    *,
    tau=None,
)

An inverse-probability-of-censoring-weighted concordance index that corrects for censoring bias. Unlike Harrell’s C, the IPCW concordance is a consistent estimator of the true concordance probability even under informative censoring patterns. It is more robust when censoring is heavy or differs across risk groups.

When to use this instead of concordance_index (Harrell’s C):

  • When censoring exceeds 30-40% of subjects.
  • When censoring patterns differ across risk groups (informative censoring).
  • When comparing models across datasets with different censoring rates.

Interpretation: Same scale as Harrell’s C (0.5 = random, 1.0 = perfect discrimination). Values are comparable to Harrell’s C under light censoring and diverge when censoring is heavy.

Parameters

surv: Surv

A right-censored Surv response (time-to-event data).

risk: Any

Risk score for each subject, one per observation. Higher values indicate higher risk (earlier expected failure). Accepts a 1-D array, Pandas/Polars Series, or Python sequence.

tau: float | None = None
Truncation time. Only pairs with an event before tau contribute. This avoids instability from low censoring survival in the tail. Defaults to the largest observed event time.

Returns

float
IPCW concordance index between 0 and 1.

Details

Uno estimator: For each subject i with an observed event at T_i \le \tau, compare against all subjects j with T_j > T_i:

\hat{C}_{\mathrm{IPCW}} = \frac{\displaystyle\sum_{i:\Delta_i=1,\,T_i \le \tau} \hat{G}(T_i^-)^{-2} \Bigl[\#\{j: T_j > T_i,\, \eta_j < \eta_i\} + \tfrac{1}{2}\#\{j: T_j > T_i,\, \eta_j = \eta_i\}\Bigr]} {\displaystyle\sum_{i:\Delta_i=1,\,T_i \le \tau} \hat{G}(T_i^-)^{-2} \cdot \#\{j: T_j > T_i\}}

where \hat{G} is the Kaplan-Meier estimate of the censoring distribution.

Truncation: Restricting to events before \tau avoids instability from dividing by very small censoring probabilities in the tail. The default \tau is the largest event time. Set it explicitly to the maximum follow-up of interest.

References

Uno H., Cai T., Pencina M.J., D’Agostino R.B., Wei L.J. (2011). On the C-statistics for evaluating overall adequacy of risk prediction procedures with censored survival data. Statistics in Medicine, 30(10), 1105-1117.

Examples

Fit a Cox model on the lung dataset and compute the IPCW concordance:

import greenwood as gw

lung = gw.load_dataset("lung", backend="polars")
y = gw.Surv.right(lung["time"], event=(lung["status"] == 2))
cox = gw.CoxPH().fit(y, lung[["age", "sex"]])

lp = cox.predict(type="lp")

# Compare Harrell's C with IPCW C
c_harrell = gw.concordance_index(y, lp)
c_ipcw = gw.concordance_index_ipcw(y, lp)
print(f"Harrell C: {c_harrell:.4f}")
print(f"IPCW C:    {c_ipcw:.4f}")
Harrell C: 0.6029
IPCW C:    0.5959

Truncate at 1 year to focus on short-term discrimination:

c_1yr = gw.concordance_index_ipcw(y, lp, tau=365.0)
print(f"IPCW C (1-year): {c_1yr:.4f}")
IPCW C (1-year): 0.5991