Tutorials › Generalized Linear Mixed Models (GLMM) › Aggregation Of Binary Records Under Shared Covariates

Responses: Binary, Count, Ordinal, Overdispersed · Tutorial 70 of 698

Aggregation Of Binary Records Under Shared Covariates

You will learn the conditions that make grouped success counts likelihood-equivalent to individual binary records in a GLMM, and how to check the equivalence.

Intermediate 11 min read

What You'll Learn

  • Identify when records have the same conditional success probability.
  • Derive the likelihood relationship between an ordered binary pattern and its success count.
  • Explain why aggregation preserves likelihood-based inference in a GLMM.
  • Distinguish conditional binomial likelihoods from marginal mixtures after random effects are integrated out.
  • Check group definitions, denominators, and random-effect structure before aggregating.

When Aggregation Preserves the Relevant Information

A binary response may be stored as one zero-or-one observation per trial, or as a success count with a number of eligible trials. These formats can encode the same information for a binomial response model, but only when the records being combined share the same model-based success probability. In a generalized linear mixed model (GLMM), that probability is conditional on the random effects as well as on the covariates.

The key distinction is between the probability of one particular ordered pattern of outcomes and the probability of observing a count of successes in any order. The latter includes a combinatorial factor for all the patterns with that count. This factor matters for the probability assigned to the data, but it does not depend on the model parameters. Therefore, under the required conditions, the two data representations give the same likelihood information about those parameters.

Definition: Suppose \(m\) binary records are conditionally independent and have the same success probability \(p(b)\), conditional on covariates and random effects \(b\). Their success count \(S=\sum_{i=1}^{m}Y_i\) is a conditionally binomial response: \(S\mid b\sim\operatorname{Binomial}(m,p(b))\). Replacing the records by \((S,m)\) is likelihood-equivalent for model parameters when the individual and grouped likelihoods differ only by a factor that does not involve those parameters.

The Likelihood Relationship

For a cluster \(j\), write the conditional mean of binary record \(i\) as \(\operatorname{logit}\{p_{ij}(b_j)\}=\mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta}+\mathbf{z}_{ij}^{\mathsf T}b_j\). Here \(\mathbf{x}_{ij}\) is the fixed-effect design vector, \(\mathbf{z}_{ij}\) is the random-effect design vector, \(\boldsymbol{\beta}\) is the fixed-effect coefficient vector, and \(b_j\) is the cluster’s random-effect vector. The records can be pooled into one count only if their success probabilities are the same for every value of the model parameters and random effects under consideration. A practical sufficient condition is that they share the same covariates, offset if present, cluster, and random-effect design.

Let \(y_i\in\{0,1\}\), \(s=\sum_i y_i\), and suppose all \(m\) records have conditional probability \(p(b)\). Conditional independence gives the likelihood of the observed individual pattern. The grouped count likelihood includes all possible placements of the \(s\) successes:

$$ L_{\mathrm{individual}}(b)=p(b)^s\{1-p(b)\}^{m-s}, \qquad L_{\mathrm{count}}(b)=\binom{m}{s}p(b)^s\{1-p(b)\}^{m-s}. $$

There are \(\binom{m}{s}\) distinct ordered binary patterns with \(s\) successes, and each has the same conditional probability. Thus the second likelihood is the probability of the count, not the probability of one particular sequence. For fixed observed data, \(\binom{m}{s}\) does not depend on \(\boldsymbol{\beta}\), \(b\), or random-effect distribution parameters. The log likelihoods differ by the constant \(\log\binom{m}{s}\); their parameter-dependent parts are identical.

Justification after random effects are integrated out: If \(b\) has density \(f(b;\boldsymbol{\psi})\), the marginal likelihood for the observed individual pattern is the integral of its conditional likelihood against that density. The grouped likelihood has the same integrand multiplied by \(\binom{m}{s}\). Since this factor does not depend on \(b\), it can be taken outside the integral: $$ L_{\mathrm{count}}(\boldsymbol{\beta},\boldsymbol{\psi}) =\binom{m}{s}L_{\mathrm{individual}}(\boldsymbol{\beta},\boldsymbol{\psi}). $$ Therefore, aggregation preserves the likelihood information about fixed effects and random-effect distribution parameters in this setting.

This does not mean that a count from a GLMM is generally an ordinary binomial random variable after random effects are integrated out. Conditional on \(b_j\), the count is binomial; marginally, its distribution is a mixture over \(b_j\). Nor does the equivalence say that a count and a particular ordered pattern have the same probability. They are different data events, linked by the combinatorial factor.

Worked Example: Five Records With One Shared Conditional Probability

Consider a hypothetical cluster with five binary records. Suppose every record has the same covariate and random-effect design, the same cluster random intercept is fixed at \(b_j=0.3\) for this conditional calculation, and the linear predictor is \(\eta=-0.2+0.4+0.3=0.5\). The observed pattern is \(1,1,0,1,0\), so there are \(s=3\) successes.

The common conditional success probability is \(p=\operatorname{logit}^{-1}(0.5)=1/(1+\exp(-0.5))\approx0.622459\), with failure probability \(1-p\approx0.377541\). Conditional independence holds by the model, and the identical design gives every record this same probability.

The likelihood of this particular ordered pattern is \(p^3(1-p)^2\). Using the displayed probabilities, \((0.622459)^3(0.377541)^2\approx0.03438\).

The grouped observation is \(S=3\) successes out of \(m=5\) trials. Its conditional probability is \(\binom{5}{3}p^3(1-p)^2=10(0.034376\ldots)\approx0.3438\). This is ten times the probability of the displayed pattern because there are ten patterns with three successes. The factor 10 is fixed by the observed count, so it changes neither the parameter-dependent likelihood nor likelihood-based estimates.

Several Homogeneous Groups in One Cluster

A cluster can contain more than one set of records eligible for aggregation. Each set must be homogeneous in its conditional probability. Different sets may have different covariates and hence different probabilities, while still sharing the same cluster random effect. Their conditional contributions multiply given that random effect. If the random effect is later integrated out, the product must be integrated jointly; one must not treat the groups as having independently drawn random effects unless the model specifies that.

Worked Example: Aggregating Two Covariate Strata

Suppose, hypothetically, that a cluster has two internally homogeneous sets of records. Conditional on the cluster random effect, the first set has \(m_1=4\), \(s_1=1\), and \(p_1=0.5\); the second has \(m_2=3\), \(s_2=2\), and \(p_2=0.75\). These probabilities could arise from two different fixed-effect linear predictors at the same specified random effect. Assume conditional independence across all seven records.

For the first set, the grouped contribution is \(\binom{4}{1}(0.5)^1(0.5)^3=4(0.0625)=0.25\). For the second, it is \(\binom{3}{2}(0.75)^2(0.25)^1=3(0.140625)=0.421875\). Thus the conditional joint likelihood of the two counts is \(0.25(0.421875)=0.10546875\), or approximately \(0.1055\).

For comparison, one particular pattern in the first set has likelihood \(0.0625\), and one particular pattern in the second has likelihood \(0.140625\). Their joint likelihood is \(0.0625(0.140625)=0.0087890625\). There are \(\binom{4}{1}\binom{3}{2}=12\) patterns with these two counts, and \(12(0.0087890625)=0.10546875\). The count representation therefore preserves the parameter-dependent information while recording the pattern multiplicity.

What Must Match Before Pooling

The relevant sameness is model-based, not merely that records appear similar in a data table. Before aggregating, check the response definition, eligibility, and model design. In particular, records placed in one count must have:

  • the same definition of a success and the same type of eligible trial;
  • the same fixed-effect covariate values and offset, if any;
  • the same cluster membership and random-effect design, so the same latent effects enter their linear predictors;
  • conditional independence under the specified response model.

The count’s denominator must be the number of eligible records represented by that count, not a larger number of people or opportunities that were not observed or eligible. Check that the grouped success count and failure count are nonnegative integers and sum to the denominator. If some records are missing, aggregation must represent only the records included under the model and its missing-data assumptions.

When all records in a homogeneous set have a common linear predictor \(\eta\), the individual log likelihood is \(s\log p+(m-s)\log(1-p)\). Differentiating with respect to \(\eta\), using \(dp/d\eta=p(1-p)\), gives \(\partial\ell/\partial\eta=s-mp\). The grouped log likelihood adds \(\log\binom{m}{s}\), whose derivative is zero, so it has the same score. This shows directly why the two forms lead to the same likelihood-based parameter information.

Worked Example: Checking a Grouped Contribution and Its Score

Suppose four hypothetical records share the same design and have conditional probability \(p=\operatorname{logit}^{-1}(-0.2)\approx0.450166\). One record succeeds and three fail. Conditional independence and the common design justify treating the count as binomial with \(m=4\) and \(s=1\).

The likelihood of one particular pattern with one success is \(p(1-p)^3\approx(0.450166)(0.549834)^3\approx0.07483\). The probability of the count is \(\binom{4}{1}p(1-p)^3\approx4(0.074828\ldots)=0.2993\). The difference is the four possible locations of the single success.

At this linear predictor, the score with respect to \(\eta\) is \(s-mp=1-4(0.450166)\approx-0.8007\). The binomial coefficient contributes no derivative, so calculating the score from the individual records or from the grouped count gives the same result.

Choosing a Representation and Diagnosing Errors

Individual Bernoulli records are often easiest to audit because each outcome remains visible. Grouped binomial counts can be more compact when many records genuinely share the same conditional probability. If both forms encode the same observations and model, likelihood-based estimates should agree, apart from numerical optimization tolerance. A discrepancy is a useful warning to check denominators, success coding, covariate values, offsets, and random-effect design.

The grouped likelihood includes \(\binom{m}{s}\) when it is interpreted as a probability for the observed count. Omitting that coefficient does not change parameter estimates for fixed observed data, because it is constant in the parameters; however, it does not give the normalized probability of the count. Keep the coefficient when reporting count probabilities or constructing a likelihood on the count’s probability scale. Comparisons between models should use a consistent representation of the same data.

A frequent error is to aggregate all records in a cluster because they share the same random intercept. A shared intercept alone does not guarantee identical probabilities: fixed covariates or random-slope covariates may differ. The correction is to compare the full conditional linear predictors, including both fixed- and random-effect terms. Pool only records whose predictors are identical for all relevant parameter values. If this condition fails, the simple binomial count likelihood derived here does not represent the records’ likelihood.

Key takeaway: Aggregation is safe for likelihood-based inference when records are conditionally independent and have a common conditional success probability. The grouped count likelihood is the individual-pattern likelihood multiplied by the number of patterns represented by that count. In a GLMM, preserve the conditioning on shared random effects.

Check Your Understanding

Answer each question, then check the solutions below.

  1. Six conditionally independent records have a common probability \(p\), and two are successes. What factor relates the count likelihood to the likelihood of one specified pattern?
  2. Why is a shared cluster random intercept by itself not always enough to justify pooling records?
  3. In a GLMM, is a count necessarily binomial after the random effect is integrated out? Explain.
  4. Four records have a common conditional probability \(p=0.2\), and one success is observed. What are the likelihoods of one specified pattern and of the count?

Solutions. (1) The factor is \(\binom{6}{2}=15\), the number of ways to place two successes among six records. (2) Fixed covariates, offsets, or random-slope design values may differ, producing different conditional probabilities even with the same intercept. (3) No. It is binomial conditional on the random effect; integrating over a random effect generally produces a mixture of binomial distributions. (4) One specified pattern has likelihood \(0.2(0.8)^3=0.1024\). The count likelihood is \(\binom{4}{1}(0.2)(0.8)^3=4(0.1024)=0.4096\).

Clinical Biostats