Comparing and Combining Diagnostic Tests
Source:vignettes/14-decision-compare-combine.Rmd
14-decision-compare-combine.RmdWhen two or three binary diagnostic tests are evaluated on the same patients, paired analyses keep within-patient correlation intact:
-
Compare Medical Decision Tests
(
decisioncompare(), meddecide > Decision > Compare Medical Decision Tests) compares paired sensitivity, specificity, predictive values, likelihood ratios, McNemar mid-p tests, Newcombe Method 10 paired differences, and (for three tests) Cochran’s Q. -
Combine Medical Decision Tests
(
decisioncombine(), meddecide > Decision > Combine Medical Decision Tests) evaluates every single test, Boolean combination (Parallel OR, Serial AND, majority), and exact multi-test result pattern empirically — without assuming conditional independence.
See Choosing and interpreting an analysis for reference-standard requirements, denominator alignment, and verification bias.
Try the saved analyses in jamovi
Open Imaging Tests Comparison from the meddecide Data Library and select the saved Compare Medical Decision Tests analysis. Turn on the statistical comparisons and examine Paired N beside each comparison. Try dropping the third test. The global three-test result drops away and the remaining pair continues to use its joint complete cases. To compare predictive values at a specific population prevalence, enable Known population prevalence and enter a proportion. The per-test interval tables still use the observed sample prevalence.
Open Screening and Confirmatory Testing and select
the saved Combine Medical Decision Tests analysis. Read
the Row type in the combination table before
interpreting a row. A pattern such as +/- describes one
exact result pattern. Parallel and serial strategy rows count everyone
classified positive by the named rule. Enable Combinations vs
each test alone and use the paired difference columns to see
the trade-off between finding more cases and raising more false
positives.
Bundled dataset
breast_cancer_data contains 2,000 simulated screening
records with a binary outcome (cancer_status) and three
complete binary modalities (mammography,
ultrasound, clinical_exam), plus
mri performed on a subset of cases.
Comparing three paired tests: decisioncompare()
Both the positive and negative levels must be
specified explicitly for the reference standard and every test. Any
unselected level (such as an equivocal category) stops the analysis
unless excludeIndeterminate = TRUE is enabled.
cmp <- decisioncompare(
data = bc,
gold = "cancer_status",
goldPositive = "Cancer",
goldNegative = "No Cancer",
test1 = "mammography",
test1Positive = "BIRADS 3-5",
test1Negative = "BIRADS 1-2",
test2 = "ultrasound",
test2Positive = "Suspicious",
test2Negative = "Normal",
test3 = "clinical_exam",
test3Positive = "Abnormal",
test3Negative = "Normal",
ci = TRUE,
statComp = TRUE
)
cmp$comparisonTable$asDF
#> test
#> "test_1" mammography
#> "test_1_interp" → High sensitivity and high specificity in this sample (both >=95%); Strong positive evidence; Strong negative evidence (zero cell; LR may be unstable)
#> "test_2" ultrasound
#> "test_2_interp" → Moderately high sensitivity and specificity in this sample (both >=85%); Moderate positive evidence; Moderate negative evidence
#> "test_3" clinical_exam
#> "test_3_interp" → Moderately high specificity (>=85%) in this sample; Moderate positive evidence
#> n excluded excludedRate Sens Spec AccurT
#> "test_1" 2000 0 0 1.0000000 0.9526448 0.9530
#> "test_1_interp" NA NA NA NA NA NA
#> "test_2" 2000 0 0 0.8666667 0.8957179 0.8955
#> "test_2_interp" NA NA NA NA NA NA
#> "test_3" 2000 0 0 0.3333333 0.9405542 0.9360
#> "test_3_interp" NA NA NA NA NA NA
#> PPV NPV LRP LRN
#> "test_1" 0.13761468 1.0000000 21.117021 0.0000000
#> "test_1_interp" NA NA NA NA
#> "test_2" 0.05909091 0.9988764 8.310789 0.1488564
#> "test_2_interp" NA NA NA NA
#> "test_3" 0.04065041 0.9946723 5.607345 0.7088020
#> "test_3_interp" NA NA NA NA
cmp$mcnemarTable$asDF
#> comparison n method
#> "cochran_q_global" Overall (3 tests) 2000 Cochran's Q
#> "mammography vs ultrasound" mammography vs ultrasound 2000 McNemar mid-p
#> "mammography vs clinical_exam" mammography vs clinical_exam 2000 McNemar mid-p
#> "ultrasound vs clinical_exam" ultrasound vs clinical_exam 2000 McNemar mid-p
#> stat df p
#> "cochran_q_global" 52.355 2 4.278152e-12
#> "mammography vs ultrasound" NA NA 1.118384e-11
#> "mammography vs clinical_exam" NA NA 1.961087e-02
#> "ultrasound vs clinical_exam" NA NA 6.920721e-06
#> interpretation
#> "cochran_q_global" Highly significant overall difference among tests (p<0.001)
#> "mammography vs ultrasound" Highly significant difference (p<0.001) (Holm-Bonferroni corrected)
#> "mammography vs clinical_exam" Statistically significant difference (p<0.05) (Holm-Bonferroni corrected)
#> "ultrasound vs clinical_exam" Highly significant difference (p<0.001) (Holm-Bonferroni corrected)
cmp$diffTable$asDF
#> comparison metric
#> "mammography vs ultrasound_Sens" mammography vs ultrasound Sensitivity
#> "mammography vs ultrasound_Spec" mammography vs ultrasound Specificity
#> "mammography vs ultrasound_AccurT" mammography vs ultrasound Accuracy
#> "mammography vs clinical_exam_Sens" mammography vs clinical_exam Sensitivity
#> "mammography vs clinical_exam_Spec" mammography vs clinical_exam Specificity
#> "mammography vs clinical_exam_AccurT" mammography vs clinical_exam Accuracy
#> "ultrasound vs clinical_exam_Sens" ultrasound vs clinical_exam Sensitivity
#> "ultrasound vs clinical_exam_Spec" ultrasound vs clinical_exam Specificity
#> "ultrasound vs clinical_exam_AccurT" ultrasound vs clinical_exam Accuracy
#> n diff lower upper
#> "mammography vs ultrasound_Sens" 15 0.13333333 -0.092008717 0.37881983
#> "mammography vs ultrasound_Spec" 1985 0.05692695 0.040658304 0.07345309
#> "mammography vs ultrasound_AccurT" 2000 0.05750000 0.041301341 0.07395748
#> "mammography vs clinical_exam_Sens" 15 0.66666667 0.344433498 0.84823676
#> "mammography vs clinical_exam_Spec" 1985 0.01209068 -0.001977475 0.02625362
#> "mammography vs clinical_exam_AccurT" 2000 0.01700000 0.002724648 0.03139902
#> "ultrasound vs clinical_exam_Sens" 15 0.53333333 0.159810991 0.75015433
#> "ultrasound vs clinical_exam_Spec" 1985 -0.04483627 -0.061912018 -0.02792997
#> "ultrasound vs clinical_exam_AccurT" 2000 -0.04050000 -0.057735071 -0.02340594
#> p
#> "mammography vs ultrasound_Sens" 2.500000e-01
#> "mammography vs ultrasound_Spec" 7.465967e-12
#> "mammography vs ultrasound_AccurT" NA
#> "mammography vs clinical_exam_Sens" 9.765625e-04
#> "mammography vs clinical_exam_Spec" 9.184530e-02
#> "mammography vs clinical_exam_AccurT" NA
#> "ultrasound vs clinical_exam_Sens" 1.171875e-02
#> "ultrasound vs clinical_exam_Spec" 2.060919e-07
#> "ultrasound vs clinical_exam_AccurT" NA-
comparisonTablesummarizes each test against the reference on that test’s available determinate cases. -
mcnemarTablereports Cochran’s Q on cases complete for all three tests and the reference. Each McNemar comparison uses the cases complete for the two tests and the reference. Multiple pairwise accuracy p-values are adjusted by Holm’s method. Fagerland et al., 2013. -
diffTablegives first-test-minus-second differences in sensitivity, specificity and accuracy with Newcombe Method 10 score intervals. The sensitivity and specificity p-values are unadjusted and are calculated within the corresponding reference-status group. Overall accuracy depends on the case mix. Read it alongside the class-specific differences.
Comparator (imperfect reference) mode
When the benchmark is a comparative method or
expert consensus rather than an established clinical
disease reference, set referenceType = "method" (or
"consensus"). The output switches from
sensitivity/specificity/PPV to Positive Percent Agreement (PPA),
Negative Percent Agreement (NPA), and Overall Percent Agreement (OPA).
PPA and NPA condition on the comparator-positive and comparator-negative
groups respectively, so state which method supplied the comparison
result. FDA
statistical guidance for diagnostic-test studies.
The example below relabels the simulated reference as a comparator to illustrate the output:
cmp_method <- decisioncompare(
data = bc,
referenceType = "method",
referenceDescription = "Existing reference assay",
gold = "cancer_status",
goldPositive = "Cancer",
goldNegative = "No Cancer",
test1 = "mammography",
test1Positive = "BIRADS 3-5",
test1Negative = "BIRADS 1-2",
test2 = "ultrasound",
test2Positive = "Suspicious",
test2Negative = "Normal",
test3 = NULL,
test3Positive = NULL,
test3Negative = NULL,
ci = TRUE
)
cmp_method$comparatorMetrics$asDF
#> test metric numerator denominator
#> "1 1" mammography Positive percent agreement (PPA) 15 15
#> "1 2" mammography Negative percent agreement (NPA) 1891 1985
#> "1 3" mammography Overall percent agreement (OPA) 1906 2000
#> "1 4" mammography Reference positive given positive call 15 109
#> "1 5" mammography Reference negative given negative call 1891 1891
#> "1 6" mammography Positive specific agreement (symmetric) 30 124
#> "1 7" mammography Negative specific agreement (symmetric) 3782 3876
#> "2 1" ultrasound Positive percent agreement (PPA) 13 15
#> "2 2" ultrasound Negative percent agreement (NPA) 1778 1985
#> "2 3" ultrasound Overall percent agreement (OPA) 1791 2000
#> "2 4" ultrasound Reference positive given positive call 13 220
#> "2 5" ultrasound Reference negative given negative call 1778 1780
#> "2 6" ultrasound Positive specific agreement (symmetric) 26 235
#> "2 7" ultrasound Negative specific agreement (symmetric) 3556 3765
#> estimate lower upper
#> "1 1" 1.00000000 0.78198064 1.00000000
#> "1 2" 0.95264484 0.94235878 0.96156544
#> "1 3" 0.95300000 0.94278877 0.96185496
#> "1 4" 0.13761468 0.07911543 0.21679895
#> "1 5" 1.00000000 0.99805115 1.00000000
#> "1 6" 0.24193548 NA NA
#> "1 7" 0.97574819 NA NA
#> "2 1" 0.86666667 0.59539730 0.98342409
#> "2 2" 0.89571788 0.88143152 0.90882274
#> "2 3" 0.89550000 0.88125851 0.90856962
#> "2 4" 0.05909091 0.03183521 0.09892766
#> "2 5" 0.99887640 0.99594714 0.99986390
#> "2 6" 0.11063830 NA NA
#> "2 7" 0.94448871 NA NA
#> method
#> "1 1" Exact binomial (independent cases)
#> "1 2" Exact binomial (independent cases)
#> "1 3" Exact binomial (independent cases)
#> "1 4" Exact binomial (independent cases)
#> "1 5" Exact binomial (independent cases)
#> "1 6" Symmetric ratio; binomial CI not applicable
#> "1 7" Symmetric ratio; binomial CI not applicable
#> "2 1" Exact binomial (independent cases)
#> "2 2" Exact binomial (independent cases)
#> "2 3" Exact binomial (independent cases)
#> "2 4" Exact binomial (independent cases)
#> "2 5" Exact binomial (independent cases)
#> "2 6" Symmetric ratio; binomial CI not applicable
#> "2 7" Symmetric ratio; binomial CI not applicableCombining tests empirically: decisioncombine()
Unlike the calculator tools (cotest() and
sequentialtests()), decisioncombine() reads
patient-level paired results directly and therefore captures whatever
conditional dependence exists in the cohort.
cmb <- decisioncombine(
data = bc,
gold = "cancer_status",
goldPositive = "Cancer",
test1 = "mammography",
test1Positive = "BIRADS 3-5",
test2 = "ultrasound",
test2Positive = "Suspicious",
test3 = NULL,
test3Positive = NULL,
showPairedComparison = TRUE,
showRecommendation = TRUE
)
cmb$combinationTable$asDF
#> pattern rowType tp fp fn tn prevalence
#> "+/+" +/+ Pattern 13 11 2 1974 0.0075
#> "+/-" +/- Pattern 2 83 13 1902 0.0075
#> "-/+" -/+ Pattern 0 196 15 1789 0.0075
#> "-/-" -/- Pattern 0 1695 15 290 0.0075
#> "Test 1 alone" Test 1 alone Single test 15 94 0 1891 0.0075
#> "Test 2 alone" Test 2 alone Single test 13 207 2 1778 0.0075
#> "Parallel (>=1 pos)" Parallel (>=1 pos) Strategy 15 290 0 1695 0.0075
#> "Serial (all pos)" Serial (all pos) Strategy 13 11 2 1974 0.0075
#> sens spec ppv npv acc
#> "+/+" 0.8666667 0.9944584 0.54166667 0.9989879 0.9935
#> "+/-" 0.1333333 0.9581864 0.02352941 0.9932115 0.9520
#> "-/+" 0.0000000 0.9012594 0.00000000 0.9916851 0.8945
#> "-/-" 0.0000000 0.1460957 0.00000000 0.9508197 0.1450
#> "Test 1 alone" 1.0000000 0.9526448 0.13761468 1.0000000 0.9530
#> "Test 2 alone" 0.8666667 0.8957179 0.05909091 0.9988764 0.8955
#> "Parallel (>=1 pos)" 1.0000000 0.8539043 0.04918033 1.0000000 0.8550
#> "Serial (all pos)" 0.8666667 0.9944584 0.54166667 0.9989879 0.9935
#> balancedAccuracy youden youdenLower youdenUpper
#> "+/+" 0.93056255 0.86112510 0.63624097 0.99873935
#> "+/-" 0.54575987 0.09151973 -0.04723721 0.31562882
#> "-/+" 0.45062972 -0.09874055 -0.15293983 0.07229801
#> "-/-" 0.07304786 -0.85390428 -0.90764936 -0.68179970
#> "Test 1 alone" 0.97632242 0.95264484 0.78112328 1.00000000
#> "Test 2 alone" 0.88119228 0.76238455 0.53713257 0.90056541
#> "Parallel (>=1 pos)" 0.92695214 0.85390428 0.68179970 0.90764936
#> "Serial (all pos)" 0.93056255 0.86112510 0.63624097 0.99873935
#> lrPos lrNeg dor
#> "+/+" 156.393939 0.1340763 1166.454545
#> "+/-" 3.188755 0.9044865 3.525487
#> "-/+" 0.000000 1.1095584 0.000000
#> "-/-" 0.000000 6.8448276 0.000000
#> "Test 1 alone" 21.117021 0.0000000 620.492063
#> "Test 2 alone" 8.310789 0.1488564 55.830918
#> "Parallel (>=1 pos)" 6.844828 0.0000000 180.931153
#> "Serial (all pos)" 156.393939 0.1340763 1166.454545
cmb$pairedComparisonTable$asDF
#> rule comparator sensGained sensLost sensChange
#> "parallel_1" Parallel (>=1 pos) Test 1 alone 0 0 0.0000000
#> "parallel_2" Parallel (>=1 pos) Test 2 alone 2 0 0.1333333
#> "serial_1" Serial (all pos) Test 1 alone 0 2 -0.1333333
#> "serial_2" Serial (all pos) Test 2 alone 0 0 0.0000000
#> sensLower sensUpper sensP specGained specLost specChange
#> "parallel_1" 0.00000000 0.20388330 NA 0 196 -0.09874055
#> "parallel_2" 0.03736126 0.37881983 NA 0 83 -0.04181360
#> "serial_1" -0.37881983 -0.03736126 NA 83 0 0.04181360
#> "serial_2" -0.20388330 0.00000000 NA 196 0 0.09874055
#> specLower specUpper specP
#> "parallel_1" -0.11264902 -0.08638216 NA
#> "parallel_2" -0.05153994 -0.03385724 NA
#> "serial_1" 0.03385724 0.05153994 NA
#> "serial_2" 0.08638216 0.11264902 NAKey cautions when combining tests
-
Single tests remain candidates: Every individual
test is included in
combinationTableand rule rankings alongside Parallel (OR) and Serial (AND) combinations. A weak second test can perform worse in combination than the stronger test alone. -
Paired incremental trade-offs:
pairedComparisonTableshows how many diseased and non-diseased cases each combination gains or loses relative to each constituent test. For an OR rule, adding a test can only add positive calls. For an AND rule, it can only remove them. The table uses a score interval for the fraction changed in those one-directional comparisons, and Newcombe paired intervals and unadjusted McNemar mid-p values for majority rules that can move either way. -
Partial verification and reflex testing: If a
second test (such as
mriinbreast_cancer_data) or the reference standard was obtained selectively after a positive screen, complete-case sensitivity, specificity, and single-test or combined-rule predictive values can be severely biased. Indecisioncombine(), the single tests and rules in the main combination table share the all-tests-complete denominator. Check the missingness and exclusion counts before comparing it with a per-test row fromdecisioncompare(). -
Selection optimism: Choosing the highest-ranking
rule on the same data yields optimistic apparent performance; enable
optimismCorrection = TRUEto assess internal optimism and validate the locked rule on independent patients.