Evaluate performance and prevalence for any series of diagnostics tests, incl. SARS
The Bayes Lines Tool is a revolutionary set of software tools for back solving disease prevalence, test performance and confusion matrices for diagnostic test reports.
How does it work?
For all permutations of prevalence, sensitivity, and specificity, the Bayes Lines Tool returns all confusion matrixes for which the true + false positives equals the number of positives reported.
No prior knowledge of prevalence, sensitivity & specificity, type of test kits, or lab guidelines is required.
The Bayes Lines Tool consists of an SQL script and a simplified version in Excel. Both are available for download.
The SQL script generates all possible Bayesian confusion matrixes for a (series of) diagnostic test results, without making assumptions about prevalence, sensitivity or specificity.
The code in standard SQL is given as follows:
with tests as ( select :reg :: text as region_name, :rid :: text as report_id, :tst :: float as tests, :pos :: float as positives ), permutations as ( select sens :: float as sensitivity, spec :: float as specificity from generate_series(0.005, 1.000, 0.005) as sens, generate_series(0.005, 1.000, 0.005) as spec ), prevalences as ( select (positives / tests + specificity - 1) :: float / (sensitivity + specificity - 1) :: float as prevalence, * from permutations, tests where sensitivity + specificity > 1 ), matrices as ( select (tests * prevalence * sensitivity) :: float as true_positives, (tests * (1 - prevalence) * specificity) :: float as true_negatives, * from prevalences where prevalence between 0 and 1 ), results as ( select positives - true_positives as false_positives, (tests - positives) - true_negatives as false_negatives, * from matrices ) select region_name, report_id, (tests) :: int as tests_performed, (positives) :: int as positives_reported, (tests * prevalence) :: int as has_disease, (tests * (1 - prevalence)) :: int as hasnot_disease, (true_positives) :: int as true_positives, (false_positives) :: int as false_positives, (true_negatives) :: int as true_negatives, (false_negatives) :: int as false_negatives, sensitivity :: numeric(4,3), specificity :: numeric(4,3), prevalence :: numeric(4,3) from results where (false_positives + true_positives) :: int = positives :: int
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Excel file last updated Jan 25 2021, marked as version 1.2. Please note that this is based on a previous version of the SQL code. An update is on its way and will be made available soon.
The examples presented in the paper (both figures and underlying data) are available in the Tableau workbooks, which can be downloaded below.
This group of scientists submitted a research paper titled “Bayes Lines Tool (BLT) – A SQL-script for analyzing diagnostic test results with an application to SARS-CoV-2-testing” with F1000 Research on 23 January 2021.
Follow us on our individual Twitter accounts, or join the discussion in the #UnbiasedScience channel on Telegram.
You can also reach us at email@example.com