concordance_index_compare()

Compare two concordance indices via the paired influence-function delta method.

Usage

Source

concordance_index_compare(
    surv,
    risk_a,
    risk_b,
    *,
    data=None,
    cause=None,
    tau=None,
    conf_level=0.95,
)

Tests whether two risk scores (from different models) have different concordance indices on the same data. The standard error of the difference is derived from the joint influence function, which properly accounts for the correlation between the two estimates (they share the same subjects).

Parameters

surv: Surv | Outcome | str

A Surv response (right-censored or multistate). An Outcome or a formula response such as 'Surv(time, status == 2)' is also accepted, with its columns read from data.

risk_a: Any

Risk scores from the first model.

risk_b: Any

Risk scores from the second model.

cause: int | None = None

Integer cause code for competing-risks concordance. None for standard.

tau: float | None = None

Truncation time.

conf_level: float = 0.95

Confidence level.

data: Any = None
A data frame (pandas, Polars, PyArrow, DuckDB, a lazy frame, …) holding the columns named by the response, risk_a, and risk_b. When surv is an Outcome or a formula, rows with a missing value in any column used are dropped first, along with the matching rows of any arrays passed alongside.

Returns

ConcordanceCompareResult
Difference, standard error, CI, z-statistic, and p-value.

Examples

import greenwood as gw

lung = gw.load_dataset("lung", backend="polars")
death = gw.Outcome.surv(time="time", event="status")
cox1 = gw.CoxPH().fit(death, covariates=["age"], data=lung)
cox2 = gw.CoxPH().fit(death, covariates=["age", "sex"], data=lung)
lp1 = cox1.predict(type="lp")
lp2 = cox2.predict(type="lp")

gw.concordance_index_compare(death, risk_a=lp1, risk_b=lp2, data=lung)
ConcordanceCompareResult(delta=-0.0467, se=0.0355, CI=[-0.1162, 0.0228], z=-1.318, p=0.1875)