To create a ROC curve, you need a **numeric predictor** and a **binary outcome**. The ROC curve evaluates how well the predictor discriminates between categories.
# Load necessary library
library(pROC)
# Convert categorical variable to binary (1 = "Yes", 0 = "No")
data$Outcome_binary <- ifelse(data$Outcome == "Yes", 1, 0)
# Compute ROC curve
roc_model <- roc(data$Outcome_binary, data$Score)
# Plot ROC curve
plot(roc_model, col = "blue", main = "ROC Curve")
abline(a = 0, b = 1, lty = 2, col = "gray") # Random classifier line
auc(roc_model) # Calculate AUC
The ROC curve evaluates a model’s classification performance by plotting sensitivity vs. 1-specificity.