Likelihood ratio for binomial Suppose we wish to preform a simple likelihood ratio test for the parameters of two binomial distributions. Where the null hypothesis is that the two parameters are equal versus the alternative they are not.
Now for the following example, to construct a normal test or T-test would be straightforward. However I am interested in comparing this to using the likelihood ratio test and chi-square distribution.
Say we know for example
$A∼Bin(40,p_{A})$
and
$B∼Bin(20,p_{B})$
and we observe data from A and we observe $24$ successes hence we can then estimate the MLE $p=0.6$
and from B we observe data and observe $15$ successes hence the MLE $p=0.75$
How would one go about forming the likelihood ratio test statistic?
For example, if the parameters are the same then we can simply add and form a new binomial random variable. But if they are not, I dont think that can be done.
Ie under the null we would have observed 39 successes in 60 trials which would give an MLE of $p=0.65$
Using standard methods, we could form the pooled proportion $p=0.65$
then with standard error=$ \sqrt{(0.65)(1-0.65)(0.075)}=0.13$
$z=1.154$
 A: A. Finding the form of a likelihood ratio test
The basic procedure for constructing a likelihood ratio test is of the following form:


*

*maximize the likelihood under the null $\hat{\mathcal{L}}_0$ (by substituting the MLE under the null into the likelihood for each sample)

*maximize the likelihood under the alternative $\hat{\mathcal{L}}_1$ in the same manner

*Take the ratio $\Lambda = \hat{\mathcal{L}}_0/\hat{\mathcal{L}}_1$

*Reject if this ratio is too small (less than some critical value $k$ chosen to give an appropriate-level test). [Some sources take $\hat{\mathcal{L}}_1/\hat{\mathcal{L}}_0$ and reject if it's too large; this is the same thing.]
So for the null, where $p_A=p_B$, you combine the samples, write the estimator of the common $p_0$ and substitute that into the binomial likelihood for the two samples (the joint likelihood is the product of the individual likelihoods due to independence).
For the alternative you substitute the MLE of the $p$ parameter for the two samples separately into the likelihood for each one, taking their product.
Then take the ratio and simplify. Note that constants that remain after cancellation can be shifted out (pushed over to the other side of the inequality with $k$), and various other transformations performed that might simplify things (as long as your inequality is correctly maintained); you should be able to get it down to a simple rejection rule in terms of some new constant $k^\prime$.
If you're particularly lucky, you can eliminate dependence on the alternative (which should mean you would have a UMP test, at least in a one-tailed alternative). In some cases you may even be able to actually compute the required $k^\prime$ to achieve the type I error rate you want, and get a small-sample test.
Otherwise, it's common to apply an asymptotic result.
[I think this particular case boils down to an equivalent statistic to the one in the 2x2 G-test.]

B. Conducting a test directly on data -- using Wilks' theorem
For this you can just substitute the numbers straight into the likelihoods (the $\hat{\mathcal{L}}$ quantities above), compute their numerical values and take minus twice the log, comparing it with a chi-squared distribution (with df equal to the difference in the number of parameters). [NB H0 must be nested in H1 and not at a boundary for this to work]
For your specific example, I get:
L0 <- dbinom(15,20,39/60)*dbinom(24,40,39/60)
L1 <- dbinom(15,20,15/20)*dbinom(24,40,24/40)
-2*log(L0/L1)
[1] 1.359258

Applying Wilks' theorem that should be asymptotically $\chi^2_1$ under the null, so this has an asymptotic p-value of about 0.24

Edit: It turns out the G test ($G = 2\sum_i O_i \log(O_i/E_i)$) gives the same value for the test statistic (1.36), so that's encouraging, it suggests that it was correctly carried out. For comparison, with largish numbers like these the ordinary chi-square should be similar it as well, and the uncorrected chi-square is 1.32, which is quite close (p-value of 0.25).
