From Group Outcomes to a Conditional Prediction
A binary random-intercept GLMM represents group differences on the log-odds scale. Once the model has been fitted, a practical task is to predict the latent intercept for a particular observed group from that group’s successes and failures. The prediction balances two sources of information: the group’s observed outcomes and the model’s Gaussian distribution for group effects.
This tutorial works with one binary outcome and an intercept-only group effect. The fitted population intercept and random-effect variance are treated as fixed inputs to the calculation. The resulting prediction is conditional on those fitted values; it does not include uncertainty from estimating them.
The conditional mode is the value of \(b_j\) that maximizes the conditional density of the random effect given the observed group outcomes, using the fitted model parameters. Equivalently, it maximizes the group’s binomial likelihood multiplied by the Gaussian random-effect density. It is not simply the logit of the group’s observed proportion: the Gaussian density pulls the prediction toward zero on the random-effect scale.
Score, Curvature, and the Numerical Update
Suppress the group subscript temporarily and write \(y=y_j\), \(m=m_j\), and \(b=b_j\). With \(p(b)=\operatorname{logit}^{-1}(\hat\beta_0+b)\), the log of the conditional density, up to terms that do not depend on \(b\), is
The first two terms are the binomial log likelihood, and the last term is the log Gaussian density, apart from constants. Differentiating gives the score; differentiating once more gives the curvature:
A conditional mode solves \(U(b)=0\). Since \(m p(b)\{1-p(b)\}\geq 0\) and \(\hat\tau^2>0\), the second derivative is strictly negative. Thus \(\ell(b)\) is strictly concave: it has at most one mode, and any root of the score is the unique maximizer. The score decreases as \(b\) increases, which also gives a useful numerical check.
Newton’s method uses the score and the negative second derivative, called the observed curvature here:
The Gaussian penalty ensures \(J(b)>0\). At a converged mode, a local quadratic approximation to \(\ell(b)\) has curvature \(J(\hat b_j)\). Matching that quadratic to a normal log density yields the local approximation \(\operatorname{Var}(b_j\mid y_j,f_j,\hat\beta_0,\hat\tau^2)\approx 1/J(\hat b_j)\). Its square root is an approximate conditional standard error. This is a local approximation, not a guarantee that the whole conditional distribution is normal.
Worked Example: Eight Successes and Twelve Failures
Suppose a hypothetical group has \(y=8\) successes and \(f=12\) failures, so \(m=20\). Let the fitted intercept be \(\hat\beta_0=-1.00\) and the estimated random-intercept variance be \(\hat\tau^2=0.6400\). Start Newton’s method at \(b_0=0.400\).
At \(b_0\), the linear predictor is \(-1.00+0.400=-0.600\), so \(p(b_0)=1/(1+\exp(0.600))\approx0.3543\). The score is \(U(b_0)=8-20(0.3543437)-0.400/0.6400\approx0.2881\).
The Newton update is therefore \(b_1=0.400+0.2881/6.138\approx0.4469\). At this updated value, \(p(b_1)\approx0.3651\). The score is then close to zero: \(8-20(0.3651)-0.4469/0.6400\approx-0.0003\). This indicates that \(0.4469\) is already a close numerical approximation to the conditional mode.
Using the displayed probability to calculate the local curvature gives \(J(\hat b_j)\approx20(0.3651)(1-0.3651)+1/0.6400\approx4.636+1.563=6.199\), or \(6.19854\) before rounding. Hence the approximate conditional standard error is \(1/\sqrt{6.19854}\approx0.4017\) on the log-odds scale. The group’s fitted conditional probability is about \(0.3651\); it is not a population-averaged probability.
Two Further Numerical Cases
Worked Example: One Success in a Group of Fifteen
Consider a hypothetical group with \(y=1\) success and \(f=14\) failures. Take \(\hat\beta_0=-1.640\), \(\hat\tau^2=0.6400\), and candidate mode \(b=-0.433\). This candidate has linear predictor \(-1.640-0.433=-2.073\), giving \(p\approx0.1117\) (unrounded \(p\approx0.1117489\)).
Check the score at this candidate. Using the unrounded probability, \(U(-0.433)=1-15(0.1117489)-(-0.433)/0.6400\approx0.0003\). The score is nearly zero, so the candidate is a close approximation to the unique conditional mode.
The curvature and its inverse-square-root standard error are \(J(\hat b_j)\approx15(0.1117489)(0.8882511)+1/0.6400\approx3.0514\), and \(SE\approx1/\sqrt{3.0514}\approx0.5725\). The mode is approximately \(-0.433\) log-odds units, with a local approximate conditional standard error of \(0.5725\) log-odds units. The fitted conditional success probability is about \(0.1117\).
The group’s observed proportion is \(1/15\approx0.0667\), smaller than its fitted conditional probability. The prediction is not required to equal the observed proportion: the model combines the group’s data with the random-effect distribution and the fitted intercept.
Worked Example: No Successes in a Small Group
Suppose a hypothetical group has \(y=0\) successes and \(f=8\) failures, with \(\hat\beta_0=-1.00\) and \(\hat\tau^2=0.5000\). Starting at \(b_0=0\), the probability is \(p(b_0)=\operatorname{logit}^{-1}(-1)\approx0.2689\). The score and curvature are \(U(b_0)=0-8(0.2689)-0/0.5000\approx-2.152\) and \(J(b_0)=8(0.2689)(0.7311)+2\approx3.573\).
The first update is \(b_1=0-2.152/3.573\approx-0.6022\). At this value, the linear predictor is approximately \(-1.6022\) and \(p(b_1)\approx0.1676\). The score is then about \(0-8(0.1676)-(-0.6022)/0.5000\approx-0.136\), so another update is warranted. It gives a value near \(-0.646\), where \(p\approx0.1616\) and the score is approximately zero.
At the mode, \(J(\hat b_j)\approx8(0.1616)(0.8384)+2\approx3.084\), giving an approximate conditional standard error of \(1/\sqrt{3.084}\approx0.5694\). The conditional probability is below the population-intercept probability \(\operatorname{logit}^{-1}(-1)\approx0.2689\), as expected for a group with no observed successes. It is not zero, because the fitted random-intercept model combines the finite group data with the random-effect distribution.
Interpreting the Prediction and Its Uncertainty
The mode \(\hat b_j\) is a group-specific prediction on the random-intercept, or log-odds, scale. Adding it to the fitted intercept gives the group’s conditional log odds, \(\hat\beta_0+\hat b_j\). Applying the inverse-logit gives the group’s conditional success probability. In contrast, the probability based on \(\hat\beta_0\) alone corresponds to a group with random intercept zero, not an average over the random-effect distribution.
The curvature-based standard error describes local uncertainty about the group effect conditional on the group outcomes and the supplied fitted parameters. It is useful as a compact measure of how sharply peaked the conditional density is near its mode: larger \(J(\hat b_j)\) means smaller local standard error. It does not account for uncertainty in \(\hat\beta_0\) or \(\hat\tau^2\), and it should not automatically be treated as an exact description of the full conditional distribution.
The central alternative summaries answer different questions. The raw group proportion \(y_j/m_j\) describes the observed outcomes but does not incorporate the model’s random-effect distribution. The conditional mode does incorporate that distribution and gives a prediction for the group effect. A posterior mean is another possible summary of the conditional distribution; it need not equal the mode when that distribution is asymmetric. A population-averaged probability instead averages over random effects and targets a different quantity.
Diagnostics, Limitations, and a Common Pitfall
For a numerical result, check that the final score is close to zero, the final curvature is positive, and additional Newton updates change the estimate negligibly. A large score indicates that the current value is not sufficiently close to the mode. The strict concavity shown above means the target mode is unique under this model, but an implementation can still have numerical trouble if updates are not evaluated accurately. Recomputing the score and curvature at the reported estimate is a direct check.
The local normal approximation is most defensible when the conditional log density is reasonably quadratic around its mode. With limited group information or an outcome pattern that concentrates information unevenly, the conditional density may not be well represented by a symmetric normal curve. In those situations, the mode can still be defined, while the curvature-based standard error may be an incomplete summary of uncertainty. The calculation also relies on a correctly specified logistic random-intercept model, a positive fitted variance, and the assumption that the input fitted parameters are being treated as fixed.
- Common mistake: treating the raw logit as the prediction. For a group with both outcome categories observed, one might compute \(\log\{(y_j/m_j)/(1-y_j/m_j)\}\) and report it as \(\hat b_j\). That quantity is a data-only logit, not the conditional mode. It omits both the fitted intercept and the Gaussian penalty; it is also undefined for groups with zero successes or zero failures.
- Correction: maximize the binomial likelihood together with the Gaussian random-effect density, or solve \(U(b)=0\). Then report the group effect on the log-odds scale and, if useful, transform \(\hat\beta_0+\hat b_j\) to a conditional probability.
- Common mistake: interpreting the local standard error as total model uncertainty. The curvature calculation conditions on the supplied fitted parameters. It does not include their estimation uncertainty.
Check Your Understanding
Answer each question, then compare with the brief solutions below.
- A group has \(y_j=5\) successes and \(f_j=7\) failures. What is \(m_j\), and what terms enter its conditional score?
- Why does the conditional log density have a unique mode when \(\hat\tau^2>0\)?
- At a candidate \(b\), suppose \(U(b)=0.24\) and \(J(b)=4.00\). What is the next Newton value?
- In one sentence, state what the curvature-based standard error conditions on and what it omits.
Solutions. (1) \(m_j=5+7=12\), and the score is \(5-12p(b)-b/\hat\tau^2\), where \(p(b)=\operatorname{logit}^{-1}(\hat\beta_0+b)\). (2) The second derivative is \(-m_jp(b)\{1-p(b)\}-1/\hat\tau^2<0\), so the log density is strictly concave and has at most one mode. (3) \(b_{\text{new}}=b+0.24/4.00=b+0.060\). (4) It summarizes local uncertainty in the group effect conditional on the observed group outcomes and supplied fitted parameters; it omits uncertainty in the fitted intercept and variance.