$\newcommand{\szdp}[1]{\!\left(#1\right)} \newcommand{\szdb}[1]{\!\left[#1\right]}$ Problem Statement: A survey of voter sentiment was conducted in four midcity political wards to compare the fraction of voters favoring candidate $A.$ Random samples of $200$ voters were polled in each of the four wards. The numbers of voters favoring $A$ in the four samples can be regarded as four independent binomial random variables. Construct a likelihood ratio test of the hypothesis that the fractions of voters favoring candidate $A$ are the same in all four wards. Use $\alpha=0.05.$

Note 1: This is essentially Exercise 10.88 in Mathematical Statistics with Applications, 5th Ed., by Wackerly, Mendenhall, and Sheaffer.

Note 2: I have looked at several threads asking the same question. This thread has no viable answer. This thread has a solution done mostly in R and is not a theoretical derivation of the needed result. This thread works out exactly zero details: and as you'll see, I'm definitely in the weeds on this one.

Note 3: This is cross-posted here.

My Work So Far: Let $p_i$ be the proportion of voters favoring $A$ in Ward $i.$ So the null hypothesis is that $p_1=p_2=p_3=p_4,$ while the alternative hypothesis is that at least one proportion is different from the others. We have $f$ as the underlying distribution: $$f(y_i)=\binom{n}{y_i}p_i^{y_i}(1-p_i)^{n-{y_i}}.$$ It follows that the likelihood function is $$L(p_1,p_2,p_3,p_4) =\prod_{i=1}^4\szdb{\binom{n}{y_i}p_i^{y_i}(1-p_i)^{n-y_i}}.$$ Then we construct $L\big(\hat\Omega_0\big)$ and $L\big(\hat\Omega\big).$ Note that under the null hypothesis, we will set $p_1=p_2=p_3=p_4=p.$ Hence, $$L\big(\hat\Omega_0\big) =\prod_{i=1}^4\szdb{\binom{n}{y_i}p^{y_i}(1-p)^{n-y_i}}.$$ The one remaining parameter $p$ we will replace with its MLE, which we can confidently say is $\big(\sum y_i\big)/(4n).$ Hence \begin{align*} L\big(\hat\Omega_0\big) &=\prod_{i=1}^4\szdb{\binom{n}{y_i}\szdp{\frac{\sum y_i}{4n}}^{\!\!y_i}\szdp{1-\frac{\sum y_i}{4n}}^{\!\!n-y_i}}\\ &=\frac{1}{(4n)^n}\prod_{i=1}^4\szdb{\binom{n}{y_i}\szdp{\sum y_i}^{\!y_i}\szdp{4n-\sum y_i}^{\!n-y_i}}. \end{align*} Next, we turn our attention to $L\big(\hat\Omega\big):$ \begin{align*} L\big(\hat\Omega\big) &=\prod_{i=1}^4\szdb{\binom{n}{y_i}\szdp{\frac{y_i}{n}}^{\!y_i} \szdp{1-\frac{y_i}{n}}^{\!n-y_i}}\\ &=\prod_{i=1}^4\szdb{\binom{n}{y_i}\szdp{\frac{y_i}{n}}^{\!y_i} \szdp{\frac{n-y_i}{n}}^{\!n-y_i}}\\ &=\frac{1}{n^{4n}}\prod_{i=1}^4\szdb{\binom{n}{y_i}y_i^{y_i} \,\szdp{n-y_i}^{n-y_i}}. \end{align*} Next we form the likelihood ratio: \begin{align*} \lambda &=\frac{L\big(\hat\Omega_0\big)}{L\big(\hat\Omega\big)}\\ &=\frac{\displaystyle \frac{1}{(4n)^n}\prod_{i=1}^4\szdb{\binom{n}{y_i} \szdp{\sum y_i}^{\!y_i}\szdp{4n-\sum y_i}^{\!n-y_i}}} {\displaystyle \frac{1}{n^{4n}}\prod_{i=1}^4\szdb{\binom{n}{y_i}y_i^{y_i} \,\szdp{n-y_i}^{n-y_i}}}\\ &=\frac{n^{4n}}{4^n\,n^n}\cdot \prod_{i=1}^4\szdb{\szdp{\frac{\sum y_j}{y_i}}^{\!y_i}\, \szdp{\frac{4n-\sum y_j}{n-y_i}}^{\!n-y_i}}\\ &=\szdp{\frac{n^3}{4}}^{\!\!n}\cdot \prod_{i=1}^4\szdb{\szdp{\frac{\sum y_j}{y_i}}^{\!y_i}\, \szdp{\frac{4n-\sum y_j}{n-y_i}}^{\!n-y_i}}. \end{align*}

My Questions:

  1. This looks wrong to me, because I'm told (and it totally makes sense) that $0\le\lambda\le 1,$ whereas everything in sight is greater than $1.$
  2. Supposing this expression can be salvaged, what are the next steps? Should I take logs and try to simplify somehow?
  3. I'm expecting to be able to obtain a test something along the lines of $$\frac{(1/(4n))\sum_{j=1}^ny_j-\sum_{j=1}^n(y_j/n)}{\displaystyle\sqrt{\sum_{j=1}^4\dfrac{(y_j/n)(1-y_j/n)}{n}}},$$ although this test doesn't strike me as sensitive enough. We could have $y_1/n$ much too low, and $y_4/n$ much too high, and this test could still mark them down as equal because they "average out" to the right thing. What's the right generalization to the standard difference of proportions test?
  • 1
    $\begingroup$ I'm looking at the 6th ed. of the text by W-M-S, where this seems to be problem 10.94, following worked example 10-24 which is similar but compares complaints by union stewards about two shifts at a factory. The approximate dist'n of $-2\log \lambda$ is $\mathsf{Chisq}(\nu)$ for appropriate degrees of freedom $\nu.$ I cannot see how your expression for $\lambda$ parallels the implementation of Thm 10.2 shown for the factory example. Maybe you can have another look at that. $\endgroup$
    – BruceET
    Commented Aug 24, 2021 at 18:31
  • $\begingroup$ @BruceET Thanks for your comment. The Example 10.24 (in 6th ed.) should have the underlying distribution as Poisson, whereas in Exercise 10.94, the underlying distribution is binomial. So I would certainly expect the final result to be quite different. So you think this problem should apply Theorem 10.2? I could certainly do that (the d.o.f. should be $3-0=0,$ correct?): in that case there wouldn't be even a superficial similarity to the usual difference-of-proportions test. Is my $\lambda$ correct? $\endgroup$ Commented Aug 24, 2021 at 18:49
  • 1
    $\begingroup$ I meant d.o.f. $3-0=3,$ of course. $\endgroup$ Commented Aug 24, 2021 at 18:54
  • $\begingroup$ Re 6e: And I meant Exmp 10.25 (not 10.24), but you're right about Poisson assumption. // Yes, I'd follow Thm 10.2. // My 'Answer' below has more of an applied flavor, especially the ad hoc tests. // Thanks for up-vote. But don't Accept for now. Let's see if someone knows about a relevant implementation of LR test in R. $\endgroup$
    – BruceET
    Commented Aug 24, 2021 at 19:29
  • $\begingroup$ @BruceET Thanks for your help! I'm kinda hoping whuber will weigh in, as I'm sure he can figure this out. $\endgroup$ Commented Aug 24, 2021 at 19:55

3 Answers 3


In the following, I'm going to use the numbers supplied in the exercise. The null hypothesis is $H_0:p_1=p_2=p_3=p_4=p$. As you wrote, the likelihood function is $$ L(\mathbb{p})=\prod_{i=1}^4{200\choose y_i}p_i^{y_i}(1-p_i)^{200-y_i} $$ where $y_i$ are the number of voters favoring $A$ in ward $i$. Under $H_0$, the MLE of $p$ is $\hat{p}=\sum_{i=1}^{4}y_i/800$. Otherwise, we have $\hat{p}_i=y_i/200$ for $i=1, 2, 3, 4$. Plugging these into the likelihood function and forming the ratio, we get $$ \lambda = \dfrac{\left(\dfrac{\sum y_i}{800}\right)^{\sum y_i}\left(1 - \dfrac{\sum y_i}{800}\right)^{800 - \sum y_i}}{\prod_{i=1}^{4}\left(\dfrac{y_i}{200}\right)^{y_i}\left(1 - \dfrac{y_i}{200}\right)^{200 - y_i}}. $$ According to theorem 10.2 in the book, for large $n$, $-2\log(\lambda)$ has approximately a $\chi^2$ distribution with $\nu$ degrees of freedom when $H_0$ is true, where $\nu$ is the difference between the number of freely varying parameters in $\Omega$ and the number of such parameters in $\Omega_0$. Here, we have $4 - 1 = 3$ degrees of freedom.

Using the data provided in the book, we have $y_1 = 76, y_2 = 53, y_3 = 59, y_4 = 48$. According to the formula above, I get $-2\log(\lambda)=10.54$ and a $p$-value of $0.015$. This is very similar to what Rs prop.test gives:

y <- c(76, 53, 59, 48)
prop.test(y, rep(200, 4), correct = FALSE)

X-squared = 10.722, df = 3, p-value = 0.01333
alternative hypothesis: two.sided
sample estimates:
prop 1 prop 2 prop 3 prop 4 
 0.380  0.265  0.295  0.240 
  • 1
    $\begingroup$ Your simplified expression and mine are different: I was able to plug numbers into both, and they came out different. Must have done some incorrect algebra in there somewhere. Thanks! $\endgroup$ Commented Aug 27, 2021 at 22:45

You have a small error in the algebra in your post. Using your notation, you should have:

$$\begin{align*} L ( \hat{\Omega}_0) &= \frac{1}{(4n)^{4n}} \prod_{i=1}^4 \Bigg[ {n \choose y_i} (\sum y_i)^{y_i} (4n-\sum y_i)^{n-y_i} \Bigg], \\[12pt] L (\hat{\Omega}) &= \frac{1}{n^{4n}} \prod_{i=1}^4 \Bigg[ {n \choose y_i} y_i^{y_i} (n- y_i)^{n-y_i} \Bigg]. \\[12pt] \end{align*}$$

(So your constant out the front of the first expression is wrong.) You should then get:

$$\begin{align*} \lambda \equiv \frac{L(\hat{\Omega}_0)}{L(\hat{\Omega})} &= \frac{1}{4^{4n}} \prod_{i=1}^4 \frac{(\sum y_i)^{y_i} (4n-\sum y_i)^{n-y_i}}{y_i^{y_i} (n- y_i)^{n-y_i}} \\[6pt] &= \prod_{i=1}^4 \bigg( \frac{\sum y_i}{4y_i} \bigg)^{y_i} \bigg( \frac{4n-\sum y_i}{4n-4y_i} \bigg)^{n-y_i}, \\[6pt] \end{align*}$$

which satisfies the constraint $0 \leqslant \lambda \leqslant 1$.

An alternative derivation for the generalised case: Let's try to simplify these likelihood functions as much as we can to minimise the notational burden of the mathematics. I am going to do a generalised version of the problem where I use $k$ groups and I don't assume that each sample is the same size. Thus, I will let $y_1,...,y_k$ be the sample totals (favouring candidate $A$) and $n_1,...,n_k$ be the respective sample sizes, with $\mathbf{p}=(p_1,...,p_k)$ being the unknown vector of true probabilities. We also let $y \equiv \sum y_i$ and $n \equiv \sum n_i$ be the pooled sample total and sample size respectively.

It is simple to establish that the MLE for the probability parameter for binomial data is the sample proportion. Consequently, without the null assumption, the maximised log-likelihood is:$^\dagger$

$$\begin{align} \hat{\ell}_{\mathbf{y},A} &= \sum_{i=1}^k \log \text{Bin} \Big( y_i \Big| n_i,\frac{y_i}{n_i} \Big) \\[6pt] &= \sum_{i=1}^k \Bigg[ \log {n_i \choose y_i} + y_i \log \bigg( \frac{y_i}{n_i} \bigg) + (n_i-y_i) \log \bigg( \frac{n_i-y_i}{n_i} \bigg) \Bigg] \\[6pt] &= \sum_{i=1}^k \Bigg[ \log {n_i \choose y_i} + y_i \log ( y_i ) + (n_i-y_i) \log (n_i-y_i) - n_i \log(n_i) \Bigg]. \\[6pt] \end{align}$$

When we condition on the null hypothesis we have the maximised log-likelihood:

$$\begin{align} \hat{\ell}_{\mathbf{y}, 0} &= \sum_{i=1}^k \log \text{Bin} \Big( y_i \Big| n_i,\frac{y}{n} \Big) \\[6pt] &= \sum_{i=1}^k \log {n_i \choose y_i} + y \log \bigg( \frac{y}{n} \bigg) + (n-y) \log \bigg( \frac{n-y}{n} \bigg) \\[6pt] &= \sum_{i=1}^k \log {n_i \choose y_i} + y \log (y) + (n-y) \log (n-y) - n \log (n). \quad \quad \quad \quad \quad \ \ \\[6pt] \end{align}$$

We can therefore write the likelihood ratio statistic as:

$$\begin{align} \Delta_\text{LR}(\mathbf{y}) &\equiv 2 (\hat{\ell}_{\mathbf{y}, A} - \hat{\ell}_{\mathbf{y},0}) \\[12pt] &= 2 \sum_{i=1}^k \Bigg[ \log {n_i \choose y_i} + y_i \log ( y_i ) + (n_i-y_i) \log (n_i-y_i) - n_i \log(n_i) \Bigg] \\[6pt] &\quad \quad - 2 \Bigg[ \sum_{i=1}^k \log {n_i \choose y_i} + y \log (y) + (n-y) \log (n-y) - n \log (n) \Bigg] \\[6pt] &= 2 \sum_{i=1}^k \Bigg[ y_i \log \bigg( \frac{y_i}{y} \bigg) + (n_i-y_i) \log \bigg( \frac{n_i-y_i}{n-y} \bigg) - n_i \log \bigg( \frac{n_i}{n} \bigg) \Bigg]. \\[6pt] \end{align}$$

Since $\hat{\ell}_{\mathbf{y}, A} \geqslant \hat{\ell}_{\mathbf{y}, 0}$ this likelihood ratio statistic will be non-negative. The likelihood ratio test is obtained by finding a cut-off point for this statistic, above which the null hypothesis is rejected.

$^\dagger$ In these equations we use $\text{Bin}$ to denote the binomial mass function.

  • $\begingroup$ Perhaps it's the hubris of youth, but this answer is less than helpful for the following reasons: 1. Instead of answering my questions directly, you appear to have simply tried solving the original problem the way you would prefer to do it. 2. You're using notation that is quite different from mine, and therefore somewhat confusing. 3. You stopped your answer right at the point I stopped my question, which is precisely where I was asking for help. My book is sparse on the details of getting from an as-simplified-a-likelihood-ratio-as-you-can-get to a test. Could you please answer my questions? $\endgroup$ Commented Aug 27, 2021 at 16:39
  • $\begingroup$ In particular, the notations $\hat\ell$ and $\text{Bin}$ are unknown to me. Your $\Delta$ ratio is the opposite of mine. You skip a number of steps in writing down the $\hat\ell$'s: you write that they're maximized, but show no steps as to why they are maximized. What I want to know is: what's wrong with MY reasoning? I spent an awful long time trying to write a good question, because I know that CV.SE has lots of bad questions: I investigated what was already here, I wrote out the problem statement in full, I displayed all my work, and I laid out my questions clearly. I was pretty specific. $\endgroup$ Commented Aug 27, 2021 at 16:43
  • 2
    $\begingroup$ I have edited the post to review your working directly. The notation $\hat{\ell}$ is used to denote the maximised log-likelihood function, and $\text{Bin}$ denotes the probability mass function for the binomial distribution. The quantity $\Delta_\text{LR}$ is the usual form of the (logarithmic form) of the likelihood ratio function, shown at the link. $\endgroup$
    – Ben
    Commented Aug 28, 2021 at 0:13
  • $\begingroup$ Thank you; that's much more helpful. $\endgroup$ Commented Aug 28, 2021 at 1:05

Comment continued. A reasonable approximation to the likelihood ratio test is a chi-squared test of homogeneity for a contingency table. There are two essentially equivalent implementations of such a test in R. Using the data from w-M-S, 6e, Exercise 10.94, I show results from each. [Counts are large enough that results should be similar to LR test.]

Data. Wards are rows, Favor and Not are columns.

TBL = cbind(c(76,53,59,48), 
     [,1] [,2]
[1,]   76  123
[2,]   53  147
[3,]   59  141
[4,]   48  153

In R, the procedure prop.test uses an approximately chi-squared statistic to compare the four proportions in favor for the four rows of TBL. The null hypothesis that true proportions are the same in all four wards is decisively rejected at the 5% level (P-value about 1%).


    4-sample test for equality of proportions 
    without continuity correction

data:  TBL
X-squared = 11.145, df = 3, p-value = 0.01097
alternative hypothesis: two.sided
sample estimates:
   prop 1    prop 2    prop 3    prop 4 
0.3819095 0.2650000 0.2950000 0.2388060 

Pearson's chi-squared test of heterogeneity gives the same chi-squared statistic and P-value.


            Pearson's Chi-squared test

    data:  TBL
    X-squared = 11.145, df = 3, p-value = 0.01097

The proportions in favor seems about the same in wards 2, 3, and 4. An ad hoc test finds no significant difference among them.


        Pearson's Chi-squared test

data:  TBL[2:4, ]
X-squared = 1.6228, df = 2, p-value = 0.4442

By contrast, an ad hoc 'chisq.test` of Ward 1 against the other three wards (without Yates' correction because of large counts) finds a highly significant difference.

chisq.test(TBL2, cor=F)

       Pearson's Chi-squared test

data:  TBL2
X-squared = 9.6204, df = 1, p-value = 0.001924

Fisher's exact test (ad hoc) also finds a significant difference at about the 1% level.


        Fisher's Exact Test 
        for Count Data

data:  TBL
p-value = 0.01226
alternative hypothesis: two.sided
  • 1
    $\begingroup$ This will be helpful for corroborating a theoretical solution, but I can't mark this as the solution because I am not interested in an R solution (see Note 2). $\endgroup$ Commented Aug 24, 2021 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.