HDiagnostic · Guide test 309
DeLong AUC comparison test
Tests equality of areas under ROC curves, with paired covariance handling for measurements on the same subjects.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Compare two ROC curves (paired) — Does one marker discriminate better than another on the same subjects?
In Compare two ROC curves (paired), choose Test = DeLong's paired test (equal AUCs).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · DeLong AUC comparison test
Cases score this many SDs higher on marker 1.
Both markers are measured on the same people, so their errors correlate.
Your data
Simulated with known separationsThe two markers are measured on the same people, so their AUCs are correlated; DeLong compares the areas, Venkatraman–Begg the whole curves.
If H₀ were true
- The reference: how z varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .004).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- each case's (control's) share of correctly ordered case–control pairs
- the covariance from measuring both markers on the same people, which the paired test uses
The verdict
z = 2.87, p = .004, ΔAUC = 0.19
p ≤ α = .050: reject H₀
Effect size: difference in AUC ΔAUC = 0.189
Compares areas only: crossing ROC curves can have equal AUCs and still differ where it matters clinically. Direction is fixed in advance (higher = case).
- Statistic
- 2.866
- p-value
- 0.0042
DeLong AUC comparison test on 30 cases and 30 controls, two markers each: z = 2.87, p = .004, ΔAUC = 0.19. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: two ROC areas are equal.
Assumptions
Independent cases and controls; pairing of marker scores within subject handled correctly; empirical full-AUC inference with adequate sample sizes.
Formula
Parameters and notation
For marker k, h(x,y)=I(x>y)+½I(x=y). Case placements vik=n⁻¹Σj h(xik,yjk); control placements ujk=m⁻¹Σi h(xik,yjk). S matrices are sample covariance across marker placement vectors.
Structure of the method
Express each empirical AUC as a case-control U-statistic, compute case and control placement vectors, estimate their covariance across markers and standardize the AUC difference. Paired comparisons retain within-subject covariance; genuinely independent samples use separate variance contributions.
Estimated and nuisance parameters
AUCs, placement means and covariance matrices are estimated. Case/control counts and marker direction determine the empirical ranking problem. Classifier training parameters are external to this test; treating training-set fitted predictions as fixed independent validation scores can underestimate uncertainty and exaggerate performance.
Settings and design choices
Prespecify paired/unpaired design, positive class, score direction, full versus partial AUC and alternative. The baseline sets both ROC directions explicitly and compares full empirical AUCs. DeLong is not the supported method for every smoothed or partial-AUC estimand; select a compatible alternative when needed.
Fitting and adaptation
Train or select predictive models outside the evaluation sample, then apply the paired AUC comparison to appropriate held-out scores. If resampling includes model fitting, repeat the complete training pipeline. This is evaluation covariance estimation, not fine-tuning the predictive model to win the test.
Sensitivity and robustness
Ties are handled with half credit, but extreme discreteness and small case counts reduce precision. Identical or perfect scores can produce degenerate estimated variance. Equal AUC does not imply identical ROC shape or equal clinical utility at a threshold; report the difference and interval, not only the p value.
How to use and calibrate
Use an asymptotic normal two sided test; set covariance zero for genuinely independent ROC samples with matching separate variances.
Example application
Compare discrimination of two markers measured on the same subjects.
Interpretation and pitfalls
Watch out
This tests AUC, not equality of entire ROC curves. Partial or smoothed AUCs need methods supported for those estimands.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Both predictions are on the same subjects. DeLong compares AUCs; Venkatraman tests equality of the ROC curves via permutation, a stronger/different target. Direction and event coding are fixed, not auto-selected.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: pROC
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
truth<-rep(c(0,1),each=60);score1<-truth+rnorm(120);score2<-.7*truth+rnorm(120);a<-pROC::roc(truth,score1,levels=c(0,1),direction="<",quiet=TRUE);b<-pROC::roc(truth,score2,levels=c(0,1),direction="<",quiet=TRUE)
print(pROC::roc.test(a,b,paired=TRUE,method="delong"))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs pROC
set.seed(2026)
truth<-rep(c(0,1),each=60);score1<-truth+rnorm(120);score2<-.7*truth+rnorm(120);a<-pROC::roc(truth,score1,levels=c(0,1),direction="<",quiet=TRUE);b<-pROC::roc(truth,score2,levels=c(0,1),direction="<",quiet=TRUE)
print(pROC::roc.test(a,b,paired=TRUE,method="delong"))
Output
DeLong's test for two correlated ROC curves data: a and b Z = 0.94692, p-value = 0.3437 alternative hypothesis: true difference in AUC is not equal to 0 95 percent confidence interval: -0.06567539 0.18845317 sample estimates: AUC of roc1 AUC of roc2 0.7583333 0.6969444
Sources
- pROC — pROC · roc.testAuthor documentation/source reviewed: pROC 1.19.1.search.r-project.org
- roc.testsearch.r-project.org
- rocsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 309, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT309.