Likelihood-ratio test for equality of beta shape parameters (source code)

= Likelihood-ratio test for equality of beta shape parameters
{title2=$\lambda=\frac{(n+m)^{n+m}}{n^nm^m}T^n(1-T)^m$}

Take two independent <statistical samples> from <beta distributions> with parameters $(\theta,1)$ and $(\tau,1)$, of positive sizes $n,m$. Put $A=-\sum_i\log X_i$, $B=-\sum_j\log Y_j$, and $T=A/(A+B)$. To test the <null hypothesis> $\theta=\tau$, divide the maximized common-rate <likelihood function> by the unrestricted maximum to obtain the displayed <likelihood ratio>. Indeed the unrestricted fitted rates are $n/A,m/B$, and the common fitted rate is $(n+m)/(A+B)$; substitution cancels the exponential factors.

Under the <null hypothesis>, $A$ and $B$ have independent <gamma distributions> with a common rate. <Beta-gamma independence> gives $T\sim\operatorname{Beta}(n,m)$. The <derivative> of $\log(T^n(1-T)^m)$ changes sign at $n/(n+m)$, so the exact <critical region> of size $\alpha$ is $T<k_1$ or $T>k_2$, with $k_1<n/(n+m)<k_2$. Its cutoffs satisfy
$$
k_1^n(1-k_1)^m=k_2^n(1-k_2)^m,\qquad
F_{n,m}(k_1)+1-F_{n,m}(k_2)=\alpha.
$$
Here $F_{n,m}$ is the <beta distribution> <cumulative distribution function>. Equal <likelihood ratios> at the cutoffs do not generally mean equal tail probabilities. Increasing the ratio threshold continuously adds positive <null distribution> mass on both sides, proving uniqueness for $0<\alpha<1$.