# Estimator of variance for a binomially distributed sample

I want to run some Bayesian analysis on some data. Suppose we have a sample that we believe comes from a binomial population. We have $$m$$ observations

$$X_i \sim \text{Bin}(n,p) \quad \quad \quad \text{ for } i \in \{1,2,\dots,m\}.$$

I have chosen my prior to be a beta distribution. I'm unsure how to pick parameters to make my distribution better suited to my beliefs. I assume I would take the sample mean and set the mean of the beta prior equal to this number, but I'm not sure what to do about working out the variance. Can anyone offer a suggestion?

• You can set the mean as the ratio $\alpha/(\alpha+\beta)$, and the distribution has an effective sample size of $\alpha+\beta$ so the smaller they are the less your prior will contribute to the posterior. Commented Dec 15, 2023 at 18:18
• You do not set the prior mean to the sample mean but to the mean of your prior belief (the Bayesian updating process handles the sample through the likelihood). You also need some measure of how uncertain your prior belief is and some way of expressing this. Commented Dec 15, 2023 at 21:21
• @Henry What do I do then if I don't have strong beliefs about my data? Why would it be incorrect for me to set the prior mean to be the sample mean? What're the effects of this? Commented Dec 16, 2023 at 12:32
• @PBulls What does your comment about the sample size being alpha + beta mean? Commented Dec 16, 2023 at 12:33
• @TerryStone such prior carries an effective sample size of $n=\alpha+\beta$. If you have a beta likelihood on 30 observations and a beta prior whose parameters sum to 30 they will contribute equally to the posterior, and e.g. Jeffreys' prior (0.5, 0.5) carries a weight of 1 observation. In the same way a normal conjugate with SD $\sigma/\sqrt n$ carries the weight of $n$ observations from a distribution with SD $\sigma$. The same idea appears in Javier's answer, because for priors it's useful to think in terms of how much your actual data can shift them (how their 'sample sizes' relate). Commented Dec 16, 2023 at 15:38

You could try to set a Beta prior distribution on $$p$$ and parametrize it in terms of the prior mean $$\mu_p$$ and prior precision $$\varphi_p$$. If $$(a_1, a_2)$$ are the canonical shape parameters of the Beta distribution, then $$\mu_{p}= \frac{a_1}{a_1+a_2}, \varphi_{p}= a_1+ a_2$$. This might be more intuitive for you. I have uploaded a plot that shows the beta distribution under the mean-precision parametrisation for several choices of $$\mu_{p},\varphi_{p}$$.
• Because the question asks specifically about variance, some explanation of your "precision" would help here, because it's not equal to the usual meaning of "precision" (as the reciprocal variance). That would be $(a_1+a_2)^2(1+a_1+a_2)/(a_1a_2).$ For specifying parameters for an intended mean and variance, see the answers at stats.stackexchange.com/questions/12232. A comment in that thread explains $\phi_p.$