I came across this page about choosing a conjugate prior for a hypergeometric distribution. I noticed that one of the answers described a beta-binomial as the posterior distribution posterior distribution for the difference in 'successes' in the population $M$ and the sample $x$ as
$$M-x | x, \alpha, \beta \sim BB\left(N-n, \alpha+x,\beta+n-x\right)$$
I have used the beta-binomial frequently either as a posterior for the binomial with a beta prior, or by setting its parameters appropriately, I get either a hypergeometric or negative hypergeometric. I find it convenient to have multiple ways of using the same distribution function, so when I saw this post, I thought that this would be a relatively simple way to learn a new use for this distribution, but I have had a little trouble.
I wanted to try an perform a sample size and power calculation for what I assumed, from reading this post, would be a way to determine a sample size for concluding the value of $M$ from $M-x.$ For sake of example, I chose a population of size $N=100$, I set $M=30$ under the null with a one-sided, less-than test, I decided the alternative I'd like to detect with at least $80\%$ power would be $M=20.$
Normally, I would begin in R with qbbinom
but that is not an available option for the beta-binomial in the extraDistn
library, so I decided to compute a range of possibilities using pbbinom
. I set $N=100$ fixed and generated all combinations of values for $M\in\{0,1,...N\}$, for sample size $n \in \{1,2,...N\}$ and observed successes $x\in\{0,1,...,M\}$.
I thought the values of $\alpha$ and $\beta$ to reflect my null. Since $M=30$ in a population of size $N=100$, I set the $\alpha$ parameter to $0.3 \cdot n$ and the $\beta$ parameter to $0.7 \cdot n$ with pbbinom(M-x, N-n, alpha = 1+0.3*n, beta = 1+0.7*n)
. The values $M-x$ are the number of successes still in the population after drawing my sample and $N-n$ is the number of observations still in the population after drawing my sample. The significance level seems rather off; I compared results to the hypergeometric and beta for a similar hypothesis test. I did try a calculation for power just to reinforce that I had made an error, pbbinom(M-x, N-n, alpha = 1+0.2*n, beta = 1+0.8*n)
and the power is surprisingly low, never exceeding 0.5.
I'm thinking about this problem in the wrong way and I'm not sure what it is, so any help would be appreciated.