Tutorials › Generalized Linear Mixed Models (GLMM) › A Worked Random-Intercept Model for Continuous Outcomes

Random Intercepts and Slopes · Tutorial 36 of 698

A Worked Random-Intercept Model for Continuous Outcomes

Learn to calculate and interpret cluster-specific fitted means in a Gaussian random-intercept model, and distinguish them from fixed-part means and observed outcomes.

Intermediate 10 min read

What You'll Learn

  • State the Gaussian random-intercept model and the assumptions needed for its conditional and marginal means.
  • Interpret the fixed intercept, fixed slope, and a cluster’s random-intercept deviation in outcome units.
  • Calculate fitted conditional means using fixed coefficients and cluster deviations.
  • Distinguish fitted means from observed outcomes and their residuals.
  • Check model assumptions and recognize common interpretation errors.

Why Work Through a Random-Intercept Model?

Measurements from the same cluster—such as repeated readings from one person or outcomes from patients at one clinic—may share a baseline level. A Gaussian random-intercept model represents this structure by giving each cluster its own deviation from a common fixed intercept. Working through the arithmetic makes the interpretation concrete: the fixed coefficients describe the common part of the model, while the random intercept shifts a cluster’s fitted mean up or down.

The focus here is a continuous outcome with an identity link. The examples show how to compute and interpret fitted conditional means from specified coefficients and cluster deviations. They do not treat a fitted mean as the observed outcome, nor do they imply that the random deviation is known without uncertainty.

Model and Assumptions

Definition: A Gaussian random-intercept model for observation \(i\) in cluster \(j\) is $$ Y_{ij}=\beta_0+\beta_1x_{ij}+b_{0j}+\varepsilon_{ij}. $$ Here \(Y_{ij}\) is the continuous outcome, \(x_{ij}\) is a predictor, \(\beta_0\) and \(\beta_1\) are fixed coefficients, \(b_{0j}\) is the random intercept for cluster \(j\), and \(\varepsilon_{ij}\) is the observation-level residual. The model assumes \(b_{0j}\sim N(0,\sigma_b^2)\) independently across clusters, and \(\varepsilon_{ij}\sim N(0,\sigma^2)\) independently across observations and independently of the random intercepts. The predictor values are treated as fixed, or are assumed independent of the random intercepts. In particular, \(E(b_{0j}\mid x_{ij})=0\) under these conditions.

The last condition matters for interpreting the mean over clusters at a given predictor value. A random intercept having unconditional mean zero alone would not guarantee a zero mean after conditioning on a predictor that is associated with the random intercept. The fixed-predictor or independence assumption rules out that issue here. The model also presumes that the conditional outcome is Gaussian with the stated additive structure, that clusters are independent, and that the residual variance is common across observations.

For a particular cluster, conditional on its random intercept and predictor, the model mean is

$$ E(Y_{ij}\mid x_{ij},b_{0j})=\beta_0+\beta_1x_{ij}+b_{0j}. $$

This is the cluster-specific or conditional mean. The term \(\beta_0+\beta_1x_{ij}\) is the fixed-part mean, and \(b_{0j}\) shifts it for cluster \(j\). Averaging over the random-intercept distribution at a fixed predictor value gives

$$ E(Y_{ij}\mid x_{ij}) =\beta_0+\beta_1x_{ij}+E(b_{0j}\mid x_{ij}) =\beta_0+\beta_1x_{ij}. $$

That last equality follows from the stated assumption \(E(b_{0j}\mid x_{ij})=0\), not merely from \(E(b_{0j})=0\). It describes the model’s mean over clusters at that predictor value; it does not say that every cluster has that mean.

Reading the Coefficients and a Cluster Deviation

The fixed intercept \(\beta_0\) is the fixed-part mean at \(x_{ij}=0\). The fixed slope \(\beta_1\) is the change in conditional mean, in outcome units, for a one-unit increase in \(x_{ij}\), holding the cluster intercept fixed. Because this model has a random intercept but no random slope, the slope is the same for every cluster. The cluster deviation \(b_{0j}\) is a vertical shift, also in outcome units, relative to the fixed-part line.

For fitted data, the coefficients and cluster deviations are typically replaced by estimates. Write these as \(\hat{\beta}_0\), \(\hat{\beta}_1\), and \(\hat{b}_{0j}\). The fitted conditional mean is then

$$ \hat{Y}_{ij}^{\,\mathrm{cond}} =\hat{\beta}_0+\hat{\beta}_1x_{ij}+\hat{b}_{0j}. $$

It is conditional because it includes the estimated deviation for the specified cluster. It is a fitted mean, not a prediction of the exact observed outcome: an observation also includes its residual \(\varepsilon_{ij}\). Estimated cluster deviations are not directly observed; they are estimated from the data and generally carry uncertainty.

Worked Example: A Cluster Above the Fixed-Part Mean

Suppose an illustrative model for a continuous laboratory score has \(\hat{\beta}_0=50\) score points and \(\hat{\beta}_1=2.4\) score points per hour of a measured exposure. For a specified cluster, suppose the fitted deviation is \(\hat{b}_{0j}=3.5\) score points. Calculate the fitted conditional mean at \(x_{ij}=4\) hours.

First calculate the fixed-part mean:

$$ \hat{\beta}_0+\hat{\beta}_1x_{ij} =50+(2.4)(4) =50+9.6 =59.6\text{ score points}. $$

Then add the cluster’s fitted deviation:

$$ \hat{Y}_{ij}^{\,\mathrm{cond}} =50+(2.4)(4)+3.5 =63.1\text{ score points}. $$

For this cluster, the fitted conditional mean at four hours is 63.1 score points. The fixed-part mean at the same exposure is 59.6 points, and the positive deviation shifts the cluster’s fitted mean upward by 3.5 points. These calculations interpret the supplied fitted values; they do not establish that exposure causes a change in the score.

Calculate Fitted Means Across Predictor Values

A random intercept changes the level of a cluster’s fitted line but not its slope. For a given cluster, add the same \(b_{0j}\) at every predictor value. The resulting conditional mean is a straight line parallel to the fixed-part line. This description concerns the model’s mean structure; individual observed values can lie above or below that line because of residual variation.

Worked Example: Comparing a Cluster’s Fitted Means

Use \(\hat{\beta}_0=50\) score points, \(\hat{\beta}_1=2.4\) score points per hour, and \(\hat{b}_{0j}=-4.0\) score points. Calculate the fixed-part and conditional fitted means at \(x_{ij}=0\) and \(x_{ij}=5\) hours.

At zero hours, the fixed-part mean is \(50+(2.4)(0)=50\) points. Including the cluster deviation gives \(50-4.0=46.0\) points.

At five hours, the fixed-part mean is

$$ 50+(2.4)(5)=50+12=62\text{ score points}. $$

The cluster’s conditional fitted mean is

$$ 50+(2.4)(5)-4.0=58.0\text{ score points}. $$

Thus the conditional fitted means are 46.0 points at zero hours and 58.0 points at five hours. The increase is 12.0 points over five hours, the same as the fixed-part increase: \((2.4)(5-0)=12.0\). The cluster deviation lowers both fitted means by 4.0 points; it does not alter the slope.

From Fitted Mean to Observed Outcome

An observed outcome need not equal its fitted conditional mean. Under the model, the difference is the residual:

$$ \varepsilon_{ij} =Y_{ij}-(\beta_0+\beta_1x_{ij}+b_{0j}). $$

In an application, the corresponding fitted residual is calculated by subtracting the fitted conditional mean from the observed outcome. A positive residual means the observed value is above that fitted mean; a negative residual means it is below.

Worked Example: Interpreting a Fitted Residual

Suppose a cluster has \(\hat{b}_{0j}=2.0\) score points, and the fitted coefficients are \(\hat{\beta}_0=50\) points and \(\hat{\beta}_1=2.4\) points per hour. An observation in that cluster has \(x_{ij}=3\) hours and an observed score of 61 points. Calculate its fitted conditional mean and fitted residual.

The fitted conditional mean is

$$ 50+(2.4)(3)+2.0 =50+7.2+2.0 =59.2\text{ score points}. $$

The fitted residual is observed minus fitted:

$$ 61-59.2=1.8\text{ score points}. $$

The observed score is 1.8 points above this fitted conditional mean. The fitted mean is not 61, and the residual is not another cluster deviation: the deviation is the cluster-level shift, while the residual is the observation-specific difference from the fitted mean.

Justification and Practical Checks

The conditional-mean formula follows by taking expectations in the model while holding the predictor and cluster intercept fixed. The marginal mean follows by averaging over cluster intercepts. Writing out those steps makes clear both the role of the random intercept and the condition needed to use the fixed-part mean as the mean at a given predictor value.

1
Condition on the cluster.
For fixed \(x_{ij}\) and \(b_{0j}\), the residual has mean zero, so \(E(Y_{ij}\mid x_{ij},b_{0j})=\beta_0+\beta_1x_{ij}+b_{0j}\).
2
Average across clusters at a fixed predictor value.
Under fixed predictors or independence of predictors and random intercepts, \(E(b_{0j}\mid x_{ij})=0\). Therefore \(E(Y_{ij}\mid x_{ij})=\beta_0+\beta_1x_{ij}\).
3
Use fitted values for a specified cluster.
Substitute the fitted coefficients and that cluster’s fitted deviation into \(\hat{\beta}_0+\hat{\beta}_1x_{ij}+\hat{b}_{0j}\). This yields a fitted conditional mean, not an observed outcome.

In practice, inspect residuals against fitted conditional means and predictor values for patterns such as changing spread, curvature, or clusters that remain systematically above or below their fitted values. Such patterns can signal that the Gaussian, constant-variance, linear-mean, or random-intercept structure is inadequate. Also check whether the predictor values could plausibly be associated with cluster baselines; if they are, the conditional mean over clusters need not equal the fixed part.

A random-intercept model is useful when the aim is to represent cluster-specific baselines while retaining a common slope. Ordinary Gaussian regression omits that cluster-level deviation and may not represent the dependence among observations in a cluster. A marginal model instead targets a mean averaged over clusters, while this model also represents cluster-specific conditional means. Those approaches answer related but distinct questions; selecting among them depends on the scientific target and data structure.

The random-intercept model has limits. It assumes a common slope, a specified Gaussian distribution for the random intercepts and residuals, and a predictor relationship compatible with its linear mean. If cluster effects are systematically related to predictors, the independence condition used for the marginal-mean interpretation fails. A fitted conditional mean also does not remove uncertainty in estimated coefficients or cluster deviations. For these reasons, report the model’s conditioning and assumptions rather than presenting a cluster-specific fitted value as an error-free fact.

Common Mistakes

  • Calling the fixed intercept every cluster’s baseline. It is the fixed-part mean at \(x=0\); a cluster’s conditional mean there also includes its \(b_{0j}\).
  • Interpreting a deviation as a slope change. A random intercept shifts the fitted line vertically. The model shown has the same slope in every cluster.
  • Equating a fitted mean with an observed outcome. The observation also contains a residual, so the two need not match.
  • Inferring a conditional mean-zero property from a marginal one. \(E(b_{0j})=0\) alone does not imply \(E(b_{0j}\mid x_{ij})=0\). The fixed-predictor or independence assumption is needed for that step.
  • Treating an estimated deviation as known without uncertainty. A fitted cluster deviation is an estimate, not a directly observed constant.
Key takeaway: In a Gaussian random-intercept model, the fitted conditional mean for a specified cluster is the fixed-part mean plus that cluster’s fitted deviation. The fixed-part mean is also the mean over clusters at a given predictor value only under an appropriate condition, such as fixed predictors or independence between predictors and random intercepts.

Check Your Understanding

Use the model and assumptions stated above. Each question is followed by its solution.

  1. A fitted model has intercept 12 units, slope 0.8 units per day, and a cluster deviation of \(-1.5\) units. Find the conditional fitted mean at day 10.
  2. With the same coefficients and deviation, how much does this cluster’s fitted conditional mean change between day 2 and day 7?
  3. An observed outcome is 24 units and its fitted conditional mean is 21.6 units. Find and interpret the fitted residual.
  4. Why is \(E(b_{0j})=0\) by itself insufficient to conclude that the mean conditional on \(x_{ij}\) is \(\beta_0+\beta_1x_{ij}\)?
  5. A fitted model has a random intercept but no random slope. What does the cluster deviation change, and what does it leave unchanged?

Solutions. (1) \(12+(0.8)(10)-1.5=18.5\) units. (2) The deviation cancels from the change: \((0.8)(7-2)=4.0\) units. (3) \(24-21.6=2.4\) units; the observed outcome is 2.4 units above its fitted conditional mean. (4) The predictor may be associated with the random intercept, so \(E(b_{0j}\mid x_{ij})\) need not be zero even if \(E(b_{0j})=0\). Fixed predictors or independence supplies the needed conditional mean-zero property. (5) It shifts the cluster’s fitted line vertically and leaves its slope unchanged.

Clinical Biostats