BiostatKit Tiếng Việt

BiostatKit / Diagnostic tests / Sensitivity and specificity

Sensitivity and Specificity Calculator

Enter the 2x2 table of an index test against a reference standard and get sensitivity, specificity, predictive values and likelihood ratios with 95% confidence intervals, plus a sentence for your manuscript.

Your data never leaves your browser. No sign-up, no ads.

Your diagnostic 2x2 table

Counts of people, not percentages. Rows are the test result, columns the reference standard.

Condition
present
Condition
absent
Total
Test positiveindex test
105
Test negativeindex test
95
Total
100
100
200
PPV and NPV depend on how common the condition is. Leave empty to use the prevalence in your sample.

Result

Diagnostic accuracy of the index test.

Sentence for your manuscript

Written in AMA style from your numbers. Check it against your own study design before you submit.

Reporting checklist

  • STARD 2015 (diagnostic accuracy studies): give the cross tabulation of the index test against the reference standard (item 23) and estimates of diagnostic accuracy with their precision, such as 95% CIs (item 24).
  • Also report how the participants were selected and whether the reference standard was applied to everyone; both change how far the numbers can be trusted.

Methods wording. Sensitivity, specificity, predictive values and accuracy are reported with 95% CIs by the Wilson score method; likelihood ratios with 95% CIs on the log scale (BiostatKit) [1].
[1] BiostatKit. Sensitivity and specificity calculator. Accessed [date]. [URL]

Reproduce it in R

The script is filled in with your numbers. Paste it into R or RStudio and compare.

R 4.x · base R only

    

This calculator was checked against SciPy and statsmodels on 2 reference cases and matched to 4 significant digits. See the verification log.

How to read sensitivity and specificity

What they are

Sensitivity is the share of people with the condition whom the test detects. Specificity is the share of people without it whom the test clears. Predictive values answer the patient's question: given a positive (or negative) result, how likely is the condition?

How this page computes it

Sens = TP/(TP+FN)   Spec = TN/(FP+TN)   PPV = TP/(TP+FP)   NPV = TN/(FN+TN)

LR+ = Sens/(1 - Spec)   LR- = (1 - Sens)/Spec. The CIs of the proportions use the Wilson score method. The CIs of the likelihood ratios use the log method: SE(ln LR+) = sqrt(1/TP - 1/(TP+FN) + 1/FP - 1/(FP+TN)).

With a different prevalence pv: PPV = Sens x pv / (Sens x pv + (1 - Spec)(1 - pv)).

Assumptions

  • Everyone received both the index test and the same reference standard.
  • Participants resemble the people in whom the test will be used (spectrum). A sample of clear cases and clear non-cases overstates accuracy.
  • Independent participants, one result per person.

Common mistakes

  • Carrying PPV and NPV to a setting with a different prevalence. Sensitivity and specificity transfer better; predictive values do not.
  • Reporting accuracy alone. With a rare condition, a test that calls everyone negative has high accuracy.
  • Choosing the cut-off and reporting accuracy on the same data without saying so.
  • Swapping rows and columns. Rows here are the test result, columns the reference standard.

Frequently asked questions

Which confidence interval does this use for sensitivity and specificity?

The Wilson score interval. Some programs use the exact Clopper-Pearson interval, which is slightly wider. Both are acceptable; say which one you used.

How do I read a likelihood ratio?

LR+ above 10 and LR- below 0.1 are usually considered strong evidence to rule a condition in or out. They do not depend on prevalence; multiply the pre-test odds by the LR to get post-test odds.

Why do PPV and NPV change with prevalence?

A positive result is more likely to be a true positive when the condition is common. Enter another prevalence in the optional box to see PPV and NPV for another setting.

What happens with a zero cell?

Likelihood ratios become 0 or infinite. This tool adds 0.5 to every cell for the likelihood ratios and says so; report that choice.

Related calculators: ROC curve and AUC · Relative risk calculator · Odds ratio calculator