pa_summarize_cr: Summarize multiple competing-risks models into a wide...

View source: R/pa_survival_eval_cr.R

pa_summarize_crR Documentation

Summarize multiple competing-risks models into a wide comparison table

Description

Calls pa_survival_eval_cr() for each model in a named list and returns a wide table where rows are metrics and columns are model names.

Usage

pa_summarize_cr(
  models,
  metrics = NULL,
  t_star = NULL,
  tau = NULL,
  event_type = 1,
  digits = 2,
  censoring = c("cox", "km"),
  censor_covariates = NULL,
  calibration_args = list()
)

Arguments

models

A **named list**; each element is a list with components:

  • pred_cif – numeric matrix of predicted CIF values (rows: time grid; cols: subjects)

  • time.cif – numeric vector of the time grid corresponding to pred_cif rows

  • event_time – numeric vector of observed times

  • status – integer vector of event codes (0=censoring; event_type=target; others=competing)

metrics

Character vector of metrics to compute (passed through to pa_survival_eval_cr()); use "all" for all supported.

t_star

(Optional) Evaluation time for Brier score, AUC, point R2, and calibration. Defaults to the median observed follow-up.

tau

(Optional) The maximum prediction time horizon for R2 and C index. Default is maximum of observation time.

event_type

Integer code for the cause of interest (passed through).

digits

Number of decimal places to round the metric values (default = 2).

censoring

Censoring estimator for generalized R-squared metrics, '"cox"' (default) or '"km"'; passed to [pa_survival_eval_cr()].

censor_covariates

Optional numeric censoring-model covariates shared across models. Rows must match each model's subject order. Passed to [pa_survival_eval_cr()]; used only with 'censoring = "cox"'.

calibration_args

Optional named list passed to [pa_calibration_cr()].

Details

See [pa_survival_eval_cr()] for the event-observation weighting rule, original-time support requirements and probability floor.

Value

A data.frame with:

  • each row = metric

  • each column = model name

  • cell values = metric values

Examples

# Competing risks: cause 1 is the event of interest, cause 2 the competing
# risk. Both cause-specific hazards are modelled.
cr <- pa_simulate_fine_gray(n = 150, v = 2, beta1 = c(0.5, -0.5),
                            beta2 = c(-0.3, 0.3), censor = 0.3, seed = 2025)
cr$time <- cr$obs.times
cr$status <- cr$obs.event
m1 <- survival::coxph(survival::Surv(time, status == 1) ~ X1 + X2,
                      data = cr, x = TRUE, y = TRUE)
m2 <- survival::coxph(survival::Surv(time, status == 2) ~ X1 + X2,
                      data = cr, x = TRUE, y = TRUE)
p <- pa_predict_cif(model1 = m1, model2 = m2, newdata = cr,
                    covs = c("X1", "X2"), event.type = 1, tau = max(cr$time))

pa_summarize_cr(list(csh = p), event_type = 1)

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