Skip to contents

This function calculates the Harrell C Index value of a model in each of the imputed dataset stored in data as a long dataset. The Harrell's C Index calculation is realized using the Hmisc::rcorr.cens() function of the Harrell's package Hmisc. After calculating the index in each imputed dataset then it aggregates them using the rubin rules with the psfmi::pool_RR() function of the Heymans' package psfmi. Finally, it stores the result inside the results_imp and results_agg attributes of the model.

Usage

calculate_harrell_c_index(model, data, .progress = FALSE)

Arguments

model

A model generated by the function mv_model_cox() or mv_model_logreg()

data

Multiple imputation data organized as a long dataset

.progress

TRUE to render the progress bar FALSE otherwise

Value

The same model passed as a parameter with the Harrell C Index value stored in results_agg and results_imp

References

F. E. Harrell, “Harrell Miscellaneous (R package Hmisc version 5.1-1),” R-project.org, Sep. 2023, doi: https://cran.r-project.org/package=Hmisc. M. Heymans, “Prediction Model Pooling, Selection and Performance Evaluation Across Multiply Imputed Datasets (R package psfmi version 1.4.0),” R-project.org, Jun. 2023, doi: https://cran.r-project.org/package=psfmi.

Examples

set.seed(123)

model <- mv_model_logreg(formula = event ~ 0.5 * x + 0.3 * z - 1.2)

data <- data.frame(
  .imp = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
  id = c(1, 2, 3, 1, 2, 3, 1, 2, 3),
  x = rnorm(9, 1, 0.25),
  z = rnorm(9, 2, 0.75),
  event = survival::Surv(rpois(9, 5), rbinom(n = 9, size = 1, prob = 0.2))
)

model <- model |>
  calculate_predictions(data) |>
  calculate_harrell_c_index(data)