Bayesian batting average prior

I wanted to ask a question inspired by an excellent answer to the query about the intuition for the beta distribution. I wanted to get a better understanding of the derivation for the prior distribution for the batting average. It looks like David is backing out the parameters from the mean and the range.

Under the assumption that the mean is $0.27$ and the standard deviation is $0.18$, can you back out $\alpha$ and $\beta$ by solving these two equations: \begin{equation} \frac{\alpha}{\alpha+\beta}=0.27 \\ \frac{\alpha\cdot\beta}{(\alpha+\beta)^2\cdot(\alpha+\beta+1)}=0.18^2 \end{equation}

• Honestly, I just kept graphing values in R until it looked right. – David Robinson Jan 17 '13 at 3:09
• where do you get the standard deviation to be .18? – appleLover Jul 20 '13 at 19:20
• How did you come up with this standard deviation? Did you know it in advance? – Maria Lavrovskaya Jun 12 at 6:02

Notice that:

$$\begin{equation} \frac{\alpha\cdot\beta}{(\alpha+\beta)^2}=(\frac{\alpha}{\alpha+\beta})\cdot(1-\frac{\alpha}{\alpha+\beta}) \end{equation}$$

This means the variance can therefore be expressed in terms of the mean as

$$\begin{equation} \sigma^2=\frac{\mu\cdot(1-\mu)}{\alpha+\beta+1} \\ \end{equation}$$

If you want a mean of $$.27$$ and a standard deviation of $$.18$$ (variance $$.0324$$), just calculate:

$$\begin{equation} \alpha+\beta=\frac{\mu(1-\mu)}{\sigma^2}-1=\frac{.27\cdot(1-.27)}{.0324}-1=5.083333 \\ \end{equation}$$

Now that you know the total, $$\alpha$$ and $$\beta$$ are easy:

$$\begin{equation} \alpha=\mu(\alpha+\beta)=.27 \cdot 5.083333=1.372499 \\ \beta=(1-\mu)(\alpha+\beta)=(1-.27) \cdot 5.083333=3.710831 \end{equation}$$

You can check this answer in R:

> mean(rbeta(10000000, 1.372499, 3.710831))
 0.2700334
> var(rbeta(10000000, 1.372499, 3.710831))
 0.03241907
• David, do you happen to follow any baseball research? There are several competing techniques out there for finding the proper $\alpha$ and $\beta$, so I was wondering if you had any opinion on the matter if you were doing something besides just trying to find a graph that looked reasonable. – Michael McGowan Jan 17 '13 at 14:53
• I don't particularly follow sabermetrics- in the other answer it just happened to provide a very convenient example of estimating p from a binomial with a prior. I don't even know if this is how it's done in sabermetrics, and if it is, I know there are many components I left out (players having different priors, stadium adjustments, weighting recent hits over old ones...) – David Robinson Jan 17 '13 at 15:02
• I am impressed that your eyeballing was this accurate. – Dimitriy V. Masterov Jan 19 '13 at 1:03
• Hi David, how do you get from these values of $\alpha = 1.37$ and $\beta = 3.71$ to your eyeballed values in the linked post of 81 and 219 respectively? – Alex Feb 29 '16 at 2:15
• @Alex The requested variance and standard deviation come from the above question, which asked for an SD of .18, not the beta distribution post. If I were calculating instead of eyeballing I might have guessed an SD of something like .03, which would have given values of 59 and 160. – David Robinson Feb 29 '16 at 2:32

I wanted to add this as a comment on the excellent answer but it ran long and will look better with answer formatting.

Something to keep in mind is that not all $(\mu, \sigma^2)$ are possible. It's clear $\mu \in [0,1]$, but not as clear are the limitations for $\sigma^2$.

Using the same reasoning as David, we can express

$$\sigma^2(\alpha, \mu) = \frac{\mu^2 (1-\mu)}{\alpha + \mu}$$

This is decreasing with respect to $\alpha$, so the largest $\sigma^2$ can be for a given $\mu$ is:

$$\lim_{\alpha \rightarrow 0}\sigma^2(\alpha, \mu) = \mu(1-\mu)$$

This is only a supremum since the set of valid $\alpha$ is open (i.e., for Beta, we must have $\alpha > 0$); this limit is itself maximized at $\mu = \frac12$.

Notice the relationship to a corresponding Bernoulli RV. The Beta distribution with mean $\mu$, since it is forced to take all values between 0 and 1, must be less dispersed (i.e., have lower variance) than the Bernoulli RV with the same mean (which has all of its mass at the ends of the interval). In fact, sending $\alpha$ to 0 and fixing $\beta = \frac{1-\mu}{\mu} \alpha$ amounts to putting more and more of the mass of the PDF close to 0 and 1, i.e., getting closer to a Bernoulli distribution, which is why the supremum of the variance is exactly the corresponding Bernoulli variance.

Taken together, here is the set of valid means and variances for Beta: (Indeed this is noted on the Wikipedia page for Beta)