Optimization of pool size and number of tests for prevalence estimation via group testing I'm trying to devise a protocol for pooling lab tests from a cohort in order to get prevalence estimates using as few reagents as possible.
Assuming perfect sensitivity and specificity (if you want to include them in the answer is a plus), if I group testing material in pools of size $s$ and given an underneath (I don't like term "real") mean probability $p$ of the disease, the probability of the pool being positive is:
$$p_w = 1 - (1 - p)^s$$
if I run $w$ such pools the probability of having $k$ positive wells given a certain prevalence is:
$$p(k | w, p) = \binom{w}{k} (1 - (1 - p)^s)^k(1 - p)^{s(w-k)}$$ 
that is $k \sim Binom(w, 1 - (1 - p)^s)$.
To get $p$ I just need to maximize the likelihood $p(k | w, p)$ or use the formula $1 - \sqrt[s]{1 - k/w}$ (not really sure about this second one...).
My question is, how do I optimize $s$ (maximize) and $w$ (minimize) according to a prior $p$ in order have the most precise estimates, below a certain level of error?
 A: I may have found a solution:
I can estimate the uncertainty around $p$ in two ways, given $w$ and $s$.
First I get the expected results of a pooled test through:
$$E[p_w] = 1 - (1 - p)^s$$
Then, through maximum likelihood and logit transformation, I get the Confidence Intervals:
$$CI_{p_{\alpha/2}} = 1 - \sqrt[s]{1 - logit^{-1}(logit(E[p_w]) \pm Z_{\alpha/2} \frac{1}{\sqrt{w E[p_w] (1-E[p_w]))}}}$$
In alternative I can exploit the Beta distribution as a conjugate of the binomial to get the posterior Credibility Intervals of $p$ for the given quantiles $q$:
$$CrI_{p_{\alpha/2}} = 1 - \sqrt[s]{1 - Beta(q, 1 + w E[p_w], 1 + w (1 - E[p_w])}$$
this second solution even allows the specification of priors.
I was afraid that these solution would underestimate variability, since they evaluate the variance at the test level (on $p_w$), not at the level of the underneath prevalence $p$. But comparing the results with a full MCMC hierarchical estimation of $p$ posterior with a model:
$$p \sim Beta(\alpha,\beta)$$
$$p_w \sim 1 - Binom(0, s, p)$$
$$p(k | w, p_w) \sim Binom(k, w, p_w)$$
it can be shown that there is no relevant difference with the intervals of the other two methods (which are of course faster to compute).
Finally, I search numerically the maximal value of $s$ and minimal of $w$ that keep the uncertainty below a specified threshold. I'm postulating that as the uncertainty goes down so will the estimation bias due to the loss of information in the pooling. I still haven't found an analytical way to get this error directly.
