# Sensitivity, specificity, likelihood ratios, diagnostic odds ratio and predictive values from a 2 × 2 table, version 1.1.0

stats-diagnostic-accuracy\@1.1.0: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Tested, not reference-checked; Clopper–Pearson, Katz and Woolf papers not read: rest on statsmodels' code; epiR agrees; no PPV or NPV interval. Reference kind: an outside program, statsmodels, 0.15.0; a published dataset, Hajian-Tilaki 2013 Table 2; statsmodels, Caspian J Intern Med 4:627-635; statsmodels 0.15.0; a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-24, mpmath 1.4.1 at 60 significant digits; every root bracketed to a relative width below 1e-45; each output rounded once to the nearest double; not an outside program.**

Tested by this project, not reference-checked and not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with this project's own expected values within the stated tolerance. That tests the code against our own working, not against an outside reference. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these tests. No independent scientist has yet reviewed them.

[Every version of this method](https://www.drybench.com/methods/m/stats-diagnostic-accuracy) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 1.1.0

**Level: Tested, not reference-checked; Clopper–Pearson, Katz and Woolf papers not read: rest on statsmodels' code; epiR agrees; no PPV or NPV interval. Reference kind: an outside program, statsmodels, 0.15.0; a published dataset, Hajian-Tilaki 2013 Table 2; statsmodels, Caspian J Intern Med 4:627-635; statsmodels 0.15.0; a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-24, mpmath 1.4.1 at 60 significant digits; every root bracketed to a relative width below 1e-45; each output rounded once to the nearest double; not an outside program.** `stats-diagnostic-accuracy@1.1.0`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** Se, Sp, LR± and the predictive values as Hajian-Tilaki 2013 prints them (read at source); the Wilson interval as the NIST/SEMATECH e-Handbook §7.2.4.1 prints it (read 24 November 2026). Clopper and Pearson 1934, Katz et al. 1978 and Woolf 1955 were not read (subscription, bot checks); those intervals rest on statsmodels 0.14.4's code, read. By exact rational arithmetic and a hand-worked case; against statsmodels 0.15.0 (no zero-cell correction) at every offered level and method; against epiR 2.0.67 (R 4.3.3, independent of statsmodels) on 66 tables, 1,012 of 1,021 values within relative 1e-12, the other nine one table's LR+ where epiR's 1 − Sp cancels (the tool agrees with 50-digit arithmetic); Se and Sp against Hajian-Tilaki 2013 Table 2. No interval on PPV or NPV; ratios withheld at a zero cell; interval coverage at small counts not checked. Clopper–Pearson is refused above 10^5 subjects per row, the top of what epiR checked, since its time grows linearly with the count (D0273B-F1); Wilson and the ratios take the schema's whole range, which epiR checked to 10^9.

Se and Sp with a Wilson or Clopper–Pearson interval, LR+ and LR− with the Katz log interval, the diagnostic odds ratio with Woolf's log interval, and PPV and NPV at a prevalence the caller states.

- **How results are reported:** none: full double precision
- **Uncertainty:** Wilson or Clopper–Pearson for Se and Sp; Katz log for LR±; Woolf log for the DOR; none for PPV and NPV; its coverage is not checked
- **Computes through this project's own routines:** the Wilson score interval for sensitivity and specificity; the Clopper–Pearson interval for sensitivity and specificity; the likelihood ratios and their Katz intervals, as relative risks; the diagnostic odds ratio and its Woolf interval
- **Reference, as its record states it:** statsmodels 0.15.0 and SciPy 1.18.1, exact rational arithmetic, Hajian-Tilaki 2013's printed table, and epiR 2.0.67 (R) on 66 tables

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

92 cases in 3 files, linked by this exact version.

Run through the tool at build against an outside program, statsmodels, 0.15.0; a published dataset, Hajian-Tilaki 2013 Table 2; statsmodels, Caspian J Intern Med 4:627-635; statsmodels 0.15.0; a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-24, mpmath 1.4.1 at 60 significant digits; every root bracketed to a relative width below 1e-45; each output rounded once to the nearest double; not an outside program: 75 agree within the tolerance the file states, 17 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 27 cases**
  - **Where the expected values came from:** an outside program, statsmodels 0.15.0
  - **Recorded on:** 2026-11-25
  - **Reference:** statsmodels, 0.15.0; licence BSD-3-Clause
  - **Tolerance as the file states it:** sensitivity, specificity, PPV and NPV 1e-15 absolute; their interval limits 1e-12 absolute against statsmodels; likelihood ratios and the diagnostic odds ratio 1e-14 relative, their interval limits 1e-12 relative, each absolute below 1e-6; levels, counts, methods, statuses and codes exact

- **File 2, 4 cases**
  - **Where the expected values came from:** a published dataset, Hajian-Tilaki 2013 Table 2; statsmodels Caspian J Intern Med 4:627-635; statsmodels 0.15.0
  - **Recorded on:** 2026-11-25
  - **Reference:** Hajian-Tilaki 2013 Table 2; statsmodels, Caspian J Intern Med 4:627-635; statsmodels 0.15.0; licence To be checked
  - **Tolerance as the file states it:** printed sensitivity and specificity 0.0005, tighter than half a unit for the two-decimal values (the exact fractions match exactly); other values as in stats-diagnostic-accuracy-1

- **File 3, 61 cases**
  - **Where the expected values came from:** an outside program, second implementation (Python 3.13) 2026-11-24
  - **Recorded on:** 2026-11-25
  - **Reference:** second implementation (Python 3.13), 2026-11-24; licence BSD-3-Clause
  - **Tolerance as the file states it:** every number relative 1e-12 (absolute 1e-15 below 1e-3, in each value's unit); counts, labels, strings, flags, statuses and codes exact

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was not checked

The coverage of the intervals at small counts (the relative-risk interval's coverage is unchecked); the primary papers behind the imported intervals (Wilson 1927, Clopper and Pearson 1934, Woolf 1955, Katz et al. 1978) are not read: Wilson rests on the NIST/SEMATECH e-Handbook, the other three on statsmodels 0.14.4's code; Clopper–Pearson is refused above 10^5 subjects per row (D0273B-F1: its time grows linearly with the count); no interval is given for PPV or NPV; the caller's counts and the independence of the diseased and non-diseased samples. The tool assumes every subject received the reference standard whatever the test result (no partial verification) and that the reference standard is correct; a table biased either way cannot be detected from its counts.

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
Se = TP / (TP + FN)
```

| Symbol | Meaning and unit |
| --- | --- |
| TP | true positives (a count) |
| FN | false negatives (a count) |
| Se | sensitivity |

Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section section on sensitivity and specificity, 2 × 2 table (a = TP, c = FN), version of record, PMC full text (PMC3755824); read in full on 2026-11-10 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a14f2a5fab99. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-11. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.

**Equation 2**

```equation
Sp = TN / (TN + FP)
```

| Symbol | Meaning and unit |
| --- | --- |
| TN | true negatives (a count) |
| FP | false positives (a count) |
| Sp | specificity |

Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section section on sensitivity and specificity (d = TN, b = FP), version of record, PMC full text (PMC3755824); read in full on 2026-11-10 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a14f2a5fab99. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-11. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.

**Equation 3**

```equation
LR+ = Se / (1 − Sp)
LR− = (1 − Se) / Sp
```

| Symbol | Meaning and unit |
| --- | --- |
| LR+ | positive likelihood ratio |
| LR− | negative likelihood ratio |

Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section section on likelihood ratios, version of record, PMC full text (PMC3755824); read in full on 2026-11-10 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a14f2a5fab99. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-11. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.

**Equation 4**

```equation
PPV = p·Se / [p·Se + (1 − p)(1 − Sp)]
NPV = (1 − p)·Sp / [p(1 − Se) + (1 − p)·Sp]
```

| Symbol | Meaning and unit |
| --- | --- |
| p | prevalence stated by the caller |
| PPV | positive predictive value |
| NPV | negative predictive value |

Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section section on predictive values, the Bayes form, version of record, PMC full text (PMC3755824); read in full on 2026-11-10 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a14f2a5fab99. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-11. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.

Two readings: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section section on predictive values, the Bayes form can be read as PPV = p·Se / \[p·Se + (1 − p)(1 − Sp)\], Bayes' theorem with the false-positive rate or as p·Sen / \[p·Sen + (1 − p)·Spe\], as the source prints it. This project takes PPV = p·Se / \[p·Se + (1 − p)(1 − Sp)\], Bayes' theorem with the false-positive rate, because the printed denominator contradicts the source's own PPV = a/(a + b): at the sample prevalence it gives a/(a + d), where Bayes' form gives a/(a + b); NPV is printed in Bayes' form (found by the second implementation's agent, 24 November 2026). Taking p·Sen / \[p·Sen + (1 − p)·Spe\], as the source prints it would give a different result.

**Equation 5**

```equation
Wilson (no continuity correction): (p̂ + z²/(2n) ± z·√(p̂(1 − p̂)/n + z²/(4n²))) / (1 + z²/n)
z = Φ⁻¹(1 − (1 − level)/2) = Φ⁻¹((1 + level)/2)
```

| Symbol | Meaning and unit |
| --- | --- |
| p̂ | Se or Sp |
| n | TP + FN or TN + FP (a count) |
| level | confidence level |
| z | the standard normal quantile Φ⁻¹((1 + level)/2) |
| Φ⁻¹ | the standard normal quantile function |

Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4.1 Confidence intervals (for a proportion), section 7.2.4.1, Formulas for the confidence intervals (the Wilson method, after Wilson 1927), the online e-Handbook page as retrieved (NIST/SEMATECH, 2012 web edition); the page bytes; read in full on 2026-11-24 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f482e716abfd. Free to read (US-government work (NIST)), checked 2026-11-24. No erratum found (searched the page itself), 2026-11-24.

**Equation 6**

```equation
Clopper–Pearson: lower = B⁻¹((1 − level)/2
x, n − x + 1), upper = B⁻¹((1 + level)/2
x + 1, n − x), the lower bound 0 at x = 0 and the upper 1 at x = n
```

| Symbol | Meaning and unit |
| --- | --- |
| n | TP + FN or TN + FP (a count) |
| x | TP or TN (a count) |
| level | confidence level |
| B⁻¹(q; a, b) | the q quantile of the beta distribution with shape parameters a and b |

Source: Clopper CJ, Pearson ES 1934, Biometrika 26:404-413; Woolf B 1955, Ann Hum Genet 19:251-253; Katz D et al. 1978, Biometrics 34:469-474, section clopperPearson; Clopper and Pearson 1934 not read, as statsmodels 0.14.4 stored reference values lines 261-270 computes it; not read: Woolf 1955 (Wiley) answered HTTP 403 and Katz 1978 (JSTOR) a client challenge to the raising session on 14 November 2026; Morris and Gardner 1988 (BMJ 296:1313, PMC2545775), which prints both log intervals, answered a reCAPTCHA page at PMC's PDF and Europe PMC's render on 24 November 2026; Clopper and Pearson 1934 (Biometrika, Oxford) not served openly. Read in its place: statsmodels 0.14.4 (Seabold S, Perktold J et al.), stored reference values (proportion\_confint, method 'beta') and stored reference values (Table2x2.log\_riskratio\_se, log\_oddsratio\_se and their confint methods), section stored reference values lines 261-270 (SHA-256 b039f25cf95166fcc882a9fd47f72b7ab90013bfda9823aa7acf3c2950978ed9); stored reference values log\_riskratio\_se, log\_oddsratio\_se, log\_riskratio\_confint, log\_oddsratio\_confint (SHA-256 af2e5455df459abc9ced79186e16fecf38344cc630aeec1ade9e6e65b488090f), the installed 0.14.4 wheel's source files (PyPI); the authors' code, read, not run as the source of any number; read in full on 2026-11-24 by an AI-assisted session; not yet checked by a person. Behind a subscription, checked 2026-11-24. No erratum found (searched Crossref: update and relation metadata for 10.1093/biomet/26.4.404, Crossref: update and relation metadata for 10.1111/j.1469-1809.1955.tb01348.x, Crossref: update and relation metadata for 10.2307/2530610), 2026-11-11.

**Equation 7**

```equation
for an arranged table [[a, b], [c, d]], RR = (a/(a + b)) / (c/(c + d)), the ratio of the first row's proportion to the second's
LR+ = RR of [[TP, FN], [FP, TN]] and LR− = RR of [[FN, TP], [TN, FP]], each with the interval exp(log RR ± z·√(1/a − 1/(a + b) + 1/c − 1/(c + d))) (Katz, two independent proportions)
DOR = TP·TN/(FN·FP) with exp(log DOR ± z·√(1/TP + 1/FN + 1/FP + 1/TN)) (Woolf)
```

| Symbol | Meaning and unit |
| --- | --- |
| a, b, c, d | the arranged table's cells (a count) |
| RR | relative risk |
| DOR | diagnostic odds ratio |
| z | the standard normal quantile Φ⁻¹((1 + level)/2), level the confidence level |

Source: Clopper CJ, Pearson ES 1934, Biometrika 26:404-413; Woolf B 1955, Ann Hum Genet 19:251-253; Katz D et al. 1978, Biometrics 34:469-474, section relativeRiskKatz and oddsRatioWoolf; Katz 1978 and Woolf 1955 not read, as statsmodels 0.14.4 Table2x2.log\_riskratio\_se and log\_oddsratio\_se compute them; not read: Woolf 1955 (Wiley) answered HTTP 403 and Katz 1978 (JSTOR) a client challenge to the raising session on 14 November 2026; Morris and Gardner 1988 (BMJ 296:1313, PMC2545775), which prints both log intervals, answered a reCAPTCHA page at PMC's PDF and Europe PMC's render on 24 November 2026; Clopper and Pearson 1934 (Biometrika, Oxford) not served openly. Read in its place: statsmodels 0.14.4 (Seabold S, Perktold J et al.), stored reference values (proportion\_confint, method 'beta') and stored reference values (Table2x2.log\_riskratio\_se, log\_oddsratio\_se and their confint methods), section stored reference values lines 261-270 (SHA-256 b039f25cf95166fcc882a9fd47f72b7ab90013bfda9823aa7acf3c2950978ed9); stored reference values log\_riskratio\_se, log\_oddsratio\_se, log\_riskratio\_confint, log\_oddsratio\_confint (SHA-256 af2e5455df459abc9ced79186e16fecf38344cc630aeec1ade9e6e65b488090f), the installed 0.14.4 wheel's source files (PyPI); the authors' code, read, not run as the source of any number; read in full on 2026-11-24 by an AI-assisted session; not yet checked by a person. Behind a subscription, checked 2026-11-24. No erratum found (searched Crossref: update and relation metadata for 10.1093/biomet/26.4.404, Crossref: update and relation metadata for 10.1111/j.1469-1809.1955.tb01348.x, Crossref: update and relation metadata for 10.2307/2530610), 2026-11-11.

### Conventions

What each mode computes:

- `interval = wilson`: Sensitivity and specificity, each a proportion (unit 1), with Wilson's score interval without continuity correction at the stated level (R prop.test(correct = FALSE)).
- `interval = clopper-pearson`: Sensitivity and specificity, each a proportion (unit 1), with the Clopper–Pearson interval from beta quantiles at the stated level (R binom.test); 0 at x = 0 and 1 at x = n.

### Constants

Constants: none used.

### Worked example

Worked example: one case of stats-diagnostic-accuracy\@1.1.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

**Inputs**

- truePositive = 90
- falsePositive = 10
- falseNegative = 10
- trueNegative = 90
- interval = wilson
- level = 0.95
- prevalence = 0.01

**Steps**

1. se = 0.9, from truePositive, falseNegative; by equation 1; gives sensitivity.estimate.
2. sp = 0.9, from trueNegative, falsePositive; by equation 2; gives specificity.estimate.
3. lr-positive = 9, from se, sp; by equation 3; gives likelihoodRatioPositive.estimate.
4. ppv = 0.083333333, from se, sp, prevalence; by equation 4; gives positivePredictiveValue.estimate.

The working, as the case writes it:

```equation
Se = 90/100
Sp = 90/100
LR+ = 0.9/0.1 = 9
LR- = 0.1/0.9 = 1/9
DOR = 90·90/(10·10) = 81
PPV = 0.009/(0.009 + 0.099) = 1/12
NPV = 0.891/(0.001 + 0.891) = 891/892
```

**Answer**

- `sensitivity.estimate` = **0.9**
- `specificity.estimate` = **0.9**
- `likelihoodRatioPositive.estimate` = **9**
- `positivePredictiveValue.estimate` = **0.083333333**

Where these values came from: an outside program, statsmodels 0.15.0; exact arithmetic; worked by hand in stored reference values §3.4; intervals from statsmodels.

At build the tool returned this answer within the tolerance the file states: sensitivity, specificity, PPV and NPV 1e-15 absolute; their interval limits 1e-12 absolute against statsmodels; likelihood ratios and the diagnostic odds ratio 1e-14 relative, their interval limits 1e-12 relative, each absolute below 1e-6; levels, counts, methods, statuses and codes exact.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `PREVALENCE_AT_BOUND`: the stated prevalence is 0 or 1, where one predictive value is zero over zero Next: State a prevalence above 0 and below 1, or leave it out to get sensitivity and specificity without predictive values.
- `NO_SUBJECTS`: all four counts are zero Next: Give the counts of a study with at least one subject.
- `CLOPPER_PEARSON_ROW_ABOVE_RANGE`: interval is 'clopper-pearson' and TP + FN or TN + FP is above 10^5 (one hundred thousand), the largest row the outside program checked Clopper–Pearson at; its time grows linearly with the count (D0273B-F1); checked after NO\_SUBJECTS Next: Ask for interval 'wilson', which takes every count the schema allows, or give at most 10^5 subjects in each row.

**Input ranges:** prevalence: above 0 and below 1; outside it, refused (PREVALENCE\_AT\_BOUND).

### Changes

No correction is logged for stats-diagnostic-accuracy\@1.1.0.

## Tools that use it

- [`stats_diagnostic_accuracy`](https://www.drybench.com/methods/tools/stats-diagnostic-accuracy)

## Cite this version

Sensitivity, specificity, likelihood ratios, diagnostic odds ratio and predictive values from a 2 × 2 table. Drybench; stats-diagnostic-accuracy\@1.1.0; [https://www.drybench.com/methods/m/stats-diagnostic-accuracy/1.1.0](https://www.drybench.com/methods/m/stats-diagnostic-accuracy/1.1.0) (accessed \[date\]).
