# Estimated true prevalence using one test with a Gibbs sampler

### Introduction

This method uses a Bayesian approach and Gibbs sampling to estimate the true animal-level prevalence of infection based on testing of individual (not pooled) samples using a test with imperfect sensitivity and/or specificity. The analysis requires prior estimates of true prevalence, test sensitivity and test specificity as Beta probability distributions, and outputs posterior distributions for prevalence, sensitivity and specificity. See the User Guide or Joseph et al. (1995) for more details. See demonstration analysis.

### Input values

Required inputs for this analysis are the number of samples tested, number of samples positive and alpha and beta parameters for prior Beta distributions for true prevalence and test sensitivity and specificity. Additional inputs are the number of iterations to be simulated in the Gibbs sampler, the number of iterations to be discarded to allow convergence of the model, the lower and upper probability (confidence) limits for summarising the output distributions and starting values for the assumed number of truly infected individuals among the test-positives (true positives) and among the test-negatives (false negatives). The Gibbs sampler is then used to estimate the probability distributions of true prevalence, sensitivity and specificity that best fit the data and prior distributions provided.

### Prior distributions for Prevalence, Se and Sp

The Gibbs sampler requires prior estimates of the true prevalence and test sensitivity and
specificity, based on expert knowledge or 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 utilities*,
provided estimates of the mode and 5% or 95% confidence limits are available
from expert opinion.

If there is no prior information on which to base a prior distribution, alpha = beta = 1 should be used. This results in a uniform (uninformed) distribution, in which all values between 0 and 1 have equal probability of occurrence.

### Outputs

Outputs for this method are posterior probability distributions for prevalence, sensitivity and specificity. These distributions are described by their minimum, maximum, upper and lower probability limits specified, median, mean and standard deviation. A histogram and density chart and a text file of simulation results can also be downloaded for each parameter.

### How many iterations?

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. It is also important to carry out an adequate number of iterations to support inference from the results. suggested default values for the total number of iterations and the number to be discarded are provided, but can be varied if desired.

### Note

This analysis may take a little while to complete, depending on the number of iterations required.