ROC Curve Analysis
ClinicoPath Development Team
2025-07-29
Source:vignettes/03-roc-analysis.Rmd
03-roc-analysis.Rmd
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.