ROC Curve & AUC Calculator with Hanley-McNeil Confidence Intervals
A single threshold gives one sensitivity and one specificity — one point. Change the threshold and both numbers change with it, and which threshold is better is precisely the question you are trying to answer. An ROC curve plots all possible thresholds at once; the area under the curve (AUC) compresses the entire curve into a single number.
AUC has a clean interpretation: the probability that a randomly chosen positive individual scores higher than a randomly chosen negative individual. 0.5 is a coin flip; 1.0 is complete separation.
Two Independent Algorithms, One Answer
Trapezoidal: compute (1−specificity, sensitivity) at every possible threshold, connect the points, integrate trapezoidally
Concordance: AUC = [ #(positive > negative) + 0.5 × #(positive = negative) ] ÷ (n₁ × n₂)
These two paths share no common machinery, yet Hanley & McNeil (Radiology 1982;143:29-36) proved they are identical — the concordance formula is exactly the normalized Mann-Whitney statistic. This tool computes both and displays them side by side; a mismatch signals a bug in the implementation. Ties are weighted at 0.5, which is standard.
Confidence Interval
SE(AUC) = √{ [AUC(1−AUC) + (N₁−1)(Q₁−AUC²) + (N₂−1)(Q₂−AUC²)] ÷ (N₁N₂) }
Q₁ = AUC ÷ (2−AUC) Q₂ = 2·AUC² ÷ (1+AUC)
CI = AUC ± z(α/2) × SE(AUC)
Also from Hanley & McNeil 1982. N₁ is the number of positives, N₂ the number of negatives — not the total sample size, which is easy to confuse, and both appear in the denominator.
Verification
Anchor 1: published worked example. Switch to “Known AUC and sample sizes” mode, enter AUC 0.6, N₁ = N₂ = 976, two-sided 95%; the interval width should be 0.0500 — exactly the answer in the NCSS/PASS document Confidence Intervals for the Area Under an ROC Curve. Entering 245 gives 0.0998, which also matches that table.
Anchor 2: the identity. The default data are 12 vs 12 scores (including one tie):
| Quantity | Value |
|---|---|
| U (concordant pair count) | 115.5 |
| AUC = U ÷ 144 | 0.802083 |
| Trapezoidal AUC | 0.802083 (digit-for-digit) |
| SE | 0.092213 |
| 95% CI | 0.621350 – 0.982817 |
| Max Youden J | 0.416667 (7 thresholds tied; all listed) |
| Mann-Whitney two-sided p | 0.012023 |
The two AUC algorithms agreeing digit-for-digit is stronger evidence of a correct implementation than any single number matching.
Scope and Limits
- AUC < 0.5 does not mean “useless” — it almost always means the direction is wrong. If lower scores indicate positives, change the direction option; do not treat 0.3 as “worse than random” — the coordinate system is simply inverted.
- The normal-approximation interval can exceed 1 when AUC is near 1 (with AUC 0.965 and n = 12 per group, the upper limit reaches 1.043). This is a known limitation. The tool clips the displayed value to 1.0 and warns you explicitly rather than silently clipping; for such cases consider bootstrap or logit-transform confidence intervals.
- The Youden-optimal threshold is often not unique. J = sensitivity + specificity − 1 is a step function with small samples, and multiple thresholds can tie for the maximum. The tool reports the tie count; choosing among them requires weighing the relative costs of false negatives and false positives — a statistical quantity cannot make that judgment for you.
- AUC values from different samples cannot be directly compared. Comparing two ROC curves requires paired methods (DeLong, or the Hanley-McNeil 1983 paired formula), which use the correlation between the two scores on the same individuals. This tool does not do that.
- AUC is a good summary of threshold-independent discriminative ability, but it carries limited information for clinical decisions: two curves with identical AUC can differ substantially over the part of the specificity range you actually care about. To pick a threshold, read the ROC table — do not rely on AUC alone.
- Multi-class ROC, covariate adjustment, and missing values are not handled.
FAQ
What does AUC actually mean?
**The probability that a randomly chosen positive individual scores higher than a randomly chosen negative individual.** 0.5 is a coin flip; 1.0 is complete separation of the two groups. This is not an analogy — it is exact: Hanley & McNeil (Radiology 1982;143:29-36) proved that the trapezoidal area under the empirical ROC curve equals the normalized Mann-Whitney statistic, which is an unbiased estimate of precisely this probability. This tool computes both paths and displays them side by side so you can see this directly.
My AUC is below 0.5. Does that mean the marker is worse than chance?
Almost always, **the direction is wrong**. An AUC of 0.3 means lower scores are associated with the positive group — switch the direction option to "lower score → more likely positive" and you will get 0.7. A marker that is genuinely worse than random is extremely rare in practice. When you see AUC < 0.5, check the direction first rather than concluding the marker is useless.
What do I enter for N₁ and N₂ in the SE formula?
**N₁ is the number of positive (diseased) cases; N₂ is the number of negative (control) cases — not the total sample size.** They appear separately in the denominator and in the two bracket terms. Entering the total sample size makes the standard error too small and the interval too narrow, giving a false sense of precision. This is the most common mistake with this formula, which is why the tool asks for them separately.
The upper confidence limit exceeds 1. What should I do?
That is a limitation of the normal approximation near the boundary. With AUC 0.965 and 12 cases per group, the upper limit reaches 1.043. This tool clips the displayed value to 1.0 **and explicitly warns you** — silently clipping would make it look as though the interval truly ends at 1.0, which is a different claim. For this situation, consider bootstrap confidence intervals or apply a logit transform first and then back-transform.
Can I use the Youden-optimal threshold directly in practice?
**Not without checking the cost assumptions.** J = sensitivity + specificity − 1 implicitly assumes that false negatives and false positives carry equal cost. In screening, a missed diagnosis is usually much more serious; in that case, first fix an acceptable minimum sensitivity (e.g., ≥ 95%) and then select the threshold with the highest specificity that meets it. Also, with small samples J is a step function and multiple thresholds can tie for the maximum — the tool reports the tie count. A tie means the data cannot distinguish between those thresholds; you still need to choose based on clinical costs.
Can I compare the AUC values from two models?
This tool does not do that. Comparing two ROC curves depends on whether they come from the **same individuals**: if so, you need a paired method (DeLong, or the Hanley-McNeil 1983 paired formula), which uses the correlation between the two scores on the same sample; otherwise the samples can be treated as independent. Visually checking whether two confidence intervals overlap is incorrect — it double-counts the shared variation that is cancelled out in a paired analysis.
Does a high AUC mean the test is clinically useful?
Not necessarily. AUC is a **threshold-independent** summary of discriminative ability, but clinical use depends on a specific threshold. Two curves with identical AUC can differ substantially in the range of specificity you actually care about (say, specificity > 90%). To pick a threshold, read the ROC table row by row rather than relying on a single AUC. Also note that AUC is unaffected by prevalence, whereas positive predictive value is — in a low-prevalence population a marker with AUC 0.9 can still yield mostly false positives. The [Diagnostic 2×2 table calculator](../diagnostic-2x2/) on this site handles that side of the analysis.
Related tools
Diagnostic Test 2×2 Table Calculator: Sensitivity, Specificity, and Predictive Values
Enter TP/FP/FN/TN; compute sensitivity, specificity, PPV, NPV, likelihood ratios, Youden's J, and 95% Wilson CIs, with optional Bayesian prevalence updating.
Hardy-Weinberg Equilibrium Calculator: Allele Frequency, Genotype Frequency, and HWE Departure Test
Enter a minor allele frequency or observed genotype counts to get HWE expected frequencies and a χ² departure test — for GWAS QC and carrier frequency estimation.
Multiple Testing Correction Calculator: BH (FDR), BY, and Bonferroni
Paste a column of p-values and get BH q-values, BY, and Bonferroni corrections side by side in one step.
Buy me a coffee