Analyses two diagnostic tests applied in parallel: both are performed on the same subject at the same time, before either result is known, and the two results are then combined. Reports the post-test probability of disease for every result combination (either test positive, test 1 only, test 2 only, both positive, both negative), optionally allowing the two tests to be conditionally dependent. For tests performed one after another, where the second is ordered only after a particular first result, use Sequential Testing Analysis instead. Note that Sequential Testing Analysis also offers a parallel strategy, but its combined figures assume conditional independence; this analysis is the one that models conditional dependence numerically.
Usage
cotest(
test1_name = "",
test2_name = "",
test1_sens = 0.8,
test1_spec = 0.9,
test2_sens = 0.75,
test2_spec = 0.95,
indep = FALSE,
cond_dep_pos = 0.05,
cond_dep_neg = 0.05,
prevalence = 0.1,
showGuidance = FALSE,
fnote = FALSE,
fagan = FALSE,
faganColors = "jamovi",
preset = "custom"
)Arguments
- test1_name
Optional name for the first test (for example "HPV"). Used in the tables, the interpretation panel and the copy-ready summary. Leave blank for "Test 1".
- test2_name
Optional name for the second test (for example "Pap cytology"). Used in the tables, the interpretation panel and the copy-ready summary. Leave blank for "Test 2".
- test1_sens
Sensitivity (true positive rate) of Test 1.
- test1_spec
Specificity (true negative rate) of Test 1.
- test2_sens
Sensitivity (true positive rate) of Test 2.
- test2_spec
Specificity (true negative rate) of Test 2.
- indep
Assume tests are conditionally independent (default is false for safety). Use true only if tests measure completely different phenomena.
- cond_dep_pos
Correlation between the two test results among subjects with disease, where 0 is conditional independence. 1 is the theoretical maximum, but the largest value the sensitivities you entered actually permit is often well below 1, and values above it are truncated to that bound with a warning; the correlation the fitted model achieved is reported as "Realized phi". Negative values describe tests that compensate for each other's errors and are permitted, but their feasible range is narrower still. A source that reports a conditional covariance (for example Gardner et al. 2000) must be converted first: phi = covariance / sqrt(Se1 (1 - Se1) Se2 (1 - Se2)). A kappa is an agreement statistic, not this correlation.
- cond_dep_neg
Correlation between the two test results among subjects without disease, where 0 is conditional independence. 1 is the theoretical maximum, but the largest value the specificities you entered actually permit is often well below 1, and values above it are truncated to that bound with a warning; the correlation the fitted model achieved is reported as "Realized phi". Negative values describe tests that compensate for each other's errors and are permitted, but their feasible range is narrower still. A source that reports a conditional covariance must be converted first: phi = covariance / sqrt(Fp1 (1 - Fp1) Fp2 (1 - Fp2)), where Fp = 1 - specificity. A kappa is an agreement statistic, not this correlation.
- prevalence
Prior probability (disease prevalence in the population). Requires a value between 0.001 and 0.999.
- showGuidance
Show the introductory guidance panel and the explanation of conditional dependence. Turn this off once you are familiar with the analysis to leave only the results.
- fnote
Add explanatory footnotes to the Test Parameters and Co-Testing Results tables, describing what each sensitivity, specificity, likelihood ratio and post-test probability means.
- fagan
Draw a Fagan nomogram for the parallel decision rule (positive if either test is positive, negative only if both are negative). Its positive arm corresponds to the "Either Test Positive" row of the results table, not to "Both Tests Positive".
- faganColors
Colors of the Fagan nomogram's lines: "jamovi" follows the global palette, "classic" draws the positive-result line red and the negative-result line blue.
- preset
Select a worked example, or "custom" to enter your own values. Selecting a worked example OVERRIDES test1_sens, test1_spec, test2_sens, test2_spec, prevalence, indep, cond_dep_pos and cond_dep_neg; any values passed for those arguments are ignored, and the analysis reports which ones it discarded. The worked examples fill those parameters with round ILLUSTRATIVE numbers chosen to demonstrate the calculation. They are not pooled literature estimates, are not taken from any guideline, have not been checked for clinical accuracy, and must not be used for patient care.
Value
A results object containing:
results$instructions | a html | ||||
results$notices | a html | ||||
results$testParamsTable | a table | ||||
results$cotestResultsTable | a table | ||||
results$dependenceInfo | a html | ||||
results$dependenceExplanation | a html | ||||
results$explanation | a html | ||||
results$plot1 | an image |
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$testParamsTable$asDF
as.data.frame(results$testParamsTable)
Examples
# Two tests run in PARALLEL: both are performed on the same subject at the same
# time, before either result is known, and the two results are then combined.
# (For tests run one after another, where the second is ordered only after a
# particular first result, use a sequential testing analysis instead.)
# Conditionally independent tests -- usually the optimistic assumption, so it has
# to be justified (see "Understanding Test Dependence")
res <- cotest(
test1_sens = 0.80,
test1_spec = 0.90,
test2_sens = 0.75,
test2_spec = 0.95,
prevalence = 0.10,
indep = TRUE
)
# Tests that tend to err together: same specimen, same biology. Dependence is
# given as a correlation within each disease group (0 = independence).
res <- cotest(
test1_sens = 0.85,
test1_spec = 0.88,
test2_sens = 0.82,
test2_spec = 0.92,
prevalence = 0.05,
indep = FALSE,
cond_dep_pos = 0.15,
cond_dep_neg = 0.10,
fnote = TRUE
)
# The built-in worked examples are FOR DEMONSTRATION ONLY. Their sensitivity,
# specificity, prevalence and dependence values are round illustrative numbers
# chosen to show how the calculation behaves. They are not pooled literature
# estimates, are not drawn from any guideline, have not been checked for clinical
# accuracy, and must not be used for patient care. Supply your own values from a
# validation study in a population like yours before acting on any result.
# Selecting one OVERRIDES every parameter argument you pass.
res <- cotest(preset = "hpv_pap", showGuidance = FALSE)