Skip to content

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.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

30
30
1.20

Cases score this many SDs higher on marker 1.

0.60
0.50

Both markers are measured on the same people, so their errors correlate.

0.050

Your data

Simulated with known separations
M1: AUC 0.750M2: AUC 0.561M1 casescontrolsM2 casescontrols

The 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

z = 2.87
  1. The reference: how z varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .004).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

z=AUC^1−AUC^2Var1+Var2−2 Cov12,Var, Cov from the structural components V10,V01z=\frac{\widehat{\mathrm{AUC}}_1-\widehat{\mathrm{AUC}}_2}{\sqrt{\mathrm{Var}_1+\mathrm{Var}_2-2\,\mathrm{Cov}_{12}}},\qquad \mathrm{Var},\ \mathrm{Cov}\ \text{from the structural components }V_{10},V_{01}

With your numbers

AUC1=0.75, AUC2=0.56,SE=0.07 (r=0.56),z=2.87\mathrm{AUC}_1 = 0.75,\ \mathrm{AUC}_2 = 0.56,\quad \mathrm{SE} = 0.07\ (r = 0.56),\quad z = 2.87
V10, V01V_{10},\ V_{01}
each case's (control's) share of correctly ordered case–control pairs
Cov12\mathrm{Cov}_{12}
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 H0.

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

Z=A^1−A^2V11+V22−2V12V=Scase/m+Scontrol/n\begin{gathered}Z=\frac{\widehat A_1-\widehat A_2}{\sqrt{V_{11}+V_{22}-2V_{12}}}\\[5pt] V=S_{case}/m+S_{control}/n\end{gathered}

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.

Python · invokes R

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()
R

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

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.