Sensitivity, specificity and predictive values from a diagnostic two-by-two table

Sensitivity and specificity are proportions of the people with and without the target condition who receive the correct index test result, so they are conditional on disease status (the columns of the table). The predictive values are proportions of the positive and negative results that are correct, so they are conditional on the test result (the rows) and carry the prevalence of the study sample. Likelihood ratios are HE-FM-DXA-002 and predictive values at another prevalence HE-FM-DXA-003.

Signature

Se = TP / (TP + FN); Sp = TN / (TN + FP); PPV = TP / (TP + FP); NPV = TN / (TN + FN)
Inputs
InputsDefinitionUnit
TPPeople with the target condition on the reference standard whom the index test calls positivecount
FNPeople with the target condition whom the index test calls negativecount
TNPeople without the target condition whom the index test calls negativecount
FPPeople without the target condition whom the index test calls positivecount
Output
SeProportion of people with the target condition whom the index test calls positive, P(T+ given D+)proportion
SpProportion of people without the target condition whom the index test calls negative, P(T minus given D minus)proportion
PPVProportion of positive index test results that belong to people with the target condition, at the study's prevalenceproportion
NPVProportion of negative index test results that belong to people without the target condition, at the study's prevalenceproportion

Function

Diagnostic test accuracy measures and the expected value of test results

Maps the cross-classification of index test results against a reference standard to the measures of accuracy, conditional on disease status (sensitivity, specificity) or on the test result (predictive values), and combines accuracy with prevalence and the consequences of true and false results into the expected net monetary benefit of testing. The notation follows the Diagnostic Accuracy article and its two triage tests.

Try this function

Implementations

  • Excel

    Sensitivity, specificity and predictive values from named counts

    With the four counts named TruePos, FalseNeg, TrueNeg and FalsePos, the formulas return sensitivity, specificity and the two predictive values, held in Sens, Spec, PosPredValue and NegPredValue.

    =TruePos/(TruePos+FalseNeg); =TrueNeg/(TrueNeg+FalsePos); =TruePos/(TruePos+FalsePos); =TrueNeg/(TrueNeg+FalseNeg)

Assumptions

  • Reference standard taken as correct in the accuracy table

    Each person's true status is the reference standard result, so the measures describe agreement with that standard; when the standard is imperfect the estimates can differ from true accuracy.

  • One threshold and one population behind the four cells

    All four counts come from the same people tested at the same positivity threshold; moving the threshold raises one of sensitivity and specificity and lowers the other.

  • Predictive values tied to the study sample's prevalence

    PPV and NPV read from the table carry the sample prevalence, (TP + FN) over all four counts; they apply elsewhere only if the prevalence is the same, otherwise HE-FM-DXA-003 recomputes them.

Worked examples

  • Triage test A in 1,000 people at 5 per cent prevalence

    Of 50 people with the condition, 48 test positive; of 950 without it, 722 test negative. Sensitivity is 0.96 and specificity 0.76; only 48 of the 276 positive results are cases, a PPV of about 0.1739, and 722 of the 724 negative results are correct, an NPV of about 0.9972, as in the article.

    TP = 48; FN = 2; TN = 722; FP = 228; Se = 0.96; Sp = 0.76; PPV = 0.1739; NPV = 0.9972
  • Triage test B in 1,000 people at 5 per cent prevalence

    Test B finds 40 of the 50 cases and clears 912 of the 950 non-cases: sensitivity 0.80, specificity 0.96, PPV 40 of 78 or about 0.5128, NPV 912 of 922 or about 0.9892, as in the article.

    TP = 40; FN = 10; TN = 912; FP = 38; Se = 0.8; Sp = 0.96; PPV = 0.5128; NPV = 0.9892

Common errors

  • Reading sensitivity as the chance that a positive result is a case

    Test A detects 96 per cent of cases, but at 5 per cent prevalence only about 17 per cent of its positive results are cases; using 0.96 as the probability of disease after a positive result overstates confirmed cases more than fivefold.

  • Pooling predictive values across studies

    Predictive values depend on prevalence, so the Cochrane Handbook does not recommend pooling them across studies: between-study differences in prevalence add heterogeneity, and the pooled value refers to an average but unknown prevalence.

  • Treating sensitivity and specificity as fixed test properties

    STARD 2015 states that they are not fixed test properties: the relative numbers of false positive and false negative results vary with how patients present and which tests they have already had, so model inputs should come from the population and pathway position modelled.

Sources

  • Two-by-two table measures in the Cochrane Handbook for diagnostic test accuracy reviews

    Macaskill P, Gatsonis C, Deeks JJ, Harbord RM, Takwoingi Y. Chapter 10: Analysing and presenting results. In: Deeks JJ, Bossuyt PM, Gatsonis C, editors. Cochrane Handbook for Systematic Reviews of Diagnostic Test Accuracy. Version 1.0. The Cochrane Collaboration; 2010. Section 10.2.3: sensitivity estimated as a/(a+c) and specificity as d/(b+d), measures conditional on disease status; positive and negative predictive values estimated as a/(a+b) and d/(c+d), conditional on the index test result; section 10.4.2: pooling of predictive values is not recommended because they depend on prevalence, which is likely to vary between studies.

    View source →

  • STARD 2015 on sensitivity and specificity as setting-dependent

    Bossuyt PM, Reitsma JB, Bruns DE, Gatsonis CA, Glasziou PP, Irwig L, et al; STARD Group. STARD 2015. BMJ. 2015;351:h5527. doi:10.1136/bmj.h5527. Introduction: sensitivity and specificity are not fixed test properties; the relative number of false positive and false negative test results varies across settings, depending on how patients present and which tests they have already undergone. Table 1, item 23 asks for the cross tabulation of index test results by reference standard results.

    View source →

  • Imperfect reference standard in the NICE diagnostics assessment manual

    National Institute for Health and Clinical Excellence. Diagnostics Assessment Programme manual. Manchester: NICE; December 2011 (since replaced by the NICE HealthTech programme manual, PMG48, 2025). Section 14.2.1: whether a test result is correct is normally based on the results of a reference standard, but it is often not known for certain because of an imperfect reference standard.

    View source →

Canonical Identity