Skip to contents

This vignette shows how to perform Receiver Operating Characteristic (ROC) analysis with meddecide using the psychopdaROC() function.

Loading the Data

df_roc <- read.csv(system.file("extdata", "roc_example.csv", package = "meddecide"))
head(df_roc)

Creating the ROC Curve

roc_res <- psychopdaROC(data = df_roc, class = df_roc$class, value = df_roc$value)
roc_res$plot

The resulting plot shows the ROC curve along with the area under the curve (AUC). You can extract the AUC value and other statistics from the result object.

roc_res$AUC

Bootstrapping and Confidence Intervals

The pROC package provides robust methods for computing confidence intervals for diagnostic metrics.

# Calculate AUC confidence intervals using pROC
library(pROC)
roc_obj <- roc(response = outcome, predictor = biomarker)
pROC::ci.auc(roc_obj, method = "bootstrap")

# Calculate threshold-specific confidence intervals
pROC::ci.thresholds(roc_obj)

These methods provide statistically sound confidence intervals for your ROC analysis.

Threshold Selection (Clinician-Friendly)

  • Youden’s J: Choose the cutpoint that maximizes Sensitivity + Specificity − 1. Good for overall discrimination, not always aligned with clinical priorities.
  • Rule‑out goal: Choose the lowest threshold achieving high Sensitivity (e.g., ≥0.95); accept lower Specificity to minimize missed disease.
  • Rule‑in goal: Choose the highest threshold achieving high Specificity (e.g., ≥0.95); accept lower Sensitivity to minimize false positives.
  • Prevalence and consequences: Prefer thresholds that maximize expected clinical utility in your setting (consider prevalence and harms/benefits). In practice, review the cutpoint table and select the row that meets your clinical constraint (e.g., Sens ≥0.90) with the best complementary metric.