# 8 - Pooled prevalence using a Gibbs sampler

This method uses a Bayesian approach and a Gibbs sampler iterative model to estimate the posterior distribution of the true animal-level prevalence of infection for a given pool size, number of pools tested, number of pools positive and estimated test sensitivity and specificity. See Cowling et al. (1999) (Method 7) or Mendoza-Blanco et al. (1996) for more details.

Required inputs for this method are:

Pool size, number of pools and number of pools positive must be positive integers and the number of positive pools must be less than the number of pools tested. Alpha and beta parameters for prevalence, sensitivity and specificity must be >0 and upper and lower confidence limits must be >0 and <1. The number of iterations and the number discarded must both be positive integers (>0) and the number discarded must be less than the number of iterations.

The Gibbs sampler is used to estimate the posterior probability distributions of true prevalence, sensitivity and specificity that best fit the data and the prior distributions provided.

Prior estimates of the true prevalence and test sensitivity and specificity may be based on expert knowledge or on previous data. These estimates are specified as Beta probability distributions, with parameters alpha and beta. Beta probability distributions are commonly used to express uncertainty about a proportion based on a random sample of individuals. In this situation, if x individuals are positive for a characteristic out of n examined, then the alpha and beta parameters can be calculated as alpha = x + 1 and beta = n - x + 1. Alternatively, alpha and beta can be calculated using the Beta distribution utility, provided estimates of the mode and 5% or 95% confidence limits are available from expert opinion.

Outputs from the Gibbs sampler are posterior probability distributions for animal-level prevalence, test sensitivity and test specificity, described by their:

Because the Gibbs sampler estimates prevalence iteratively, based on the data and the prior distributions, it may take a number of iterations for the model to converge on the true value. Therefore, a specified number of initial iterations must be discarded (not used for estimation) to allow the model to converge on the true values. This number must be sufficient to allow convergence, and should be at least 2000 - 5000. It is also important to carry out an adequate number of iterations to support inference from the results. Suggested minimum values for the total number of iterations and the number to be discarded are provided, but can be varied if desired.

This analysis may take several minutes to complete, depending on the number of iterations required.

Contents
1 Introduction
2 Overview
3 Bayesian vs Frequentist methods
4 Fixed pool size and perfect tests
5 Fixed pool size and known Se & Sp
6 Fixed pool size and uncertain Se & Sp
7 Variable pool size and perfect tests
8 Pooled prevalence using a Gibbs sampler
9 True prevalence using one test
10 Estimated true prevalence using two tests with a Gibbs sampler
11 Estimation of parameters for prior Beta distributions
12 Sample size for fixed pool size and perfect test
13 Sample size for fixed pool size and known test sensitivity and specificity
14 Sample size for fixed pool size and uncertain test sensitivity and specificity
15 Simulate sampling for fixed pool size
16 Simulate sampling for variable pool sizes
17 Important Assumptions
18 Pooled prevalence estimates are biased!