← All calculators

Epidemiology & Diagnostic Tests

Sensitivity, specificity, predictive values and likelihood ratios from a 2×2 table (re-scored at any prevalence), relative risk with 95% CI, odds ratio, NNT, and incidence / prevalence / attack rates. The same math as the Excel workbook, live in your browser.

What this is for: Diagnostic-test metrics (sensitivity, specificity, predictive values, likelihood ratios), risk measures with NNT, and incidence/prevalence rates from 2×2 tables and population data.

The formula: sensitivity = TP ÷ (TP + FN); RR = risk(exposed) ÷ risk(unexposed); NNT = 1 ÷ ARR

How to use:

  1. In Diagnostic Test, fill the 2×2 table — TP, FN, FP and TN — and read sensitivity, specificity, PPV, NPV, accuracy, likelihood ratios and Youden J.
  2. Enter a new prevalence as a proportion (for example 0.02 for 2%) to see the same test's PPV and NPV at that prevalence.
  3. In Risk & NNT, enter event and no-event counts for the exposed/treated and unexposed/control rows and read RR with its 95% confidence interval, OR, ARR, RRR and the rounded-up NNT.
  4. In Rates, enter new cases, population at risk, observation years and the rate multiplier for incidence; existing cases and population for prevalence; and people ill and people exposed for attack rate.

Diagnostic Test — Sensitivity, Specificity, Predictive Values & Likelihood Ratios

Fill the 2×2 table from your validation study; every measure updates. Section B re-scores the same test at a different prevalence with Bayes' rule.

Sensitivity = TP/(TP+FN)
Specificity = TN/(TN+FP)
PPV = TP/(TP+FP) at study prevalence
NPV = TN/(TN+FN) at study prevalence
Accuracy
Prevalence in study sample
Likelihood ratio + = sens/(1−spec)
Likelihood ratio − = (1−sens)/spec
Diagnostic odds ratio
Youden's J = sens + spec − 1
PPV at new prevalence
NPV at new prevalence

Risk — Relative Risk, Odds Ratio, ARR, RRR & NNT

Rows: exposed (treated) and unexposed (control); columns: event and no event. The RR confidence interval uses the standard log method. NNT is always rounded UP.

Risk in exposed
Risk in unexposed
RELATIVE RISK (RR)
SE of ln(RR)
RR 95% CI — lower
RR 95% CI — upper
Odds ratio (OR)
Abs. risk reduction ARR (control − treated)
Relative risk reduction RRR
NNT = 1/ARR (exact)
NNT rounded UP (report this)

Rates — Incidence, Prevalence & Attack Rate

Incidence needs person-time: population × years of observation. Prevalence is a snapshot. Attack rate is outbreak language for cumulative incidence among people exposed.

years
Person-years of observation
INCIDENCE (per multiplier person-years)
Prevalence (%)
Attack rate (%)
Prefer to work offline or keep a copy? The download link is right below.
Download the Epidemiology & Diagnostic Tests workbook (.xlsx)
Notes & limits (from the workbook): Sensitivity and specificity are (mostly) properties of the test; PPV and NPV move with prevalence — at 2% prevalence this good test's positives are wrong ~60% of the time. Confidence intervals for sens/spec belong in a statistics package (binomial CIs). If ARR is negative the exposure is harmful and the same arithmetic gives NNH — check the sign of ARR first. OR approximates RR only when the outcome is rare. Person-years here assume a stable population; prevalence rises with duration even when incidence is flat — do not compare the two as if they measured the same thing.