Skip to content

HDiagnostic · Guide test 310

Venkatraman ROC curve test

Uses permutations to test equality of entire ROC curves, rather than just their areas.

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 = Venkatraman's permutation test (identical curves).

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 · Venkatraman ROC curve 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

E = 340.00
  1. The reference: how E varies across samples when H₀ is true, 500 paired swaps of the two markers' ranks (permutation null on the shared stream).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .008).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

E=∑k=1n∣e1(k)−e2(k)∣,em(k)=#{cases ranked≤k}−#{controls ranked≤k}E=\sum_{k=1}^{n}\big|e_1(k)-e_2(k)\big|,\qquad e_m(k)=\#\{\text{cases ranked}\le k\}-\#\{\text{controls ranked}\le k\}

With your numbers

E=340,n=60,500 permutationsE = 340,\quad n = 60,\quad 500\text{ permutations}
em(k)e_m(k)
the error curve of marker m at rank threshold k
permutation\text{permutation}
each person's two ranks are swapped at random (with jitter), keeping the pairing

The verdict

E = 340, p = .008

p ≤ α = .050: reject H₀

Tests the whole curve, so it reacts to curves that cross; it does not say which marker is better or where. Its p comes from permutations, so it moves slightly with their number.

Statistic
340.000
p-value
0.0080
Venkatraman ROC curve test on 30 cases and 30 controls, two markers each: E = 340, p = .008. The p-value is below α = .050, so the data are hard to reconcile with H0.

Venkatraman ROC curve test on 30 cases and 30 controls, two markers each: E = 340, p = .008. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: two ROC curves are identical over the threshold range.

Assumptions

Independent subjects with correct paired/unpaired design; valid label/within-subject permutation under H0; score ranking and ties handled consistently.

Formula

T=∫01∣ROC^1(u)−ROC^2(u)∣ duT=\int_0^1|\widehat{ROC}_1(u)-\widehat{ROC}_2(u)|\,du

Parameters and notation

u is false-positive rate; the rank-based Venkatraman statistic is a discrete integrated curve discrepancy, with implementation-specific scaling and rank tie rules.

Structure of the method

Use the published rank-based discrepancy and permutation scheme to compare the complete ROC curves. A simple integral of absolute ROC differences conveys the goal but is not a drop-in specification of every normalization, ranking or paired-permutation detail in the implemented Venkatraman algorithm.

Estimated and nuisance parameters

Empirical ranks and curve discrepancies are estimated from scores and outcomes; the permutation distribution supplies calibration. No smoothing bandwidth or fitted regression parameter is intrinsic to the standard rank test. Pairing and score direction are design inputs whose correct specification determines allowable rearrangements.

Settings and design choices

Choose paired/unpaired design, tie method, permutation count, score orientation and global curve alternative. pROC exposes ties.method and boot.n for this method and supports a two-sided comparison. Smoothed ROC curves are not supported for its Venkatraman implementation; do not silently treat a bootstrap AUC test as equivalent.

Fitting and adaptation

Use a validated implementation that preserves the intended null and pairing. If scores arise from fitted models, evaluate on an appropriate independent sample or account for fitting within a valid resampling framework. More permutations improve Monte Carlo precision but do not repair an invalid exchangeability assumption.

Sensitivity and robustness

Crossing curves can be detected even when AUCs are similar. A global discrepancy may be driven by an operating region irrelevant to the application, so complement it with prespecified threshold/region summaries. Heavy ties, small samples, identical rankings and perfect separation can create degenerate or unstable behavior; report numerical and permutation settings.

How to use and calibrate

Use the Venkatraman rank-permutation algorithm for paired or unpaired curves; recompute the complete statistic each replicate.

Example application

Detect crossing ROC curves whose total AUCs might be equal.

Interpretation and pitfalls

Watch out

Permuting outcomes indiscriminately is not the same null. Rejection concerns curve shape, not necessarily clinically relevant operating thresholds.

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="venkatraman",boot.n=999))
"""
# 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="venkatraman",boot.n=999))
Output
	Venkatraman's test for two paired ROC curves

data:  a and b
E = 462, boot.n = 999, p-value = 0.4885
alternative hypothesis: true difference in at least one ROC operating point is not equal to 0

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 310, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT310.