Stochastic analysis of 2-stage freedom survey data

Input Values


Stochastic analysis of herd-testing data for 2-stage surveys for demonstrating disease freedom. This analysis calculates the overall system sensitivity for the survey and the resulting probability of population freedom from disease, allowing for uncertainty about test sensitivity and/or prior probability of freedom. It assumes that a random sample of herds (or all herds) has been selected for testing from the population and that a random sample of animals (or all animals) has been tested within each selected herd. It also assumes that the test system has a specificity of 100% (any positive results are further investigated to exclude false positives) and that no positive results were recorded. The analysis adjusts for imperfect sensitivity of the test used.

The analysis calculates both herd and system level sensitivity estimates using three different methods depending on the available data:

  • assumed binomial sampling (sampling with replacement) where population size is unknown or not specified;
  • a hypergeometric distribution (sampling without replacement) where population size is specified; or
  • exact probability calculations where the entire population has been sampled.

Design prevalence (specified level of disease to be detected) must be specified at both animal and herd levels. Design prevalence can be specified as either:

  • a proportion of the population infected; or
  • a specific (integer) number of herds or animals (within herds) infected.


Inputs required include:

  • animal-level design prevalence and whether this is specified as a proportion or number of animals;
  • herd-level design prevalence and whether this is specified as a proportion or number of herds;
  • the number of herds in the population as either unknown, all herds tested or a specified number of herds;
  • the estimated test sensitivity, input as alpha and beta parameters for a Beta probability distribution;
  • the assumed prior probability that the population is free of disease;
  • testing data for each herd, including herd id (optional), number tested and (optionally) herd size;
  • Herd size is required if design prevalence is specified as number rather than proportion of animals; and
  • the number of iterations to be run for the simulation.
The prior probability of freedom can be entered as one of:
  • a fixed value - enter the required value as Parameter 1 (must be between 0 and 1); or
  • a beta distribution - enter alpha and beta parameters as Parameters 1 and 2 respectively (both values must be >0); or
  • a pert distribution - enter minimum, most likely and maximum values as Parameters 1, 2 and 3 respectively (all values must be between 0 and 1 and P1 < P2 < P3).


Outputs from the analysis include:

  • Summary of the output distribution for system sensitivity (probability of detecting disease if it was present at the specified animal and herd-level design prevalences);
  • Summary of the output distribution for probability of freedom of the population from disease (at the specified animal and herd-level design prevalences;
  • A summary of herd-level sensitivity (SeH) values and specific values for each herd tested; and
  • Detailed simulation results saved as excel files for downloading.
Animal-level design prevalence:
Herd-level design prevalence:
Number of herds in population?
Unknown/Not specified
All herds tested
Specified below
Test sensitivity (parameters for Beta distribution):
Prior probability of freedom:
Distribution type:
Parameter 1:
Parameter 2:
Parameter 3:
Number of iterations:


This analysis may take several minutes for large population sizes. If you enter your email address below an email will be sent to you with a link to the results.

Paste herd testing data in the space below. Data columns can be in any order but must include a column for number tested (labeled "Tested"). Columns for herd id, and herd size (labeled "HerdSize") are optional. A header row specifying column names must also be included.
Download example data


  Home  |   About this site  |   Glossary   |   References   |   Links   |  113 recent calculations

This site was created by Ausvet with funding from a range of sources.
It provides a range of epidemiological tools for the use of researchers and epidemiologists, particularly in animal health.
Please send any comments, questions or suggestions to Evan Sergeant
© 2017 Ausvet