A test’s sensitivity and specificity
Type the four counts from a test checked against a reference standard. The calculator gives sensitivity, specificity, the positive and negative predictive values, accuracy, and the likelihood ratios, and can rework the predictive values for the prevalence in your own population.
- Sensitivity
- 89.53%
Sensitivity is 89.53% and specificity is 62.79%.
- Specificity
- 62.79%
- Positive predictive value
- 87.83%
- Negative predictive value
- 66.67%
- Accuracy
- 82.85%
- Prevalence in the table
- 75%
- Positive likelihood ratio
- 2.406
- Negative likelihood ratio
- 0.167
Sensitivity: 89.53%. Sensitivity is 89.53% and specificity is 62.79%.
How to calculate
Computes a test’s sensitivity, specificity, positive and negative predictive values, accuracy and likelihood ratios from true and false positives and negatives.
Example with the default inputs (True positives 231, False positives 32, False negatives 27, True negatives 54): Sensitivity is 89.53% and specificity is 62.79%.
Method: Sensitivity = TP ÷ (TP + FN); specificity = TN ÷ (TN + FP); PPV = TP ÷ (TP + FP); NPV = TN ÷ (TN + FN); LR+ = sensitivity ÷ (1 − specificity); LR− = (1 − sensitivity) ÷ specificity; at prevalence p, PPV = sens × p ÷ [sens × p + (1 − spec)(1 − p)].
- The reference standard decides who has the condition; the counts come from one group of people tested.
- Values that would divide by zero are not shown (for example LR+ when there are no false positives).
Worked examples
Each example is checked against the calculator on every build.
- True positives 231, False positives 32, False negatives 27, True negatives 54 gives Sensitivity 89.534884%, Specificity 62.790698%, Positive predictive value 87.8327%, Negative predictive value 66.666667%, Accuracy 82.848837%, Prevalence in the table 75%.Source: https://www.bmj.com/content/308/6943/1552
- True positives 42, False positives 2, False negatives 106, True negatives 142, Prevalence in your population 10% gives Sensitivity 28.378378%, Specificity 98.611111%, Positive likelihood ratio 20.432432, Negative likelihood ratio 0.726304, Positive predictive value at your prevalence 69.421488%.Source: https://pmc.ncbi.nlm.nih.gov/articles/PMC478236/
- True positives 90, False positives 0, False negatives 10, True negatives 100 gives Sensitivity 90%, Specificity 100%, Positive predictive value 100%, Negative predictive value 90.909091%, Negative likelihood ratio 0.1.Source: https://www.bmj.com/content/308/6943/1552
How it works
The four counts come from one group of people who had the test and a reference standard (the best available way to tell who has the condition):
| Has the condition | Does not have it | |
|---|---|---|
| Test positive | TP (true positives) | FP (false positives) |
| Test negative | FN (false negatives) | TN (true negatives) |
- Sensitivity = TP ÷ (TP + FN).
- Specificity = TN ÷ (TN + FP).
- Positive predictive value (PPV) = TP ÷ (TP + FP).
- Negative predictive value (NPV) = TN ÷ (TN + FN).
- Accuracy = (TP + TN) ÷ (TP + FP + FN + TN).
- Prevalence in the table = (TP + FN) ÷ (TP + FP + FN + TN).
- Positive likelihood ratio (LR+) = sensitivity ÷ (1 − specificity). Negative likelihood ratio (LR−) = (1 − sensitivity) ÷ specificity.
- Predictive values at your prevalence p (optional, typed as a percent, more than 0 and less than 100), by Bayes' theorem: PPV = sens × p ÷ [sens × p + (1 − spec) × (1 − p)], and NPV = spec × (1 − p) ÷ [spec × (1 − p) + (1 − sens) × p].
Rules. Each count is a whole number, 0 or more. There must be at least one person with the condition (TP + FN > 0) and one without it (TN + FP > 0); otherwise there is no answer. A value whose denominator is 0 is not shown: PPV when TP + FP = 0, NPV when TN + FN = 0, LR+ when FP = 0, LR− when TN = 0, and a predictive value at your prevalence when its own denominator is 0.
Rounding. Every value is an exact fraction of the counts (and the typed prevalence), rounded once for display: shares to 2 decimals of a percent, likelihood ratios to 3 decimals.
Worked examples by hand
Liver scan (page default). TP = 231, FP = 32, FN = 27, TN = 54, 344 patients. Sensitivity = 231 ÷ 258 = 89.53%. Specificity = 54 ÷ 86 = 62.79%. PPV = 231 ÷ 263 = 87.83%. NPV = 54 ÷ 81 = 66.67%. Accuracy = 285 ÷ 344 = 82.85%. Prevalence = 258 ÷ 344 = 75.00%. LR+ = 0.895349 ÷ 0.372093 = 2.406; LR− = 0.104651 ÷ 0.627907 = 0.167.
Smoking and airway disease, prevalence 10%. TP = 42, FP = 2, FN = 106, TN = 142. Sensitivity = 42 ÷ 148 = 28.38%. Specificity = 142 ÷ 144 = 98.61%. LR+ = 0.283784 ÷ 0.013889 = 20.432. LR− = 0.716216 ÷ 0.986111 = 0.726. PPV at 10%: 0.283784 × 0.1 = 0.0283784; 0.013889 × 0.9 = 0.0125; 0.0283784 ÷ 0.0408784 = 69.42%. Deeks and Altman give a post-test probability of about 0.69.
No false positives. TP = 90, FP = 0, FN = 10, TN = 100. Sensitivity = 90.00%, specificity = 100.00%, PPV = 90 ÷ 90 = 100.00%, NPV = 100 ÷ 110 = 90.91%, LR− = 0.1 ÷ 1 = 0.100. LR+ would divide by 0, so it is not shown.
Other questions people ask
How do I calculate sensitivity?
Divide the true positives by everyone who has the condition: TP ÷ (TP + FN). In the liver scan study, 231 of the 258 patients with abnormal pathology had an abnormal scan: 231 ÷ 258 = 89.5%.
How do I calculate specificity?
Divide the true negatives by everyone who does not have the condition: TN ÷ (TN + FP). In the same study, 54 of 86 patients with normal pathology had a normal scan: 54 ÷ 86 = 62.8%.
What is the difference between sensitivity and positive predictive value?
Sensitivity starts from the people who have the condition and asks how many test positive. The positive predictive value starts from the people who test positive and asks how many have the condition: TP ÷ (TP + FP).
Why do predictive values change with prevalence?
When a condition is rare, most people tested do not have it, so even a few false positives can outnumber the true positives. Sensitivity and specificity stay the same, but the PPV falls. Type a prevalence to see the PPV and NPV for your population.
What is a likelihood ratio?
The positive likelihood ratio is sensitivity ÷ (1 − specificity): how much more often a positive result occurs in people with the condition than in people without it. The negative likelihood ratio is (1 − sensitivity) ÷ specificity.
Why is a value missing?
A value that would divide by zero is not shown. With no false positives, specificity is 100% and the positive likelihood ratio is infinite. With no positive tests at all, there is no positive predictive value.