Tutorials › Generalized Linear Mixed Models (GLMM) › Choosing Between Individual and Grouped Binomial Inputs

Software and Case Studies · Tutorial 696 of 698

Choosing Between Individual and Grouped Binomial Inputs

Use a shared trial dataset to choose and check individual or grouped binomial inputs without changing the model’s information or denominators.

Intermediate 10 min read

What You'll Learn

  • Distinguish one binary record per trial from a grouped success–failure response.
  • Derive when the two input formats give equivalent likelihoods.
  • Check which records can be safely combined while preserving predictors and random effects.
  • Calculate and verify the total number of trials represented by either format.
  • Recognize denominator, weighting, and aggregation errors in software inputs.
  • Interpret why equivalent inputs can produce different reported likelihood constants.

Why Input Format Matters

A binomial GLMM can be supplied with one row for each trial, where the response is 0 or 1, or with one row for a set of trials, where the response records the number of successes and failures. These formats can represent the same data and model, but only when the records combined into a group have the same modeled success probability conditional on the random effects. Grouping is therefore not just a data-storage decision: it must preserve the model’s predictors, clustering, and trial denominator.

The practical audit is simple to state: determine how many trials each software row represents, then add those numbers. For individual binary rows, the denominator is the number of rows. For grouped rows, it is the sum of the success and failure counts. A table with six grouped rows may represent hundreds of trials; treating the number of rows as the denominator changes the meaning of the analysis.

Definition: An individual binomial input has one response \(Y_k\in\{0,1\}\) per trial, with 1 denoting success and 0 denoting failure. A grouped binomial input has, for group \(g\), a success count \(S_g\), a failure count \(F_g\), and a trial count \(m_g=S_g+F_g\). It represents \(S_g\) successes in \(m_g\) trials, not one trial with a fractional response.

When the Two Representations Are Equivalent

Suppose that, conditional on the random effects, each trial in group \(g\) has the same probability \(p_g\) of success, and trials are conditionally independent. If the group contains \(m_g\) binary outcomes \(Y_{g1},\ldots,Y_{gm_g}\), then \(S_g=\sum_{k=1}^{m_g}Y_{gk}\) has a binomial distribution with \(m_g\) trials and probability \(p_g\). In a GLMM, \(p_g\) is determined by the fixed predictors and the random effects for the trial’s cluster.

For example, a random-intercept logistic model might specify \(\operatorname{logit}(p_{g})=\mathbf{x}_{g}^{T}\boldsymbol{\beta}+b_{j(g)}\), where \(\mathbf{x}_{g}\) is the fixed-effect design, \(\boldsymbol{\beta}\) is the fixed-effect coefficient vector, and \(b_{j(g)}\) is the random intercept for cluster \(j(g)\). To group trials, their fixed-effect design and their random-effect design must be identical. In particular, trials assigned to different clinics cannot be combined into one row if the model includes a clinic random intercept: their conditional probabilities depend on different random effects.

The equivalence also requires the binomial sampling assumptions: a known number of trials, a binary success/failure outcome for each trial, and conditional independence with a common success probability within each grouped row. A grouped input does not repair violations of those assumptions. If covariates vary among trials, they usually imply different probabilities and the trials must remain separate or be grouped only into cells with the same modeled design.

Key condition: Aggregate trials only within cells that have the same fixed-effect predictors and the same random-effect membership and design. Then the grouped response is \(S_g\) successes and \(F_g=m_g-S_g\) failures. The grouping must retain every distinction that the GLMM uses to assign a conditional probability.

Why Grouping Preserves the Model Fit

For a fixed group, the individual Bernoulli likelihood conditional on the random effects is the product of the probabilities for its observed outcomes. Write \(s_g\) for the number of observed successes and \(m_g-s_g\) for the number of failures. Since every trial in the group has the same conditional probability \(p_g\), the product is

$$ \prod_{k=1}^{m_g}p_g^{Y_{gk}}(1-p_g)^{1-Y_{gk}} =p_g^{s_g}(1-p_g)^{m_g-s_g}. $$

The grouped binomial probability for the count \(S_g=s_g\) is

$$ P(S_g=s_g\mid b) ={m_g\choose s_g}p_g^{s_g}(1-p_g)^{m_g-s_g}. $$

The extra factor \({m_g\choose s_g}\) counts how many different arrangements of the same success and failure counts are possible. It depends on the observed counts, not on the model parameters. Thus, for fixed data and valid groups, the grouped and individual likelihoods have the same parameter-dependent part. Multiplying across groups and integrating over the same random-effects distribution preserves that relationship: the marginal likelihoods differ only by the product of the binomial coefficients, a constant with respect to the model parameters. Consequently, the fitted parameter values are equivalent when the model and data are otherwise identical.

The reported log-likelihood can nevertheless differ by that constant, and software may use different conventions for a binomial response. Treat a difference in reported likelihood or deviance cautiously when comparing the two encodings; verify the software’s response convention before concluding that the fitted model changed.

Worked Example: Converting Binary Outcomes to One Group

Consider eight hypothetical trials with outcomes \(1,0,1,1,0,0,1,0\). Suppose all eight have the same fixed predictors and random-effect design. Convert them to grouped input and verify the denominator.

There are four successes and four failures, so \(S_1=4\), \(F_1=4\), and \(m_1=S_1+F_1=8\). The individual representation has eight rows, and the grouped representation has one row representing eight trials. Both therefore have denominator 8.

At a conditional success probability \(p_1=0.6\), the individual likelihood contribution for this particular ordering is \(0.6^4(0.4)^4=0.003318\) (rounded). The grouped binomial probability is \({8\choose4}0.6^4(0.4)^4=70(0.003318)=0.2322\) (rounded). The grouped probability is larger because it includes all 70 possible orderings with four successes and four failures. The factor 70 does not depend on \(p_1\), so it does not change the parameter value that maximizes the likelihood.

Worked Example: Preserving Clinic Effects While Grouping

Suppose a hypothetical study records a binary response for patients in three clinics, under control or treatment. The model includes a fixed treatment effect and a random intercept for clinic. Assume that within each clinic-by-treatment cell, patients share the same other fixed predictors. The counts are:

ClinicArmSuccessesFailuresTrials
AControl235
ATreatment426
BControl134
BTreatment325
CControl336
CTreatment527

The grouped input has six rows, but the denominator is the sum of the trial counts: \(5+6+4+5+6+7=33\). The total number of successes is \(2+4+1+3+3+5=18\), and failures total \(3+2+3+2+3+2=15\), so \(18+15=33\) confirms the denominator. By arm, control represents \(2+1+3=6\) successes in \(5+4+6=15\) trials; treatment represents \(4+3+5=12\) successes in \(6+5+7=18\) trials.

Combining patients within each clinic-by-arm cell preserves the clinic random intercept and treatment predictor. Combining all control patients into one row and all treatment patients into another would not: each resulting row would mix three clinic random effects. The grouped response should retain the clinic identifier, for example as a success–failure pair in each clinic-by-arm row. In software that accepts a two-column binomial response, the response columns are success count and failure count; the model formula must still include the clinic grouping term.

The aggregation is justified only because the patients within each cell have identical model design. If age or another modeled predictor varied among patients, the cell counts alone would discard that information. The rows would need to be further stratified by the relevant predictor pattern, or retained at the individual level.

Proportions, Trial Weights, and Denominator Audits

Some software accepts a proportion \(S_g/m_g\) as the response together with a trial weight \(m_g\). This can encode the same grouped binomial information, but only if the software defines the weight as the number of binomial trials for that row. A proportion without its trial count is incomplete: a response of 0.5 could mean one success in two trials or 500 successes in 1,000 trials, which carry different amounts of information.

Worked Example: Checking Proportions and Trial Weights

Four hypothetical groups have success/failure counts \(7/3\), \(9/6\), \(4/4\), and \(12/8\). Show the equivalent proportions and weights, then verify the total denominator.

The trial counts are \(10,15,8,\) and \(20\). The corresponding proportions are \(7/10=0.70\), \(9/15=0.60\), \(4/8=0.50\), and \(12/20=0.60\). With trial-count weights, these proportions represent \(7+9+4+12=32\) successes among \(10+15+8+20=53\) trials. The failures sum to \(3+6+4+8=21\), and \(32+21=53\) verifies the denominator.

The four proportions alone do not have denominator four for the underlying binomial analysis. Four is the number of grouped rows; 53 is the number of trials. In software, confirm that the weight is being used as a binomial trial count, not as an unrelated analytic or sampling weight. If the software accepts success and failure counts directly, that representation makes the trial count explicit.

Practical Choices and Failure Modes

Choose individual rows when trial-level predictors differ, when the model needs individual-level random-effect membership, or when the trial-level data are needed for later checks. Choose grouped counts when the trials are genuinely exchangeable within the relevant modeled cells and a compact representation is convenient. Neither format is inherently more statistically valid; the decisive issue is whether it encodes the same response process and design.

Input formatWhat one row representsDenominator checkCommon risk
Individual binaryOne trial with response 0 or 1Count the rows representing trialsDuplicated or omitted trial records
Grouped successes and failures\(S_g\) successes and \(F_g\) failuresSum \(S_g+F_g\) over rowsCombining unlike predictor or random-effect patterns
Proportion with trial weightsOne group proportion with its trial countSum the trial-count weightsOmitting weights or using the wrong weight meaning

A useful audit follows the data from source to fitted model. Count the original eligible trials; check that each individual outcome contributes once, or that grouped successes plus failures reconstruct the same count; and check totals by relevant cluster and predictor cells. For example, the row count of a grouped data frame is not a valid trial denominator unless each row really represents one trial. Also confirm the software’s response syntax and weight semantics: conventions differ across programs and functions.

Several warning signs suggest the encoding is wrong. A total count that disagrees with the source data indicates missing, duplicated, or misclassified trials. Grouped rows that combine clinics despite a clinic random effect discard the intended cluster structure. A proportion response with no trial count does not specify how many trials contributed. And if trial-level predictors vary within a grouped row, a single fitted probability cannot represent all those trials under the stated model.

The main alternative is not a different statistical method but a different representation of the same binomial data. Individual records make the row-to-trial mapping transparent and accommodate varying covariates. Grouped counts can reduce data volume and clearly display cell totals, but they require a careful definition of each cell. If the two encodings do not yield equivalent estimates under the same model, first inspect the response coding, grouping boundaries, weights, and random-effect structure rather than assuming that aggregation itself changes the scientific result.

Common Mistake

Wrong reasoning: “There are six rows in my grouped dataset, so the analysis has six trials.” This confuses the number of stored groups with the number of Bernoulli trials represented.

Correction: For grouped counts, calculate \(m_g=S_g+F_g\) for every row and sum those trial counts. In the clinic example, six rows represent 33 trials. Use that denominator when describing the analyzed sample, and verify it against the underlying individual records.

Key takeaway: Individual and grouped binomial inputs can encode the same GLMM when grouped trials share the same conditional probability structure. Preserve the fixed and random predictors, use the software’s correct binomial response convention, and verify that the denominator is the total number of trials—not automatically the number of rows.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. Three grouped rows contain \(3/2\), \(2/5\), and \(4/4\) successes/failures. What is the total number of trials and the number of successes?
  2. A model has a clinic random intercept. Can counts from two clinics be combined into one grouped row if treatment is the same? Why or why not?
  3. A group has a 0.25 success proportion from 12 trials. What success and failure counts does it represent?
  4. Patients in one treatment group have different ages, and age is a fixed predictor. Is it valid to combine all their outcomes into one treatment-only grouped row?

Solutions. (1) The trial counts are \(3+2=5\), \(2+5=7\), and \(4+4=8\), giving \(5+7+8=20\) trials; successes total \(3+2+4=9\). (2) No. The two clinics have different random intercepts, so their conditional probabilities are not represented by one shared clinic effect; keep separate clinic rows. (3) \(0.25(12)=3\) successes and \(12-3=9\) failures. (4) No. Different ages imply different fixed-effect designs and generally different conditional probabilities. Retain individual records or group only trials with the same modeled age and other design information.

Clinical Biostats