cindex_survmat: Concordance Index from a Survival Probability Matrix

View source: R/metrics.R

cindex_survmatR Documentation

Concordance Index from a Survival Probability Matrix

Description

Computes the time-dependent concordance index (C-index) from a predicted survival matrix at a fixed time point. The risk is computed as '1 - S(t_star)'.

Usage

cindex_survmat(object, predicted, t_star = NULL)

Arguments

object

A 'Surv' object representing the observed survival data.

predicted

A data frame or matrix of predicted survival probabilities. Each column corresponds to a time point (e.g., 't=90', 't=180').

t_star

A numeric time point corresponding to one of the columns in 'predicted'. If 'NULL', the last column is used.

Value

A single numeric value representing the C-index.

Examples


if (requireNamespace("torch", quietly = TRUE) && torch::torch_is_installed()) {
  veteran <- survival::veteran
  mod <- survdnn(survival::Surv(time, status) ~
  age + karno + celltype, data = veteran, epochs = 50, verbose = FALSE)
  pred <- predict(mod, newdata = veteran, type = "survival", times = c(30, 90, 180))
  y <- model.response(model.frame(mod$formula, veteran))
  cindex_survmat(y, pred, t_star = 180)
}


survdnn documentation built on April 29, 2026, 9:07 a.m.