# Stochastic analysis of 2-stage freedom survey data

Stochastic analysis of cluster-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 clusters (or all clusters) has been selected for testing from the population and that a random sample of units (or all units) has been tested within each selected cluster. 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 cluster and system (population) 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 unit and cluster levels. Design prevalence can be specified as either:

- - a proportion of the population infected; or
- - a specific (integer) number of clusters or units (within clusters) infected.

### Inputs

Inputs required include:

- - unit-level design prevalence as either a proportion or an integer number of units;
- - cluster-level design prevalence as either a proportion or an integer number of clusters;
- - the number of clusters in the population as either unknown, all clusters tested or a specified number of clusters;
- - 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 cluster, including cluster id (optional), number tested and (optionally) cluster size;
- - cluster size is required if design prevalence is specified as number rather than proportion of units; 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

Outputs from the analysis include:

- - Summary of the output distribution for system sensitivity (probability of detecting disease if it was present at the specified unit and cluster-level design prevalences);
- - Summary of the output distribution for probability of freedom of the population from disease (at the specified unit and cluster-level design prevalences;
- - A summary of cluster-level sensitivity (SeH) values and specific values for each cluster tested; and
- - Detailed simulation results saved as excel files for downloading.