Why Data Checks Matter
Grouped binomial data summarize repeated binary outcomes. A row might report how many patients improved among those given a treatment, or how many devices passed inspection in a production batch. The compact format is useful, but the roles of the counts must remain clear: the response count is the number of successes, and the denominator is the number of trials.
A small coding mistake can change the likelihood, the effective amount of information, or even which event the model calls a success. These errors can be hard to notice when the resulting proportions still look plausible. The checks in this tutorial focus on the data representation and its consequences, rather than on fitting a new kind of model.
The binomial model assumes that, within a group, the trials have the same success probability \(p_i\) and are independent conditional on the model’s predictors. Groups are also taken to be independent. When probabilities depend on predictors, the probability for group \(i\) is denoted \(p_i\); the meaning of “success” must still be consistent across all groups.
Start With the Counts and Their Roles
Before fitting or interpreting anything, check each row against the original data definition. Verify which event is a success, which count records that event, and whether the total is the sum of successes and failures. A useful basic identity is
This identity is not a substitute for checking the source data: an incorrect pair of counts can still add to a plausible total. But it catches many transcription and data-assembly errors. Also check that \(0\leq y_i\leq n_i\), that \(n_i\) is a nonnegative integer, and that any reported proportion agrees with \(y_i/n_i\).
Worked Example: Reversed Success and Failure Counts
A study records 14 patients who improved and 6 who did not improve among 20 treated patients. The model is intended to describe the probability of improvement.
The correct response count is \(y=14\), the failure count is \(m=6\), and the total is \(n=14+6=20\). The observed improvement proportion is
Suppose instead that the two counts are reversed while the denominator is kept at 20. The data then tell the model there were 6 improvements in 20 trials, giving a fitted group proportion of \(6/20=0.30\). In a model with a separate logit for this group, the correct log-odds are
After reversing the counts, the log-odds become
The sign changes because the model is now describing the odds of the opposite event. Reversing counts is not harmless relabeling unless the success event and every interpretation are deliberately changed as well.
Do Not Drop the Trial Totals
The observed proportion \(y_i/n_i\) does not retain all the information in a grouped observation by itself. For example, proportions based on 2 of 4 trials and 200 of 400 trials are both 0.5, but the latter comes from many more trials. The binomial likelihood includes \(n_i\), so replacing the grouped counts with proportions alone generally discards information about precision.
A related error is to average group proportions equally when the intended quantity is the overall success proportion across all trials. The overall proportion weights each group by its number of trials. The following derivation shows this directly for an intercept-only model, in which every trial shares one success probability \(p\).
Derivation. Ignoring factors that do not depend on \(p\), the likelihood is \(L(p)\propto p^{\sum_i y_i}(1-p)^{\sum_i(n_i-y_i)}\). For \(0<p<1\), its log-likelihood is
Writing \(Y=\sum_i y_i\) and \(N=\sum_i n_i\), its derivative is
The derivative is zero at \(p=Y/N\). Since \(0<Y<N\), this point is inside the parameter space. The second derivative is
so the log-likelihood is strictly concave and this stationary point is its unique maximum. If \(Y=0\) or \(Y=N\), the maximum instead occurs at the boundary \(p=0\) or \(p=1\), respectively. \(\square\)
Worked Example: Why an Unweighted Average Can Be Wrong
Suppose two groups share a common success probability under the model. Group A has 2 successes in 4 trials, and Group B has 36 successes in 60 trials.
The group proportions are \(2/4=0.50\) and \(36/60=0.60\). Their unweighted average is
But the total number of successes is \(2+36=38\), and the total number of trials is \(4+60=64\). The intercept-only maximum-likelihood estimate is therefore
The second group contributes more trials, so its proportion contributes more to the pooled estimate. The unweighted average answers a different question: it gives each group equal influence regardless of how many trials it contains.
Do Not Count the Same Trials Twice
A common data-assembly mistake is to create separate “success” and “failure” rows for one group, then give each row the original total as its denominator. In a binomial response, the denominator is the number of trials represented by that row. If the same trials appear in both rows, the model counts them twice.
Worked Example: Detecting a Duplicated Denominator
A group has 8 successes and 12 failures, so \(n=20\). The intended success proportion is \(8/20=0.40\). Consider the incorrect representation consisting of two binomial rows: one with response count 8 and denominator 20, and another with response count 12 and denominator 20. If both rows are interpreted as counts of successes, the combined data contain 20 apparent successes among 40 apparent trials.
For a shared probability \(p\), the correct likelihood, apart from a constant, is
which is maximized at \(8/(8+12)=0.40\). The incorrect two-row construction gives
Its maximum is at \(20/(20+20)=0.50\), and it treats the data as if there were 40 trials. The error changes both the estimate and the apparent amount of information. If a data format stores success and failure counts in separate columns, those columns must be supplied as the two outcomes for the same 20 trials—not as two success counts each with denominator 20.
Group Counts Are Not Individual Binary Outcomes
A group count such as \(y_i=8\) is not a single Bernoulli response: a Bernoulli outcome can only be 0 or 1. Nor should the count be treated as a continuous outcome merely because it is numeric. The count represents \(n_i\) binary trials summarized in one row.
There is an important distinction between an invalid treatment of a count and a valid expansion to individual records. If the underlying trials are independent and share the group probability, expanding a group into \(y_i\) binary successes and \(n_i-y_i\) binary failures preserves the probability model for estimating \(p_i\). Merely entering the number \(y_i\) as one individual response does not.
Proof. For one particular ordered sequence of \(n\) independent binary outcomes containing \(y\) successes, independence gives probability \(p^y(1-p)^{n-y}\). There are \(\binom{n}{y}\) distinct ordered sequences with exactly \(y\) successes: choose which \(y\) of the \(n\) positions contain successes. These sequences are disjoint, so their probabilities add to \(\binom{n}{y}p^y(1-p)^{n-y}\), the probability of the grouped count \(y\). Since \(\binom{n}{y}\) is constant in \(p\), it cannot change which value of \(p\) maximizes the likelihood. \(\square\)
Worked Example: A Valid Expansion Versus an Invalid Response
At predictor value \(x=0\), a group has 8 successes in 10 trials; at \(x=1\), a second group has 1 success in 10 trials. A model with a separate probability for each predictor value has likelihood, apart from binomial coefficients,
The two separate maximum-likelihood estimates are \(8/10=0.8\) and \(1/10=0.1\). Expanding the first group into eight 1s and two 0s at \(x=0\), and the second into one 1 and nine 0s at \(x=1\), yields the same parameter-dependent likelihood. Each expanded row is a binary trial.
By contrast, entering just two rows with responses 8 and 1 as if these were individual Bernoulli outcomes is invalid: neither response is a possible Bernoulli value. The two group counts summarize 20 trials; they are not two binary outcomes. Expansion is valid only when it represents the underlying trials, preserves the group predictor values, and uses the individual outcomes as 0s and 1s.
A Practical Error-Checking Sequence
The following checks separate data-definition problems from modeling choices. They are especially useful when grouped data have been created by aggregating individual records or assembled from a table with separate success and failure columns.
Write down the event the model is intended to predict, such as “improved.” Confirm that the success count records that event in every group.
Check that \(n_i=y_i+m_i\), that the counts are nonnegative, and that the reported proportion equals \(y_i/n_i\) when \(n_i>0\).
Confirm that every trial contributes once—not once in a success row and again in a failure row—and that a group count has not been entered as one binary outcome.
For a common-probability model, calculate \(\sum_i y_i/\sum_i n_i\). Compare it with the fitted estimate and investigate a discrepancy that cannot be explained by the model specification.
Common Mistakes
- Reversing successes and failures. “The two counts add to the correct total” does not establish that they are in the correct columns. Check the event definition; reversing the counts models the complementary event.
- Dropping the denominators. Proportions alone do not say how many trials produced them. Retain the trial totals when specifying the grouped binomial response.
- Giving every group equal weight by averaging proportions. That calculates an average of group-specific proportions, not the pooled proportion across trials. For a common probability, the pooled estimate is \(\sum_i y_i/\sum_i n_i\).
- Duplicating the denominator. Successes and failures are complementary outcomes from the same trials. Do not enter each count as successes in a separate row with the original total as its denominator.
- Calling a group count one binary observation. A count of 8 is not an individual Bernoulli response. Use the grouped binomial representation or, when the underlying records are available, a genuine expansion into binary outcomes.
These checks matter because grouped data are a summary, not merely a shorter way to print a list of numbers. The totals determine how many trials support each proportion, and the success definition determines the event to which every probability and coefficient refers. Confirming both before fitting can prevent an apparently well-behaved model from answering the wrong question.
Check Your Understanding
Use the definitions and calculations in this tutorial to check each conclusion.
- A group has 9 successes and 21 failures. What are its total and observed success proportion?
- Two groups have 3 successes in 5 trials and 30 successes in 50 trials. Find the pooled proportion and the unweighted average of the group proportions. Why are they equal or unequal here?
- A group has 4 successes and 16 failures. Explain why creating two binomial rows with denominator 20 would duplicate the trials if both counts were entered as successes.
- What is the difference between expanding 8 successes in 10 trials into ten binary records and entering the single number 8 as an individual binary response?
- If a model’s success event is “no relapse,” what must be checked before interpreting the fitted probability as a relapse probability?