pa_survival_eval: Compute Survival Model Evaluation Metrics

pa_survival_evalR Documentation

Compute Survival Model Evaluation Metrics

Description

This function calculates various predictive performance metrics for survival models based on predicted survival probabilities and observed survival data. It supports a range of evaluation measures, including explained variation, concordance indices, Brier Score, and time-dependent AUC.

Usage

pa_survival_eval(
  model,
  event_time,
  predicted_probability,
  pred_mean_survival = NULL,
  status,
  covariates,
  new_data = NULL,
  metrics = NULL,
  t_star = NULL,
  tau = NULL,
  calibration_args = list()
)

Arguments

model

A fitted survival model object. Optional for the metrics computed directly from predicted_probability.

event_time

A numeric vector of observed survival times.

predicted_probability

Numeric matrix of predicted survival probabilities, with

  • rows = subjects.

  • columns = sorted observed follow-up times, including duplicates

pred_mean_survival

Optional numeric vector of predicted mean survival times, used for explained variation and concordance. Predicted probabilities are still needed for point metrics, Brier score, AUC, and calibration.

status

A numeric vector indicating event occurrence (1 for event, 0 for censoring).

covariates

A character vector specifying the names of the covariates used in the model.

new_data

Optional data frame used by metrics that require refitting or prediction from model. If supplied, it should contain the variables needed by those procedures and columns time and status coded as above.

metrics

A character vector specifying the evaluation metrics to compute. Options include:

  • "pseudo_r2" - Pseudo R-squared measure

  • "r_square" - Explained variation R^2

  • "l_square" - L-squared measure

  • "Harrell's C" - Harrell's concordance index

  • "Uno's C" - Uno's concordance index

  • "brier_score" - Overall probability prediction error

  • "td_auc" - Time-dependent area under the curve (AUC)

  • "ici", "e50", "e90" - Absolute calibration error summaries

The default NULL includes ICI but omits E50 and E90. Use "all" to include every supported metric.

t_star

(Optional) Evaluation time for point R-squared, Brier score, time-dependent AUC, and calibration. If NULL, it defaults to the median survival time.

tau

(Optional) A numeric value specifying the truncation time for calculating explained variation metrics. If NULL, it defaults to the maximum observed survival time.

calibration_args

Optional named list passed to [pa_calibration()], e.g. list(nk = 3). These settings affect calibration only. For sampling weights use [pa_sample_design()] or [pa_calibration()] directly, rather than passing weights through this list.

Details

Point R-squared uses the event indicator 'I(T <= t_star)' and the predicted event probability '1 - S' at the selected prediction-grid column. Events at the evaluation time are included. Calibration uses 1 - S(t_star) from the last supplied grid column at or before t_star, interpreting the grid as a right-continuous step function (risk zero before its first time). Its outcome horizon is exactly t_star, not the nearest future grid time. See [pa_calibration()] for the estimator and boundary-probability policy. A failed calibration fit warns and returns missing calibration metrics; other requested metrics are retained.

Value

A data frame with two columns:

Metric

The name of the computed evaluation metric.

Value

The corresponding computed value.

References

Schemper, M. and R. Henderson (2000). Predictive accuracy and explained variation in Cox regression. Biometrics 56, 249–255.

Lusa, L., R. Miceli and L. Mariani (2007). Estimation of predictive accuracy in survival analysis using R and S-PLUS. Computer Methods and Programs in Biomedicine 87, 132–137.

Potapov, S., Adler, W., Schmid, M., Bertrand, F. (2024). survAUC: Estimating Time-Dependent AUC for Censored Survival Data. R package version 1.3-0. DOI: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/CRAN.package.survAUC")}. Available at https://CRAN.R-project.org/package=survAUC.

Examples

# A Cox model evaluated on right-censored data. The simulator is seeded,
# so the reported metric values are reproducible.
d <- pa_sim_cox_weibull(n = 150, pi_c = 0.3, v = 2,
                        beta = c(0.5, -0.5), seed = 2025)
d <- d[, c("time", "status", "x1", "x2")]
fit <- survival::coxph(survival::Surv(time, status) ~ x1 + x2,
                       data = d, x = TRUE, y = TRUE)
pred <- pa_predict_coxph(model = fit, covs = c("x1", "x2"), new_data = d)

# the default metric set
pa_survival_eval(
  model = fit, event_time = pred$times,
  predicted_probability = pred$surv_prob, status = pred$status,
  covariates = c("x1", "x2"), new_data = d
)

# a chosen subset; see pa_metric_names() for the accepted identifiers
pa_survival_eval(
  model = fit, event_time = pred$times,
  predicted_probability = pred$surv_prob, status = pred$status,
  covariates = c("x1", "x2"), new_data = d,
  metrics = c("harrell_c", "brier_score")
)

PAmeasures documentation built on Oct. 29, 2026, 1:08 a.m.