2×2 Test Accuracy
Turns a 2×2 table into sensitivity, specificity, predictive values and likelihood ratios, each with a 95% confidence interval.
Enter the four counts from crossing a test against its reference standard, and get eight performance figures, each with a 95% confidence interval.
This tool describes how a test performed across a set of samples. Do not use it to decide anything about an individual patient.
The 2×2 table
Fill all four cells to get results. The margins fill themselves in.
| Test result against condition | Condition present | Condition absent | Total |
|---|---|---|---|
| Test positive | True positive (a) | False positive (c) | — |
| Test negative | False negative (b) | True negative (d) | — |
| Total | — | — | — |
Left empty, it is read off the table. Fill it in when the samples were not collected in the proportion the population has.
The figures themselves are all standard arithmetic. What differs between rows is how the confidence interval is arrived at, and the Method column says which one applied to which row rather than leaving you to look it up.
A row with an empty interval is not a fault. One of three words appears there — “no denominator” means the quantity is not defined because there was nothing to divide by, “supplied value” means the prevalence was typed in and so carries no sampling error, and “not estimable” means the figure sits at 0 or at infinity, where the log and logit scales have no room.
A cell holds up to 10,000,000. That is a limit of the routine this tool uses rather than of the exact method itself — on tables far larger than the cap its interval was found to drift without complaining, so a larger table is refused rather than answered wrongly. Within the allowed range the values were checked against an independent calculation.
- Sensitivity, specificity, prevalence and accuracy — the exact (Clopper-Pearson) interval. All four are proportions counted straight off the table, which is the situation the exact method is for.
- Positive and negative predictive value — the logit method. Its variance carries no prevalence term, which is what lets a supplied prevalence produce an interval at all. When the value reaches exactly 0% or 100% the logit becomes infinite and the exact interval on the same count takes over.
- Positive and negative likelihood ratio — the log scale, using the same two variances as the predictive values.
- With a supplied prevalence, accuracy becomes a weighted average of sensitivity and specificity. It is no longer a count out of a total, so the exact method has nothing to work on and no interval is shown.
- Why is leaving prevalence empty not the same as typing the table’s own prevalence in?
- Only two rows change: prevalence itself and accuracy. A figure counted off the table carries sampling error and gets an interval; a figure typed in is an assumption and carries none. The predictive values treat prevalence as known in both cases, so their figures and their intervals are identical.
- Which axis is which?
- Rows are the result of the test being evaluated; columns are the reference standard or confirmed diagnosis. Swapping the two axes swaps sensitivity and specificity, so it is worth checking before entering a table.
- Can the confidence level be changed to 90% or 99%?
- Only 95% for now. Every reference value this tool was checked against sits at 95%, and opening the other levels would mean shipping figures that nothing has verified.
- A likelihood ratio shows ∞.
- With no false positives the positive likelihood ratio has a denominator of zero, so the ratio is unbounded. That is a real answer, not an error: this sample sets no ceiling on it. The interval is absent for the same reason.
- How do I get this into a document?
- Each of the two tables has its own “Copy for spreadsheet” and “Copy as image”. The first puts tab-separated text on the clipboard, so a spreadsheet splits it into cells on paste; the second pastes as a picture. Either way the prevalence and its source travel with the table.