Skip to contents

Function for comparing multiple Medical Decision Tests. Compares sensitivity, specificity, positive predictive value, negative predictive value, and other metrics between different tests against the same golden standard. Includes statistical comparison using McNemar's test and confidence intervals for differences.

Usage

decisioncompare(
  data,
  gold,
  goldPositive,
  test1,
  test1Positive,
  test2,
  test2Positive,
  test3 = NULL,
  test3Positive,
  pp = FALSE,
  pprob = 0.3,
  od = FALSE,
  fnote = FALSE,
  ci = FALSE,
  plot = FALSE,
  radarplot = FALSE,
  statComp = FALSE,
  showSummary = FALSE,
  showExplanations = FALSE,
  showReportSentence = FALSE
)

Arguments

data

The data as a data frame.

gold

The gold standard reference variable representing true disease status.

goldPositive

The level indicating presence of disease in the gold standard variable.

test1

The first diagnostic test variable being evaluated for performance.

test1Positive

The level representing a positive result for Test 1.

test2

The second diagnostic test variable for comparison analysis.

test2Positive

The level representing a positive result for Test 2.

test3

Optional third diagnostic test variable for extended comparison analysis.

test3Positive

The level representing a positive result for Test 3.

pp

Enable custom prior probability (prevalence) for predictive value calculations.

pprob

Prior probability (disease prevalence in the community). Requires a value between 0.001 and 0.999, default 0.300.

od

Boolean selection whether to show frequency tables. Default is 'false'.

fnote

.

ci

.

plot

Generate comparison plot showing test performance metrics.

radarplot

Generate radar plot for comprehensive test comparison visualization.

statComp

Perform statistical comparison between tests (McNemar's test and confidence intervals for differences).

showSummary

Boolean to show natural language summary of statistical comparisons.

showExplanations

Boolean to show explanations, glossary, and educational content.

showReportSentence

Boolean to show manuscript-ready report sentence.

Value

A results object containing:

results$text1a preformatted
results$text2a html
results$cTable1a table
results$epirTable1a table
results$cTable2a table
results$epirTable2a table
results$cTable3a table
results$epirTable3a table
results$comparisonTablea table
results$mcnemarTablea table
results$diffTablea table
results$plot1an image
results$plotRadaran image
results$summaryReporta html
results$reportSentencea html
results$explanationsContenta html
results$clinicalReporta html
results$aboutAnalysisa html

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$cTable1$asDF

as.data.frame(results$cTable1)

Examples

# Basic comparison of two diagnostic tests
library(ClinicoPath)
#> Error in library(ClinicoPath): there is no package called ‘ClinicoPath’
data('histopathology')

# Example 1: Compare imaging vs blood test performance
result1 <- decisioncompare(
    data = histopathology,
    gold = "Golden Standart",
    goldPositive = "1",
    test1 = "New Test",
    test1Positive = "1",
    test2 = "Rater 1",
    test2Positive = "1",
    ci = TRUE,
    plot = TRUE
)
#> Error in decisioncompare(data = histopathology, gold = "Golden Standart",     goldPositive = "1", test1 = "New Test", test1Positive = "1",     test2 = "Rater 1", test2Positive = "1", ci = TRUE, plot = TRUE): argument "test3Positive" is missing, with no default

# Example 2: Three-test comparison with statistical analysis
result2 <- decisioncompare(
    data = histopathology,
    gold = "Golden Standart",
    goldPositive = "1",
    test1 = "New Test",
    test1Positive = "1",
    test2 = "Rater 1",
    test2Positive = "1",
    test3 = "Rater 2",
    test3Positive = "1",
    statComp = TRUE,
    radarplot = TRUE
)
#> Warning: Removed 1 rows with missing values
#> Performing 3 pairwise comparisons with Holm-Bonferroni correction...
#> Statistical comparisons completed (3 comparisons, Holm-Bonferroni corrected).

# Example 3: Using custom prevalence for clinical setting
result3 <- decisioncompare(
    data = histopathology,
    gold = "Golden Standart",
    goldPositive = "1",
    test1 = "New Test",
    test1Positive = "1",
    test2 = "Rater 1",
    test2Positive = "1",
    pp = TRUE,
    pprob = 0.15,  # 15\% prevalence in screening population
    od = TRUE      # Show original frequency tables
)
#> Error in decisioncompare(data = histopathology, gold = "Golden Standart",     goldPositive = "1", test1 = "New Test", test1Positive = "1",     test2 = "Rater 1", test2Positive = "1", pp = TRUE, pprob = 0.15,     od = TRUE): argument "test3Positive" is missing, with no default