How can I calculate the $\alpha$ and $\beta$ parameters for a Beta distribution if I know the mean and variance that I want the distribution to have? Examples of an R command to do this would be most helpful.
5,197 9 9 gold badges 47 47 silver badges 64 64 bronze badges asked Jun 22, 2011 at 17:17 Dave Kincaid Dave Kincaid 1,688 2 2 gold badges 14 14 silver badges 18 18 bronze badges$\begingroup$ Note that the betareg package in R uses an alternative parameterization (with the mean, $\mu=\alpha/(\alpha+\beta)$, & the precision, $\phi=\alpha+\beta$--and hence the variance is $\mu(1-\mu)/(1+\phi)$) which obviates the need for these calculations. $\endgroup$
Commented Jul 25, 2012 at 15:48$\begingroup$ This post could be subtitled "help! I don't want to do algebra!" (that's my reason for being here at least) $\endgroup$
Commented Oct 6, 2021 at 20:41I've written up some R code to estimate the parameters of the Beta distribution from a given mean, mu, and variance, var:
estBetaParams
There's been some confusion around the bounds of $\mu$ and $\sigma^2$ for any given Beta distribution, so let's make that clear here.
answered Jun 22, 2011 at 18:00 assumednormal assumednormal 4,134 3 3 gold badges 22 22 silver badges 25 25 bronze badges$\begingroup$ @stan This will give you the Beta distribution which has the same mean and variance as your data. It will not tell you how well the distribution fits the data. Try the Kolmogorov-Smirnov Test. $\endgroup$
Commented Aug 19, 2012 at 20:19$\begingroup$ When I call this function with estBetaParams(0.06657, 0.1) I get alpha=-0.025 , beta=-0.35 . How is this possible? $\endgroup$
Commented May 7, 2014 at 23:46$\begingroup$ These calculations will only work if the variance is less than the mean*(1-mean). $\endgroup$
Commented Oct 29, 2015 at 18:20$\begingroup$ @danno - It's always the case that $\sigma^2\leq\mu\left(1-\mu\right)$. To see this, rewrite the variance as $\sigma^2=\frac<\mu\left(1-\mu\right)>$. Since $\alpha+\beta+1\geq1$, $\sigma^2\leq\mu\left(1-\mu\right)$. $\endgroup$
Commented Nov 4, 2015 at 3:06$\begingroup$ Given arbitrary $\mu\in(0,1)$ and $\sigma^2\in(0,0.5^2)$, there exists a beta distribution with mean $\mu$ and variance $\sigma^2$ if and only if $\sigma^2\leq\mu(1-\mu)$. @assumednormal showed the "only if" part of this claim, and danno hints at the "if" part. The takeaway is that not all values of $(\mu,\sigma^2)\in(0,1)\times(0,0.5^2)$ lead to valid beta distributions. Hopefully this clears up a little confusion about negative $\alpha$ and $\beta$! $\endgroup$