ROC Curve Analysis

  • Receiver Operating Characteristic Curve Analysis (ROC Curve Analysis) plots the true positive rate (TPR) against the false positive rate (FPR).

    • TPR: Positives correctly identified by the test.

    • FPR: Negatives incorrectly identified as positive.

  • This allows each point to represent sensitivity and specificity at a particular threshold.

True Postive Rate & False Postitive Rate

\[ \text{TPR} = \frac{\text{True Positives}}{\text{True Positives} + \text{False Negatives}} \]

\[ \text{FPR} = \frac{\text{False Positives}}{\text{False Positives} + \text{True Negatives}} \]

Area Under the ROC Curve

  • Area under the ROC Curve (AUC) is an indicator of how effectively a parameter differentiates between two diagnostic categories.

\[ \text{AUC} = \int_0^1 \text{TPR}(x) \,dx \]

  • AUC = 1: Correctly classifies all positive and negative cases.

  • AUC = 0.5: Cannot effectively distinguish between two classes.

  • AUC < 0.5: Worse than random chance.

Medical Implications

-Evaluates a diagnostic test’s ability to distinguish between diseased and unaffected cases.

-Facilitates the comparison of diagnostic performance between two or more laboratory tests.

-Identifies the best thresholds for diagnostic tests, improving decision-making required for patient care.

-Assists in assessing the reliability of a diagnostic test over time, ensuring consistent performance in the clinical setting.

Maximum Heart Rate, Age, Cholesterol (plotly)

R Code

library(plotly)
library(pROC)
library(dplyr)

heart_disease_data <- read.csv("C:/Users/Skj23/Documents/processed.cleveland.data", header = FALSE)
colnames(heart_disease_data) <- c("age", "sex", "cp", "trestbps", "chol", "fbs", "restecg", "thalach", "exang", "oldpeak", "slope", "ca", "thal", "target")

heart_disease_data$target <- ifelse(heart_disease_data$target > 0, "Heart Disease", "Unaffected")
roc_obj <- roc(heart_disease_data$target, heart_disease_data$thalach)

roc_data <- data.frame(TPR = roc_obj$sensitivities, FPR = 1 - roc_obj$specificities)

roc_plot <- plot_ly(data = heart_disease_data, x = ~age, y = ~chol, z = ~thalach, color = ~factor(target), colors = c("red", "grey"), type = 'scatter3d', mode = 'markers') %>% layout(scene = list(xaxis = list(title = 'Age'), yaxis = list(title = 'Cholesterol'), zaxis = list(title = 'Max Heart Rate')), legend = list(title = list(text = 'Condition')))

Cholesterol Level (ggplot)

Resting Blood Pressure (ggplot)

References