Assessing
Model Fit
Learn how to evaluate whether a classification model is actually good at its job: from confusion matrices to the ROC curve.
What is Classification?
In biostatistics, we often build models that predict a categorical outcome: Does a patient have a disease or not? Will a treatment succeed or fail? These are classification problems.
Why Accuracy Alone Fails
Suppose 95 out of 100 patients are healthy. A model that always says "healthy" achieves 95% accuracy yet misses every sick patient. This is the accuracy paradox.
The Confusion Matrix
A confusion matrix cross-tabulates predicted labels against actual labels, giving us four critical counts:
Sensitivity & Specificity
\(\text{Sensitivity} = \dfrac{TP}{TP + FN}\)
\(\text{Specificity} = \dfrac{TN}{TN + FP}\)
The Sensitivity-Specificity Trade-Off
Classification models output a probability score. We choose a threshold \(t\): if the score \(\geq t\), predict positive. Changing \(t\) shifts the balance:
Introducing the ROC Curve
The Receiver Operating Characteristic (ROC) curve plots Sensitivity (True Positive Rate) on the y-axis versus \(1 - \text{Specificity}\) (False Positive Rate) on the x-axis, across every possible threshold.
Understanding AUC
The Area Under the ROC Curve (AUC) summarizes overall model performance in a single number between 0 and 1.
Sensitivity vs Specificity: When to Prioritize
| Prioritize Sensitivity | Prioritize Specificity | |
|---|---|---|
| Goal | Catch every positive case | Avoid false alarms |
| Cost of error | Missing disease is dangerous | Unnecessary treatment is costly |
| Example | Cancer screening | Confirmatory biopsy |
| Threshold | Lower \(t\) | Higher \(t\) |
| Trade-off | More false positives | More false negatives |
How to Assess Model Fit
Example 1: Disease Screening
A blood test for diabetes is applied to 200 patients. Results:
Example 2: Comparing Two Models
Two models predict heart disease. Which is better? Accuracy alone gives the same answer, but ROC tells a different story.
Example 3: Choosing a Threshold
A cancer screening model with AUC = 0.95 offers different trade-offs at different thresholds:
| Threshold \(t\) | Sensitivity | Specificity | Clinical Impact |
|---|---|---|---|
| \(t = 0.3\) | 0.97 | 0.70 | Catch nearly all cancers, many false alarms |
| \(t = 0.5\) | 0.88 | 0.90 | Balanced performance |
| \(t = 0.7\) | 0.72 | 0.96 | Fewer false alarms, miss some cancers |
PPV & NPV: The Patient's Perspective
Sensitivity and specificity describe the test's performance. But patients ask: "Given my result, what are the chances I actually have it?"
\(\text{PPV} = \dfrac{TP}{TP + FP}\)
\(\text{NPV} = \dfrac{TN}{TN + FN}\)
Common Mistakes
Summary of Key Metrics
| Metric | Formula | Answers |
|---|---|---|
| Sensitivity | \(\frac{TP}{TP+FN}\) | How well does it detect positives? |
| Specificity | \(\frac{TN}{TN+FP}\) | How well does it rule out negatives? |
| PPV | \(\frac{TP}{TP+FP}\) | Is a positive result trustworthy? |
| NPV | \(\frac{TN}{TN+FN}\) | Is a negative result trustworthy? |
| AUC | Area under ROC | How well does the model discriminate overall? |
Question 1 of 5
A confusion matrix shows: \(TP = 80, FP = 20, FN = 10, TN = 90\). What is the sensitivity of this model?
Question 2 of 5
A model that always predicts "negative" for a disease with 2% prevalence will have:
Question 3 of 5
On an ROC curve, the ideal model would have its curve pass through which point?
Question 4 of 5
For a cancer screening test, which threshold strategy is most appropriate?
Question 5 of 5
Model X has AUC = 0.85 and Model Y has AUC = 0.65. Which statement is most accurate?