epi.prev: Estimate true prevalence based on test data and the expected...

epi.prevR Documentation

Estimate true prevalence based on test data and the expected number of false positive and false negative test results

Description

Compute the true prevalence of a disease and the estimated number of false positive and false negative test results on the basis of an imperfect test. True prevalence can be estimated using either the Rogan Gladen correction or a simplified Bayesian approach.

Usage

epi.prev(pos, tested, se, sp, method = "wilson", tp.method = "rogan.gladen",
   bayes.variant = NULL, units = 100, conf.level = 0.95)

Arguments

pos

a vector listing the count of positive test results for each population.

tested

a vector listing the count of subjects tested for each population.

se

test sensitivity (0 - 1). se can either be a single number or a vector of the same length as pos. See the examples, below, for details.

sp

test specificity (0 - 1). sp can either be a single number or a vector of the same length as pos. See the examples, below, for details.

method

a character string indicating the confidence interval calculation method to use. Options are "c-p" (Clopper-Pearson), "sterne" (Sterne), "blaker" (Blaker) and "wilson" (Wilson; default).

tp.method

a character string indicating the method used to estimate true prevalence. Options are "rogan.gladen" (Rogan Gladen correction; default) and "simplified.bayes" (simplified Bayesian approach).

bayes.variant

a character string indicating the variant of the simplified Bayesian estimator, used only when tp.method = "simplified.bayes". Options are "mode.hpd" (using the posterior mode as the point estimate and highest posterior density credible intervals) and "median.equaltail" (using the posterior median as the point estimate and equal tail credible intervals). If NULL, "mode.hpd" is used. Ignored when tp.method = "rogan.gladen".

units

multiplier for the prevalence estimates.

conf.level

magnitude of the returned confidence interval. Must be a single number between 0 and 1.

Details

Appropriate confidence intervals for the adjusted prevalence estimate are provided, accounting for the change in variance that arises from imperfect test sensitivity and specificity (see Reiczigel et al. 2010 for details).

The Clopper-Pearson method is known to be too conservative for two-sided intervals (Blaker 2000, Agresti and Coull 1998). Blaker's and Sterne's methods (Blaker 2000, Sterne 1954) provide smaller exact two-sided confidence interval estimates.

When tp.method = "simplified.bayes", true prevalence is estimated using a simplified Bayesian approach (Kopacka and Fuchs 2026) that accounts for uncertainty in test sensitivity and specificity. Credible intervals are derived from the posterior distribution, using either equal-tailed intervals (posterior median) or highest posterior density (HPD) intervals (posterior mode), depending on bayes.variant. Apparent prevalence and its confidence interval are unaffected and continue to be computed using the method specified by method.

Value

A list containing the following:

ap

the point estimate of apparent prevalence and the lower and upper bounds of the confidence interval around the apparent prevalence estimate.

tp

the point estimate of the true prevalence and the lower and upper bounds of the confidence interval around the true prevalence estimate. For the simplified Bayesian method, intervals reported for true prevalence are Bayesian credible intervals rather than frequentist confidence intervals.

test.positive

the point estimate of the expected number of positive test results and the lower and upper quantiles of the estimated number of positive test results computed using conf.level.

true.positive

the point estimate of the expected number of true positive test results and the lower and upper quantiles of the estimated number of true positive test results computed using conf.level.

false.positive

the point estimate of the expected number of false positive test results and the lower and upper quantiles of the estimated number of false positive test results computed using conf.level.

test.negative

the point estimate of the expected number of negative test results and the lower and upper quantiles of the estimated number of negative test results computed using conf.level.

true.negative

the point estimate of the expected number of true negative test results and the lower and upper quantiles of the estimated number of true negative test results computed using conf.level.

false.negative

the point estimate of the expected number of false negative test results and the lower and upper quantiles of the estimated number of false negative test results computed using conf.level.

Note

This function uses apparent prevalence, test sensitivity and test specificity to estimate true prevalence (after Rogan and Gladen, 1978). Confidence intervals for the apparent and true prevalence estimates are based on code provided by Reiczigel et al. (2010).

If apparent prevalence is less than (1 - diagnostic test specificity) the Rogan Gladen estimate of true prevalence will be less than zero (Speybroeck et al. 2012). If the apparent prevalence is greater than the diagnostic test sensitivity the Rogan Gladen estimate of true prevalence will be greater than one.

When AP < (1 - Sp) the function issues a warning to alert the user that the estimate of true prevalence is invalid. A similar warning is issued when AP > Se. In both situations the estimated number of true positives, false positives, true negatives and false negatives is not returned by the function. Where AP < (1 - Sp) or AP > Se a Bayesian approach for estimation of true prevalence is recommended. See Messam et al. (2008) for a concise introduction to this topic.

Author(s)

Code and documentation for the simplified Bayesian method for this function has been generously provided by Ian Kopacka and Klemens Fuchs, AGES - Osterreichische Agentur fur Gesundheit und Ernahrungssicherheit GmbH, Spargelfeldstrasse 191, 1220 Wien.

References

Abel U (1993). Die Bewertung Diagnostischer Tests. Hippokrates, Stuttgart.

Agresti A, Coull BA (1998). Approximate is better than 'exact' for interval estimation of binomial proportions. American Statistician 52: 119 - 126.

Blaker H (2000). Confidence curves and improved exact confidence intervals for discrete distributions. Canadian Journal of Statistics 28: 783 - 798.

Clopper CJ, Pearson ES (1934). The use of confidence of fiducial limits illustrated in the case of the binomial. Biometrika 26: 404 - 413.

Gardener IA, Greiner M (1999). Advanced Methods for Test Validation and Interpretation in Veterinary Medicince. Freie Universitat Berlin, ISBN 3-929619-22-9; 80 pp.

Kopacka I, Fuchs K (2026). Overcoming limitations of the Rogan-Gladen correction: A closed-form solution to a simplified Bayesian method for true prevalence estimation. Preventive Veterinary Medicine 253: DOI: 10.1016/j.prevetmed.2026.106891.

Messam L, Branscum A, Collins M, Gardner I (2008) Frequentist and Bayesian approaches to prevalence estimation using examples from Johne's disease. Animal Health Research Reviews 9: 1 - 23.

Reiczigel J, Foldi J, Ozsvari L (2010). Exact confidence limits for prevalence of disease with an imperfect diagnostic test. Epidemiology and Infection 138: 1674 - 1678.

Rogan W, Gladen B (1978). Estimating prevalence from results of a screening test. American Journal of Epidemiology 107: 71 - 76.

Speybroeck N, Devleesschauwer B, Joseph L, Berkvens D (2012). Misclassification errors in prevalence estimation: Bayesian handling with care. International Journal of Public Health DOI:10.1007/s00038-012-0439-9.

Sterne TE (1954). Some remarks on confidence or fiducial limits. Biometrika 41: 275 - 278.

Examples

## EXAMPLE 1:
## A simple random sample of 150 cows from a herd of 2560 is taken.
## Each cow is given a screening test for brucellosis which has a 
## sensitivity of 96% and a specificity of 89%. Of the 150 cows tested
## 45 were positive to the screening test. What is the estimated prevalence 
## of brucellosis in this herd (and its 95% confidence interval)?

epi.prev(pos = 45, tested = 150, se = 0.96, sp = 0.89, method = "blaker",
   units = 100, conf.level = 0.95)

## The estimated true prevalence of brucellosis in this herd is 22 (95% 14 
## to 32) cases per 100 cows at risk. Using this screening test we can expect
## anywhere between 34 and 56 positive test results. Of the positive tests
## between 23 and 42 are expected to be true positives and between 7 and 20 are
## expected to be false positives.


# EXAMPLE 2:
## Moujaber et al. (2008) analysed the seroepidemiology of Helicobacter pylori 
## infection in Australia. They reported seroprevalence rates together with 
## 95% confidence intervals by age group using the Clopper-Pearson exact 
## method (Clopper and Pearson, 1934). The ELISA test they applied had 96.4% 
## sensitivity and 92.7% specificity. A total of 151 subjects 1 -- 4 years
## of age were tested. Of this group 6 were positive. What is the estimated 
## true prevalence of Helicobacter pylori in this age group?

epi.prev(pos = 6, tested = 151, se = 0.964, sp = 0.927, method = "c-p",
   units = 100, conf.level = 0.95)

## The estimated true prevalence of Helicobacter pylori in 1 -- 4 year olds is
## -4 (95% CI -6 to 1) cases per 100. The function issues a warning to alert 
## the user that estimate of true prevalence invalid. True positive, false
## positive, true negative and false negative counts are not returned. Switch
## tp.method to "simplified.bayes":

epi.prev(pos = 6, tested = 151, se = 0.964, sp = 0.927, method = "c-p",
   tp.method = "simplified.bayes", bayes.variant = "mode.hpd",
   units = 100, conf.level = 0.95)

## The simplified Bayes method allows a valid estimation of true prevalence. 
## The estimated true prevalence is 0 (95% CI 0 to 3) cases per 100. 


## EXAMPLE 3:
## Three dairy herds are tested for tuberculosis. On each herd a different test
## regime is used (each with a different diagnostic test sensitivity and 
## specificity). The number of animals tested in each herd were 210, 189 and 
## 124, respectively. The number of test-positives in each herd were 8, 12 
## and 7. Test sensitivities were 0.60, 0.65 and 0.70 (respectively). Test 
## specificities were 0.90, 0.95 and 0.99. What is the estimated true 
## prevalence of tuberculosis in each of the three herds?

rval.prev03 <- epi.prev(pos = c(80,100,50), tested = c(210,189,124), 
   se = c(0.60,0.65,0.70), sp = c(0.90,0.95,0.99), method = "blaker", 
   units = 100, conf.level = 0.95)
round(rval.prev03$tp, digits = 0)

## True prevalence estimates for each herd:
## Herd 1: 56 (95% CI 43 to 70) cases per 100 cows.
## Herd 2: 80 (95% CI 68 to 92) cases per 100 cows.
## Herd 3: 57 (95% CI 45 to 70) cases per 100 cows.


epiR documentation built on Aug. 3, 2026, 5:06 p.m.