# 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$$

• Is this for a class? It looks like a standard sort of bookwork exercise. – Glen_b -Reinstate Monica Oct 24 '18 at 0:35
• @Glen_b No. My class has similar topics. I made this example myself,numbers included to attempt to learn. For example, I could already solve it using pooled proportion and z test – Learning Oct 24 '18 at 0:37
• Sounds like this would quite literally be self-study. Please check my answer and see if you can get anywhere with that approach. You may need to identify where you strike problems. – Glen_b -Reinstate Monica Oct 24 '18 at 0:58

### A. Finding the form of a likelihood ratio test

The basic procedure for constructing a likelihood ratio test is of the following form:

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

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

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

4. 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.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).

• Let me make sure I understand you correctly. Under the null the mle is p=0.65 and a log likelihood of -2.23 by forming the new binomial distribution. Under the alternative, I calculate the mle separately and multiply giving l=3.285. ratio of -0.679 ( null over alternative) – Learning Oct 24 '18 at 1:00
• 1. Unless you plan to simply apply Wilks' theorem (perform an asymptotic chi-squared test), the point is generally to compute the ML estimators rather than the ML estimates in order to derive a test statistic. (Please clarify the question.) 2. Note carefully that the ratio $\Lambda$ is a ratio of likelihoods, not log-likelihoods. If you want to deal with $\log\Lambda$ you would then have a difference not a ratio. – Glen_b -Reinstate Monica Oct 24 '18 at 1:05
• Could I apply Wilkes to the difference? In this case, instead of a ratio I would have a difference of 5.515? ( the log likelihood under the alternative minus log likelihood under null) – Learning Oct 24 '18 at 1:10
• Wilks' theorem relates to the distribution of $-2 \log \Lambda$, so you take minus twice the difference in log-likelihood. – Glen_b -Reinstate Monica Oct 24 '18 at 1:12
• Or would it be 2[5.515]=11.03? – Learning Oct 24 '18 at 1:23