Uniform-alternative binomial Bayes factor (source code)

= Uniform-alternative binomial Bayes factor
{title2=$B_{01}(y)=(n+1)\binom ny2^{-n}$}

For a <binomial distribution> count, compare a point null $\theta=1/2$ with the uniform alternative <prior distribution> on $(0,1)$. The alternative <Bayesian model evidence> is
$$
\binom ny\int_0^1\theta^y(1-\theta)^{n-y}\,d\theta=\frac1{n+1},
$$
so the exact <Bayes factor> favouring the point null is $(n+1)\binom ny2^{-n}$. With standardized deviation $z=2(y-n/2)/\sqrt n$, the local <normal distribution> approximation is $B_{01}\approx\sqrt{2n/\pi}e^{-z^2/2}$. At fixed $z$ the frequentist <p-value> remains approximately constant, while the factor grows like $\sqrt n$. This demonstrates the prior-width mechanism behind the <Jeffreys-Lindley paradox for a Gaussian point null> in a discrete sampling model.

For a separate original example, change the point null to $H_0:p=1/2$ and take $H_U$ to have a <uniform prior> $p\sim\operatorname{Beta}(1,1)$, fixed before the ten <Bernoulli trials>. Here $p$ is drawn once under $H_U$ and shared by all ten trials: they are <independent> conditional on $p$. For one particular ordered sequence with eight heads and two tails, the <Euler beta function> gives
$$
m_0(D)=2^{-10},\qquad
m_U(D)=\int_0^1p^8(1-p)^2\,dp
=B(9,3)=\frac{8!\,2!}{11!}=\frac1{495}.
$$
Thus the <Bayes factor> for the uniform alternative against the point null is
$$
\mathrm{BF}_{U0}=\frac{1024}{495}\approx2.0686869,
\qquad B_{0U}=\frac{495}{1024}\approx0.4833984.
$$
The <binomial distribution> count formulation gives $m_0(K=8)=45/1024$ and $m_U(K=8)=45/495=1/11$. Their ratio is again $1024/495$; these count masses must not be combined with the ordered-sequence masses above. The general $B_{01}$ formula at the start of this article puts the point null in the numerator, so it equals $B_{0U}$ here.

In contrast, <maximum likelihood estimation> gives $\widehat p=0.8$: differentiating the <log-likelihood> yields $8/p-2/(1-p)=0$, and the endpoints have zero <likelihood>. Its peak-to-null <likelihood ratio> is
$$
\frac{L(0.8)}{L(0.5)}
=\frac{0.8^8\,0.2^2}{2^{-10}}\approx6.8719477.
$$
This peak is chosen after seeing the data, so it is not the <Bayes factor> of the prespecified $H_U$. The <Bayesian model evidence> for $H_U$ averages $L(p)$ over its entire <uniform prior>; it is smaller than the peak. It is also smaller than $L(0.7)=0.7^8\,0.3^2\approx0.00518832$. Against the same $p=0.5$ null, a point alternative fixed at $p=0.7$ would give a <Bayes factor> about $5.31284$, greater than $2.06869$. An integrated alternative need not outperform a point alternative.

\Image[/bayes-factor-likelihood-averaging.png]
{title=A uniform-prior average of the likelihood differs from its maximum}
{description=Original calculation for a stipulated ordered sequence with eight heads and two tails. Left: the <likelihood function> $L(p)=p^8(1-p)^2$ and its <uniform prior> average $m_U=1/495$, with the point null at $p=0.5$ and peak at $p=0.8$. Right: the average, fixed $p=0.7$ value, and peak divided by the same null value $2^{-10}$. Only the first two comparisons use prespecified alternatives; the peak uses a <maximum-likelihood estimate>. These are calculated model quantities, not measured frequencies.}

For a general proper <beta distribution> <prior distribution> $\operatorname{Beta}(a,b)$ with $a,b>0$, the same ordered-sequence <marginal likelihood> is $B(8+a,2+b)/B(a,b)$. This follows by substituting the normalized <prior density> into the <integral>, and shows exactly where the parameter <prior distribution> changes the <Bayes factor>. Holding the parameter <prior distributions> fixed while changing model <prior odds> leaves that <Bayes factor> unchanged.