concordance_index_ci()

IPCW concordance index with a confidence interval.

Usage

Source

concordance_index_ci(
    surv,
    risk,
    *,
    data=None,
    cause=None,
    tau=None,
    conf_level=0.95,
    transform="logit",
)

Computes the Uno-style IPCW concordance and derives the standard error from the influence function decomposition. The confidence interval is constructed on the logit (default), log, or identity scale and back-transformed.

Parameters

surv: Surv | Outcome | str

A Surv response. If cause is given, must be multi-state (Surv() with a categorical event). Otherwise it must be right-censored (Surv(time=..., event=...)). An Outcome or a formula response such as 'Surv(time, status == 2)' is also accepted, with its columns read from data.

risk: Any

Risk score or predicted cumulative incidence, one per subject.

cause: int | None = None

Integer cause code for the competing-risks concordance. None (default) uses the standard right-censored concordance.

tau: float | None = None

Truncation time. Defaults to the largest observed (cause-specific) event time.

conf_level: float = 0.95

Confidence level for the interval (default 0.95).

transform: str = "logit"

Scale for the CI: "logit" (default, recommended), "log", or "identity".

data: Any = None
A data frame (pandas, Polars, PyArrow, DuckDB, a lazy frame, …) holding the columns named by the response and risk. 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

ConcordanceResult
Point estimate, standard error, and confidence limits.

Examples

import greenwood as gw

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

gw.concordance_index_ci(death, risk=lp, data=lung)
ConcordanceResult(estimate=0.5959, se=0.0391, CI=[0.5176, 0.6696], conf_level=0.95)