# 14 - Simulate sampling for variable pool size and assumed perfect test

This program simulates sampling and prevalence estimation for a specified (design) prevalence value and level of confidence. The program runs multiple iterations of sampling, pooling and testing from an infinite population with the specified prevalence, estimates true prevalence for each iteration and calculates the mean prevalence and estimated bias across all iterations. It assumes variable pool sizes and a test with 100% sensitivity and specificity. Values for the true sensitivity and specificity that are different to the assumed values of 100% can also be entered if desired to check the importance of the assumption of a perfect test.

For this analysis, six alternative pooling strategies were evaluated for the estimation of prevalence in a population with an assumed true prevalence of 0.14 (14%). This is equivalent to the observed prevalence and precision when 162 samples from little red flying foxes in Queensland were tested individually, with 22 positive results. Pool sizes and numbers of pools were used to provide the same total sample size (210 samples) as used for the fixed pool size and perfect test example. The true sensitivity and specificity of the test were both assumed to be 1 (100%), equal to the assumed values for prevalence estimation. Input values, pooling strategies and results are summarised in the tables below.

Input Value
Method Variable pool size and perfect test
Assumed Prevalence 0.14
Assumed Sensitivity 1
Assumed Specificity 1
True Sensitivity 1
True Specificity 1
Confidence 0.95
Number of strategies 6
Number of iterations 1000
Strategy Pool size 1 Number of pools 1 Pool size 2 Number of pools 2
1 5 42 0 0
2 5 40 1 10
3 5 40 10 1
4 10 21 0 0
5 10 20 1 10
6 20 10 10 1
Strategy Mean prevalence Minimum prevalence Maximum prevalence Mean bias Mean CI width Mean standard error Mean square error Bias/AP Bias/TP Bias/MSE Proportion valid
1 0.14272 0.05293 0.28226 0.00272 0.11136 NaN NaN 0.01909 0.01946 NaN 0.945
2 0.14256 0.05826 0.27087 0.00256 0.11016 NaN NaN 0.01793 0.01826 NaN 0.935
3 0.14161 0.05986 0.25929 0.00161 0.11187 NaN NaN 0.01139 0.01153 NaN 0.97
4 0.15136 0.06262 0.92587 0.01136 0.14941 NaN NaN 0.07507 0.08116 NaN 0.935
5 0.14654 0.06912 0.32703 0.00654 0.1433 NaN NaN 0.0446 0.04669 NaN 0.949
6 0.49031 0.04148 0.89974 0.35031 0.18629 NaN NaN 0.71447 2.50225 NaN 0.49

The standard error of the estimate cannot be calculated using this method, so that and other measures derived from it (Mean square error and Bias/MSE) are listed as NaN (not a number).

Contents
1 Fixed pool size and perfect tests
2 Fixed pool size and tests with known sensitivity and specificity
3 Fixed pool size and tests with uncertain sensitivity and specificity
4 Variable pool size and perfect test
5 Pooled prevalence using a Gibbs sampler
6 Estimated true prevalence using one test (unpooled) with a Gibbs sampler
7 Estimated true prevalence using two tests (unpooled) with a Gibbs sampler
8 Sample size calculation for fixed pool size and perfect tests
9 Sample size calculation for fixed pool size and tests with known sensitivity and specificity
10 Sample size calculation for fixed pool size and tests with uncertain sensitivity and specificity
11 Simulate sampling for fixed pool size and assumed perfect test
12 Simulate sampling for fixed pool size and test with known sensitivity and specificity
13 Simulate sampling for fixed pool size and test with uncertain sensitivity and specificity
14 Simulate sampling for variable pool size and assumed perfect test
15 Demonstration of freedom using pooled testing with tests of known sensitivity and fixed pool size
16 Estimation of alpha and beta Parameters for Prior Beta distributions
17 Estimation of Beta probability distributions for specified alpha and beta parameters