Tutorials › Generalized Linear Mixed Models (GLMM) › Why Binary GLMM Shrinkage Is Nonlinear

Prediction of Random Effects · Tutorial 455 of 698

Why Binary GLMM Shrinkage Is Nonlinear

You will derive and interpret the logistic random-intercept score equation, verify its unique conditional mode, and see how outcomes and fitted probabilities determine nonlinear shrinkage.

Advanced 11 min read

What You'll Learn

  • Write the conditional log posterior for a binary random-intercept model.
  • Derive the score equation and establish that it has a unique solution.
  • Explain why the group effect is not a fixed fraction of an unpenalized estimate.
  • Evaluate how group outcomes and baseline fitted probabilities change shrinkage.
  • Check a computed conditional mode using its score and curvature.
  • Recognize sparse-group and separation cases where the mode remains finite.

Why Binary Group Effects Do Not Shrink by a Fixed Weight

In a Gaussian random-intercept model, a group effect can often be written as a fixed fraction of a group-specific estimate. That simple linear rule does not carry over to a binary GLMM. The likelihood for binary outcomes is curved on the log-odds scale, and its slope depends on the fitted probabilities. Consequently, the amount by which a group effect is pulled toward zero depends on the group’s observed outcomes and its covariates, not just on group size and the random-effect variance.

The central calculation is the score equation for the conditional mode. It balances the group’s evidence in the binary likelihood against the normal random-effects penalty. Deriving that equation also gives a direct way to check a proposed prediction and to understand why groups with identical sizes can have different amounts of shrinkage.

Model and Conditional-Mode Equation

For group \(j\), let \(y_{ij}\in\{0,1\}\) be the binary outcome for observation \(i\), where \(i=1,\ldots,n_j\). Suppose outcomes are conditionally independent given the group effect and covariates, with \(y_{ij}\mid b_j\sim\operatorname{Bernoulli}(p_{ij})\), and \(\operatorname{logit}(p_{ij})=x_{ij}^{T}\beta+b_j\). Here \(x_{ij}^{T}\beta\) is the fixed-effects linear predictor and \(b_j\) is the group-specific random intercept. The random-effects assumption is \(b_j\sim N(0,\tau^2)\), independently across groups. For the derivation below, treat \(\beta\) and \(\tau^2>0\) as fixed and known; in applications they are commonly replaced by fitted parameter estimates.

Definition: The conditional mode \(\hat b_j\) is the value of \(b_j\) that maximizes its conditional density given the group’s outcomes and the model parameters. Under the normal random-effects assumption, it maximizes the group’s log likelihood plus the log density penalty \(-b_j^2/(2\tau^2)\), up to constants that do not depend on \(b_j\).

Write \(\eta_{ij}=x_{ij}^{T}\beta\) and \(p_{ij}(b)=\operatorname{logit}^{-1}(\eta_{ij}+b)\), where \(\operatorname{logit}^{-1}(z)=1/(1+\exp(-z))\). Omitting terms that do not depend on \(b\), the conditional log density for group \(j\) is

$$ \ell_j(b)=\sum_{i=1}^{n_j}\left[y_{ij}(\eta_{ij}+b)-\log\{1+\exp(\eta_{ij}+b)\}\right]-\frac{b^2}{2\tau^2}. $$

Differentiating each binary log-likelihood contribution gives \(y_{ij}-p_{ij}(b)\). Differentiating the normal penalty gives \(-b/\tau^2\). Thus the score is

$$ U_j(b)=\frac{d\ell_j(b)}{db} =\sum_{i=1}^{n_j}\{y_{ij}-p_{ij}(b)\}-\frac{b}{\tau^2}. $$

The conditional mode solves \(U_j(\hat b_j)=0\). Equivalently, the sum of the binary residuals at the candidate group effect must equal the penalty contribution \(\hat b_j/\tau^2\). If all observations have the same fixed-effects predictor \(\eta\), and \(k_j=\sum_i y_{ij}\), this simplifies to

$$ k_j-n_j\operatorname{logit}^{-1}(\eta+\hat b_j)-\frac{\hat b_j}{\tau^2}=0. $$

Why the Equation Has One Solution

The score changes monotonically with \(b\). Since the derivative of the logistic probability is \(p_{ij}(b)\{1-p_{ij}(b)\}\), differentiating the score gives

$$ U_j'(b)=-\sum_{i=1}^{n_j}p_{ij}(b)\{1-p_{ij}(b)\}-\frac{1}{\tau^2}<0. $$

The inequality holds because every \(p_{ij}(b)\{1-p_{ij}(b)\}\) is nonnegative and \(1/\tau^2\) is strictly positive. Therefore the conditional log density is strictly concave. Also, as \(b\) tends to \(+\infty\), the term \(-b/\tau^2\) makes the score tend to \(-\infty\); as \(b\) tends to \(-\infty\), it makes the score tend to \(+\infty\). The score is continuous, so it crosses zero, and strict decrease means it crosses exactly once. This establishes a unique finite conditional mode under the stated model.

The equation is generally solved numerically. A Newton step from a current value \(b\) is \(b_{\mathrm{new}}=b-U_j(b)/U_j'(b)\). The derivative is always negative, so a numerical check should confirm that a proposed solution has a score near zero and negative curvature. Simply equating the observed group proportion to a fitted probability ignores the penalty term and is not the conditional-mode equation.

Worked Example: Eight Successes Among Ten Observations

Suppose a hypothetical group has ten binary outcomes, eight equal to 1, and all ten observations have fixed-effects predictor \(\eta_{ij}=0\). Let \(\tau^2=0.25\), so the prior precision is \(1/\tau^2=4\). The score equation is

$$ U_j(b)=8-10\operatorname{logit}^{-1}(b)-4b=0. $$

At \(b=0.4647\), the fitted probability is \(\operatorname{logit}^{-1}(0.4647)\approx0.6141\). Substitution using this rounded probability gives \(U_j(0.4647)\approx8-10(0.6141)-4(0.4647)=8-6.141-1.8588=0.0002\). This is close to zero, so the conditional mode is approximately \(\hat b_j=0.4647\) log-odds units. The data favor a positive group effect, but the estimate is finite and pulled toward zero by the normal penalty.

Outcomes and Fitted Probabilities Determine the Pull

At zero, the score is \(U_j(0)=\sum_i\{y_{ij}-p_{ij}(0)\}\), because the penalty contribution is zero there. This is the group’s total residual relative to the fixed-effects probabilities. A positive value pushes the mode above zero; a negative value pushes it below zero. But the score at zero alone does not determine the final estimate: as \(b\) changes, all fitted probabilities change, and the residuals are recalculated. Meanwhile, the penalty grows linearly in \(b\).

This dependence is more than a matter of the group’s number of successes. If observations have different fixed-effects predictors, two groups with the same outcomes and group size can have different residual sums and different conditional modes. Even with a common predictor, the fitted probability at the mode depends on the balance of outcomes and on the random-effect variance.

Worked Example: The Same Outcomes, Different Baseline Probabilities

Consider two hypothetical groups, each with four outcomes and two successes. Set \(\tau^2=1\). In Group A, all four baseline probabilities at \(b=0\) are \(0.2\), so the common fixed-effects predictor is \(\eta=\log(0.2/0.8)\approx-1.3863\). The score is \(U_A(b)=2-4\operatorname{logit}^{-1}(-1.3863+b)-b\). At \(b=0.679\), the fitted probability is approximately \(\operatorname{logit}^{-1}(-0.7073)=0.3302\), and \(U_A(0.679)\approx2-4(0.3302)-0.679=2-1.3208-0.679=0.0002\). Thus \(\hat b_A\approx0.679\).

In Group B, keep the same four outcomes and variance, but let all baseline probabilities be \(0.8\), giving \(\eta\approx1.3863\). At \(b=-0.679\), the fitted probability is approximately \(\operatorname{logit}^{-1}(0.7073)=0.6698\), and \(U_B(-0.679)\approx2-4(0.6698)-(-0.679)=2-2.6792+0.679=-0.0002\). Thus \(\hat b_B\approx-0.679\). The groups have equal sizes and equal success counts, yet their estimated effects have opposite signs because their baseline fitted probabilities differ.

Local Curvature and the Meaning of Nonlinear Shrinkage

The score equation shows why there is no universal shrinkage fraction. In the Gaussian random-intercept case, the likelihood score is linear in the group effect, so combining it with a linear normal penalty leads to a linear weighted average. Here, changing \(b\) changes each \(p_{ij}(b)\), and therefore changes the likelihood slope. The relevant likelihood curvature is \(\sum_i p_{ij}(b)\{1-p_{ij}(b)\}\), which depends on the fitted probabilities and is largest near probability \(0.5\), decreasing near 0 and 1.

A local approximation makes the role of curvature explicit. Taylor-expand the score around zero: \(U_j(b)\approx U_j(0)+U_j'(0)b\). Solving this linear approximation for its zero gives

$$ \hat b_j\ \approx\ \frac{\sum_i\{y_{ij}-p_{ij}(0)\}} {\sum_i p_{ij}(0)\{1-p_{ij}(0)\}+1/\tau^2}. $$

This is only a local approximation, not a general closed-form solution. Its numerator is the residual evidence at zero; its denominator combines the likelihood information at zero with the prior precision. Since the probabilities in the denominator change as the group effect moves away from zero, the exact balance is nonlinear.

Worked Example: A Group With All Successes Still Has a Finite Mode

Suppose a hypothetical group has three successes out of three, with \(\eta_{ij}=0\) for each observation and \(\tau^2=0.25\). Its score is \(U_j(b)=3-3\operatorname{logit}^{-1}(b)-4b\). At \(b=0.316\), \(\operatorname{logit}^{-1}(0.316)\approx0.5783\), so \(U_j(0.316)\approx3-3(0.5783)-4(0.316)=3-1.7349-1.264=0.0011\). The conditional mode is therefore approximately \(0.316\) log-odds units.

Without the normal penalty, the group-specific logistic likelihood would increase as its intercept tends to \(+\infty\), because every outcome is a success. The penalty makes the conditional log density strictly concave and gives a finite mode. The result remains a model-based prediction, not a claim that three successes establish a precisely known group effect.

Numerical Checks, Alternatives, and Limitations

When computing a conditional mode, evaluate the score at the reported value using unrounded probabilities where possible. A score close to zero checks the first-order condition; a negative second derivative checks that the point is a maximum. Also check that the values of \(\eta_{ij}\), \(\tau^2\), and the outcomes used in the score match the stated model. With extreme fitted probabilities or very sparse groups, rounding can make a small score appear larger or smaller than it is.

The conditional mode is not the unpenalized group-specific logistic estimate: it includes the normal penalty and is pulled toward zero. Nor is it generally a fixed fraction of that estimate. A Gaussian random-intercept predictor provides a useful comparison because its linear likelihood yields a fixed shrinkage weight under its assumptions; that weight should not be transferred to a binary GLMM. The conditional mode is also distinct from the conditional posterior mean. They are different summaries of the conditional distribution, and in a binary model there is no general reason they must coincide.

The derivation assumes the logistic link, conditionally independent Bernoulli observations, a normal random intercept with positive variance, and fixed covariates and parameters during the calculation. If the assumed mean structure or conditional independence is inappropriate, a numerically accurate root does not repair the model. In practice, the fitted fixed effects and variance are themselves estimated; treating them as fixed here isolates the nonlinear score mechanism rather than representing all sources of uncertainty in a prediction.

Common pitfall: “There are ten observations, so the binary group effect must be the Gaussian group estimate multiplied by a single weight depending only on ten and \(\tau^2\).” This is wrong because the binary likelihood curvature is \(\sum_i p_{ij}(b)\{1-p_{ij}(b)\}\), which changes with outcomes, covariates, and the effect being evaluated. Use the logistic score equation and solve for its root instead.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For one group, write the score equation when there are \(n_j\) observations, \(k_j\) successes, a common fixed-effects predictor \(\eta\), and random-effect variance \(\tau^2\).
  2. Why does the conditional-mode score have exactly one zero when \(\tau^2>0\)?
  3. At \(b=0\), a group has three successes and four fitted probabilities of \(0.5\). What is its score at zero, and in which direction does the mode move?
  4. Why can a group with all outcomes equal to 1 still have a finite conditional mode?

Solutions. (1) The equation is \(k_j-n_j\operatorname{logit}^{-1}(\eta+\hat b_j)-\hat b_j/\tau^2=0\). (2) Its derivative is \(-\sum_i p_{ij}(b)\{1-p_{ij}(b)\}-1/\tau^2<0\), while the score tends to \(+\infty\) and \(-\infty\) at the negative and positive extremes, respectively; continuity and strict decrease give exactly one zero. (3) The score is \(3-4(0.5)=1\), which is positive, so its zero lies above zero. (4) The normal penalty contributes \(-b/\tau^2\); combined with the binary likelihood, it produces a strictly concave conditional log density whose score has a finite zero.

Clinical Biostats