Learn R Programming

compareCstat (version 0.1.0)

compare_c_stat: Compare C-statistics Between Two Models with Bootstrapped or Uno's C Confidence Intervals

Description

This function compares the C-statistics of two fitted models using either bootstrap resampling (Harrell's C) or Uno's C via perturbation-resampling (survC1 package).

Usage

compare_c_stat(
  model_raw,
  model_ext,
  data,
  R = 10,
  ci_type = "perc",
  method = "Harrell",
  tau = NULL
)

Value

A data frame showing C-statistics for each model, their confidence intervals, and the p-value for the difference.

Arguments

model_raw

A fitted model (e.g., coxph) representing the base model.

model_ext

A fitted model (e.g., coxph) representing the extended model.

data

The dataset used for fitting the models.

R

Number of bootstrap or perturbation-resampling replications. Default is 100.

ci_type

Type of confidence interval to return ("perc", "norm", "basic", etc., for Harrell's C).

method

Which C-statistic to use: "Harrell" (default) or "Uno".

tau

Truncation time for Uno's C (default is max observed time in your data).

References

Uno H, Cai T, Pencina MJ, D'Agostino RB, Wei LJ. (2011) On the C-statistics for evaluating overall adequacy of risk prediction procedures with censored survival data. Statistics in Medicine, 30(10):1105-1117. tools:::Rd_expr_doi("10.1002/sim.4154")

Examples

Run this code
library(survival)
data(lung)
lung$status <- ifelse(lung$status == 2, 1, 0)
model1 <- coxph(Surv(time, status) ~ age, data = lung)
model2 <- coxph(Surv(time, status) ~ age + sex, data = lung)
compare_c_stat(model1, model2, data = lung, R = 10, method = "Harrell")
compare_c_stat(model1, model2, data = lung, R = 10, method = "Uno")
compare_c_stat(model1, model2, data = lung, R = 10, method = "Uno", tau = 365.25*2)

Run the code above in your browser using DataLab