Skip to content
Prev 115 / 585 Next

need help in calculating confidence intervals forsensitivity, specificity, PPV & NPV

I am not a physician, but most of the people who ask me for confidence
intervals on sensitivity and specificity are.

My prefered approach (not the only one), is to use the Bayesian interval
using a uniform prior (beta(1,1) distribution) with the binomial (it is
easier to do than it looks).

Basically find the HPD interval from a beta distribution with parameters
s+1 and f+1, where s and f are successes (correct test results) and
failures (incorrect test results).

I use the hpd function from the TeachingDemos package, but there are
others as well (I'm a bit biased towards that package).

For example, to calculate the 95% confidence interval for sensitivity
when you have 95 true positives and 5 false negatives you would just
type (after installing and loading the package):
And the 2 numbers are limits of a 95% confidence interval.

I like this approach because it still gives sensible results when you
have no false negatives (or false positives for specificity).

Hope this helps,