| pa_survival_eval | R Documentation |
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.
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()
)
model |
A fitted survival model object. Optional for the metrics
computed directly from |
event_time |
A numeric vector of observed survival times. |
predicted_probability |
Numeric matrix of predicted survival probabilities, with
|
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 |
metrics |
A character vector specifying the evaluation metrics to compute. Options include:
The default |
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. |
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.
A data frame with two columns:
Metric |
The name of the computed evaluation metric. |
Value |
The corresponding computed value. |
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.
# 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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.