Tutorials › Generalized Linear Mixed Models (GLMM) › Predicting New Combinations in Crossed Models

Crossed and Nested Random Effects · Tutorial 520 of 698

Predicting New Combinations in Crossed Models

Work out predictions for new pairings of crossed factors by identifying which level-specific effects are estimated, which must be averaged over, and how that choice changes the response-scale prediction.

Advanced 12 min read

What You'll Learn

  • Identify whether each crossed-factor level is observed, even when its particular combination with another factor is new.
  • Construct a conditional linear predictor using only the estimated random effects for known levels.
  • Distinguish setting an unseen random effect to zero on the link scale from averaging over its distribution.
  • Compute response-scale means for Poisson log-link models when one or more crossed levels are new.
  • Recognize when an omitted random interaction or weakly informed level makes a prediction unreliable.
  • Separate a predicted mean from a prediction interval for a future response.

Why a new combination is not necessarily a new group

In a crossed-effects model, an observation belongs to levels of more than one factor: for example, a clinician and a case type, or a school and a test item. A future observation may involve a pairing that has never appeared in the data even though both factor levels have appeared many times. That is not the same prediction problem as one involving a genuinely new clinician or a new item. The model can use information about each observed level separately, but it has no directly estimated effect for the unobserved pairing unless such an interaction was included in the model.

The key is to classify each factor level, not just the combination. A level is known here if it was represented in the fitted data. The factor levels may have been observed in different pairings; that still makes their individual random effects estimable to some degree. Conversely, a level that was never represented has no data-based level-specific estimate. How much information a known level contributes depends on its data and the model, not merely on its label.

Model and prediction target

For clarity, consider a GLMM with two crossed random-intercept factors, A and B. The response distribution conditional on the random effects belongs to an exponential-family model, and its conditional mean is related to a linear predictor by a link function. A simple form is:

$$ g\{E(Y_{ij}\mid u_i,v_j)\} = \mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta}+u_i+v_j, \qquad u_i\sim N(0,\sigma_A^2),\quad v_j\sim N(0,\sigma_B^2). $$

Here \(i\) indexes levels of A, \(j\) indexes levels of B, and \(\mathbf{x}_{ij}\) contains the fixed-effect predictors for the observation. The usual model assumptions include the specified conditional response distribution and link, normally distributed mean-zero random effects, and independence between the two random-effect families in this simple model. Observations are conditionally independent given the random effects and fixed predictors, unless the model specifies further dependence. The model may use a more general covariance structure, but predictions must follow the structure actually fitted.

Write \(\hat{\boldsymbol{\beta}}\) for the fitted fixed effects and \(\hat u_i,\hat v_j\) for the fitted conditional estimates of known-level random effects. These are generally shrunken estimates, not the unknown true effects. For an observation at known levels \(i,j\), the plug-in conditional linear predictor is \(\hat\eta_{ij}=\mathbf{x}_{ij}^{\mathsf T}\hat{\boldsymbol{\beta}}+\hat u_i+\hat v_j\), and its conditional mean prediction is \(g^{-1}(\hat\eta_{ij})\).

Definition: A new combination in a crossed model is an A-by-B pairing absent from the fitted data. If both constituent levels have appeared in other pairings, their estimated random effects can contribute to a conditional plug-in prediction. A new combination does not, by itself, imply a new random-effect level.

This rule applies to the random effects the model contains. If the model includes a random A-by-B interaction, an unobserved pairing has no pairing-specific estimate; it must instead be treated as new under that interaction’s distribution. If there is no such interaction, do not invent an additional effect for the pair. With random slopes, use the estimated random-effect vector for each known level multiplied by that observation’s random-effect design vector; a level contributes only through the random-effect terms present in the fitted model.

A levelB levelRandom effects available for a plug-in predictor
KnownKnown, pairing observed\(\hat u_i+\hat v_j\)
KnownKnown, pairing unobserved\(\hat u_i+\hat v_j\); no separate pair effect unless modeled
KnownUnseen\(\hat u_i\); the new B effect is not estimated from these data
UnseenUnseenNo level-specific estimates; use a population prediction or integrate over new effects

Known effects, unseen effects, and response-scale means

For a new level, its random effect has mean zero on the linear-predictor scale under the model. Setting that effect to zero gives a useful link-scale plug-in prediction. It does not generally give the average response for a randomly sampled new level, because applying a nonlinear inverse link after averaging differs from averaging after applying the inverse link.

For example, with a log link and independent normal random intercepts, suppose a prediction has fixed part \(\eta_0\) and includes unseen effects \(U_1,\ldots,U_k\), where \(U_r\sim N(0,\tau_r^2)\). The plug-in value at zero unseen effects is \(\exp(\eta_0)\). The mean response averaged over those new effects is:

$$ E\{\exp(\eta_0+U_1+\cdots+U_k)\} =\exp\left(\eta_0+\frac{1}{2}\sum_{r=1}^{k}\tau_r^2\right). $$

This follows because the sum of independent normal effects is normal with mean zero and variance \(\sum_r\tau_r^2\), and a normal variable \(U\sim N(0,\tau^2)\) satisfies \(E\{\exp(U)\}=\exp(\tau^2/2)\). Thus, averaging over unseen levels raises the mean above the zero-effect plug-in value for a log link. For a known level, a plug-in conditional prediction instead uses its fitted effect; averaging over uncertainty about that effect is a further prediction-inference task. Under a logit link, the corresponding response-scale average generally has no such simple closed form and can be evaluated by numerical integration or simulation.

Worked Example: A New Pairing of Two Known Levels

Suppose a hypothetical Poisson GLMM predicts event counts over one standard observation period. It has a log link, fixed intercept \(\hat\beta_0=\log(4)\), a fixed predictor contribution of \(0.20\), and crossed random intercept estimates \(\hat u_i=0.30\) for clinician A and \(\hat v_j=-0.10\) for case type B. Each level has appeared in the data, but this clinician–case-type pairing has not. Assume the fitted model has no random interaction for the pairing.

The model assumptions for this calculation are the Poisson conditional response distribution, the log link, and the stated additive random-intercept structure. Since both levels are known, both fitted effects contribute:

$$ \hat\eta =\log(4)+0.20+0.30-0.10 =\log(4)+0.40 \approx 1.7863. $$

The conditional mean prediction is:

$$ \widehat{E(Y\mid u_i,v_j)} =\exp(\hat\eta) =4\exp(0.40) \approx 5.967. $$

The model therefore predicts about 5.967 events per standard observation period, conditional on the fitted effects for this clinician and case type. The fact that their pairing is new does not justify replacing either fitted effect with zero. This prediction does not include uncertainty in the fitted coefficients or random-effect estimates, and it is not a prediction interval for a future count.

Worked Example: One Known Level and One New Level

Now suppose the hypothetical model has \(\hat\beta_0=\log(3)\), a fixed treatment contribution of \(0.20\), and a known clinician effect \(\hat u_i=0.30\). The observation is for a new case type whose random intercept has fitted variance estimate \(\hat\sigma_B^2=0.16\). Assume a Poisson response, log link, and normal case-type random intercept independent of the clinician effect.

A zero-effect plug-in for the new case type gives:

$$ \hat\eta_{\text{zero}} =\log(3)+0.20+0.30 =\log(3)+0.50, \qquad \exp(\hat\eta_{\text{zero}}) =3\exp(0.50) \approx 4.946. $$

This is a conditional plug-in value with the unseen case-type effect set to its mean of zero on the log scale. For the mean response across possible new case types, average over that effect’s normal distribution. The known clinician effect remains at its fitted value in this plug-in calculation:

$$ \widehat{E(Y)} \approx \exp\left\{\log(3)+0.20+0.30+\frac{0.16}{2}\right\} =3\exp(0.58) \approx 5.358. $$

The two values answer different questions: approximately 4.946 is the zero-new-effect plug-in mean, whereas approximately 5.358 averages the response mean over the model distribution of new case-type effects. Neither calculation accounts fully for uncertainty in the estimated clinician effect or fitted parameters.

Worked Example: Both Levels Are Unseen

For a third hypothetical prediction, suppose the fixed part is \(\log(2.5)+0.40\), and the new A and B levels have independent normal random intercepts with variance estimates \(0.09\) and \(0.16\), respectively. Assume again a Poisson conditional response and a log link. Neither level has appeared in the fitted data, so neither has a fitted level-specific random effect.

At zero for both new effects, the plug-in mean is:

$$ \exp\{\log(2.5)+0.40\} =2.5\exp(0.40) \approx 3.730. $$

For the mean response across new levels, add half the sum of their variances to the log mean:

$$ \exp\left\{\log(2.5)+0.40+\frac{0.09+0.16}{2}\right\} =2.5\exp(0.525) \approx 4.226. $$

The variance correction is \(0.125\), since \((0.09+0.16)/2=0.125\). This prediction uses no level-specific fitted effects; it describes the model-average mean for new A and B levels. A particular future pair can have a response mean above or below this average because its random effects vary.

A practical construction and its checks

Before computing a prediction, define what is being predicted: a conditional mean for specified known levels, a mean averaged over new levels, or a future observation including its response variation. Then verify the factor membership against the fitted data. The distinction between a new pairing and a new level is essential; a pairing can be new while both fitted effects are available. A compact construction is:

1
List the random-effect terms.
Write down each crossed factor, any random slopes, and any interaction that is actually in the fitted model.
2
Classify each level.
For every term, determine whether the prediction’s level appeared in the fitting data. A new pairing does not make its constituent levels new.
3
Build the linear predictor.
Start with the fixed-effect contribution, add fitted effects for known levels, and specify how unseen effects will be handled.
4
Apply the prediction target.
Use the inverse link for a conditional plug-in mean, or average that response-scale mean over unseen random effects when the target is a population-average prediction.
5
Report uncertainty and scope.
State which effects were conditioned on, which were averaged over, and whether uncertainty in parameters, effects, or the future response is included.

Several checks help identify a prediction that may be unreliable. Confirm that the new observation uses the same factor definitions and coding as the fitted model. Inspect how much information supports each known level: a fitted random effect based on very few observations is typically strongly shrunk and uncertain. In crossed designs with sparse or disconnected membership patterns, estimates and predictions can be weakly supported; the existence of a numerical fitted effect does not guarantee precise prediction. Also check whether the prediction is outside the covariate range used for fitting. These checks concern the design and model support, not just arithmetic.

Alternatives and limitations

A conditional prediction uses fitted random effects for known levels and is useful when the target specifically concerns those realized levels. A population-level prediction averages over random effects for newly sampled levels; setting new effects to zero is a link-scale reference value, not always that response-scale average. Treating every factor as fixed is another possible modeling choice, but it changes the model and the intended inference rather than providing a shortcut for the fitted random-effects model. Earlier material on predicting responses for new nested groups uses the same distinction between observed and unseen levels, but crossed models require making that decision separately for each factor.

A predicted mean is not an observed outcome. For a future count, for instance, the count varies around its conditional mean even if all model parameters and random effects were known. A prediction interval for a future observation must include this response variation and may also need to reflect uncertainty in fitted parameters and known-level random effects. A confidence interval for a mean and a prediction interval for an outcome therefore have different targets.

The calculation also relies on the fitted structure being appropriate. If the scientific process contains pair-specific variation but the model has no interaction term, the prediction cannot represent that source of variation. If an interaction is included, a new pairing has no observed interaction estimate and must be handled as a new random effect. This tutorial’s simple variance corrections assume independent normal random intercepts and a log link; other links, correlated effects, and random slopes require averaging under their own fitted distributions.

Common mistake

A frequent error is to see a pairing absent from the data and set both factor effects to zero. That discards information whenever the two levels have appeared in other pairings. The correction is to check level membership independently: use the fitted random effect for each known level, handle only unseen levels as new, and introduce a pair-specific term only if the fitted model includes one. A second error is to call \(\exp(\eta_0)\) the average response for new levels under a nonlinear link; for a log link, the normal random-effect variance correction shows why that is generally too small.

Key takeaway: In a crossed model, prediction follows the status of each random-effect level separately. Known levels can contribute fitted effects even in an unseen pairing; unseen levels have no fitted level-specific estimate, and averaging over them can change the response-scale mean.

Check Your Understanding

For each question, give your answer first, then compare it with the solutions below.

  1. In a crossed random-intercept model with no interaction term, both factor levels have appeared in the data but their pairing has not. Which fitted random effects enter a conditional plug-in predictor?
  2. A log-link model has fixed linear predictor \(0.70\) and one unseen normal random intercept with variance \(0.20\). Find the zero-effect plug-in mean and the response mean averaged over that random effect.
  3. One factor level is known and the other is unseen. Is it correct to set both effects to zero because the pair is new? Explain.
  4. What additional random-effect term changes the treatment of an unobserved pairing if the model includes it?

Solutions. (1) Both fitted level effects enter, \(\hat u_i+\hat v_j\); there is no separate pairing effect in the stated model. (2) The plug-in mean is \(\exp(0.70)\approx2.014\). The averaged mean is \(\exp(0.70+0.20/2)=\exp(0.80)\approx2.226\). (3) No. Use the fitted effect for the known level and handle only the unseen level according to the prediction target. (4) A random interaction effect for that pairing; because the pairing is unobserved, it has no pairing-specific estimate and must be treated as new under the model.

Clinical Biostats