Why Use a Gaussian Benchmark?
Individual forecasts can require substantial computation when the response model is nonlinear or its uncertainty must be propagated numerically. A useful reference case is a model that is linear in Gaussian random effects and has Gaussian residual errors. With its population parameters treated as known, both the posterior distribution of an individual’s random effects and the predictive distribution of a future response have closed forms. These results make it possible to check numerical forecasts in simple cases and to see precisely how observed data update individual-level predictions.
This benchmark is deliberately narrower than a general nonlinear mixed-effects analysis. The response must be linear in the random effects, and the random-effect and residual covariance matrices are treated as known. The formulas do not automatically account for uncertainty in estimated population parameters.
In this tutorial, \(\beta\), \(G\), and \(R\) are treated as fixed and known. The observations are generated under the stated model, and the future residual errors are assumed independent of the observed residual errors and of the random effects. These conditions are what permit the simple conjugate calculations below. If residual errors are correlated across observation times, their joint covariance must instead be represented and conditioned on.
Posterior Distribution of the Random Effects
Write \(r=y-X\beta\) for the observed responses after subtracting their fixed-effect contribution. The likelihood for \(b\) is Gaussian, with mean \(Zb\) for \(r\) and covariance \(R\). Multiplying this likelihood by the Gaussian prior for \(b\) gives a Gaussian posterior.
The matrix \(C\) is the posterior covariance, and \(m\) is the posterior mean. The observed residuals \(y-X\beta\) inform the random effects through \(Z^\mathsf{T}R^{-1}(y-X\beta)\); observations with lower residual variance receive more weight through \(R^{-1}\). The prior contributes the precision matrix \(G^{-1}\), so the posterior reflects both the population distribution and the individual’s data.
Why the Posterior Is Gaussian
The result follows by completing the square in the exponent of the joint prior and likelihood. Ignoring factors that do not depend on \(b\), their product is proportional to
Expanding the quadratic expression gives
Set \(C=(G^{-1}+Z^\mathsf{T}R^{-1}Z)^{-1}\) and \(m=CZ^\mathsf{T}R^{-1}r\). Then the terms depending on \(b\) can be written as
Indeed, its quadratic term is \(b^\mathsf{T}C^{-1}b\), and its linear term is \(-2b^\mathsf{T}C^{-1}m=-2b^\mathsf{T}Z^\mathsf{T}R^{-1}r\). The remaining term does not depend on \(b\) and is absorbed into the normalizing constant. This is the kernel of a multivariate normal distribution with mean \(m\) and covariance \(C\), proving the result.
From the Posterior to a Future Forecast
Let \(y_*\) be a vector of future responses for the same individual. Suppose its model is \(y_*=X_*\beta+Z_*b+\varepsilon_*\), where the future design matrices are known and \(\varepsilon_*\sim N(0,R_*)\). Assume \(\varepsilon_*\) is independent of \(b\) and of the residual errors in the observed data. Conditional on \(y\), the uncertain random effects have distribution \(N(m,C)\), while the future residuals remain independent Gaussian errors.
The predictive mean substitutes the posterior mean of the random effects into the future model. The predictive covariance has two parts: \(Z_*CZ_*^\mathsf{T}\), uncertainty about the individual random effects after seeing the data, and \(R_*\), future residual variation. If the target is instead the latent future mean \(X_*\beta+Z_*b\), rather than a future observed response, omit \(R_*\). Confusing these two targets produces forecasts with the wrong variance.
The result follows because a linear transformation of a Gaussian vector is Gaussian. Given \(y\), \(Z_*b\) has mean \(Z_*m\) and covariance \(Z_*CZ_*^\mathsf{T}\). Adding the independent Gaussian error \(\varepsilon_*\) adds its covariance \(R_*\), giving the stated mean and covariance.
Worked Example: Updating a Random Intercept and Forecasting a Measurement
Suppose hypothetical concentrations follow \(y_i=10+b+\varepsilon_i\), measured in mg/L, with \(b\sim N(0,4)\) and independent \(\varepsilon_i\sim N(0,1)\). The population mean, prior variance, and residual variance are treated as known. An individual has two observed concentrations, 12 and 11 mg/L. Find the posterior distribution of \(b\), then forecast one future observed concentration under the same conditions.
Here \(G=4\), \(R=I\), and both rows of \(Z\) equal 1. The observed residuals relative to the fixed mean are \(12-10=2\) and \(11-10=1\). Thus
Therefore \(b\mid y\sim N(1.333,0.4444)\), with the mean in mg/L and variance in \((\mathrm{mg/L})^2\). The future response has fixed mean 10 mg/L, random-effect loading 1, and residual variance 1 \((\mathrm{mg/L})^2\). Its predictive distribution is
where the first argument is in mg/L and the second is in \((\mathrm{mg/L})^2\). The predictive standard deviation is \(\sqrt{1.444}=1.202\) mg/L. For example, a central 90% predictive interval, using the standard-normal quantile 1.645, is \(11.333\pm1.645(1.202)\), or approximately 9.356 to 13.311 mg/L. This interval concerns a future observed concentration under the model, not a 90% probability statement about a fixed unknown parameter.
Worked Example: Forecasting With a Random Slope
In a hypothetical linear model, an observed response at covariate value \(x=1\) is \(y=8+b+\varepsilon\), where \(b\sim N(0,9)\) and \(\varepsilon\sim N(0,4)\). The observed response is 14 units. Forecast the future observed response at \(x=2\), where the model is \(y_*=20+2b+\varepsilon_*\) and \(\varepsilon_*\sim N(0,1)\), independently of the observed error.
The observed residual relative to the fixed part is \(14-8=6\). The posterior variance and mean of the random slope are
The future random-effect contribution is \(2b\), so its conditional mean is \(2m=108/13=8.308\), and its conditional variance is \(2^2C=144/13=11.077\). Adding the future residual variance gives
The predictive variance is \(12.077\) response-units squared, and the predictive standard deviation is \(\sqrt{157/13}=3.475\) units. The factor \(2^2\) is essential: uncertainty in a random slope is amplified when forecasting at \(x=2\).
Worked Example: A Random-Intercept-and-Slope Benchmark
Suppose two hypothetical responses have their fixed effects subtracted, leaving residuals \(r=(2,1)^\mathsf{T}\). The random intercept and slope are \(b=(b_0,b_1)^\mathsf{T}\sim N(0,G)\), with \(G=\operatorname{diag}(4,1)\). The design matrix is \(Z=\begin{pmatrix}1&0\\1&1\end{pmatrix}\), and \(R=I\). Forecast a future observed response whose fixed-effect contribution is 10 and random-effect row is \(Z_*=(1,2)\), with future residual variance 1.
The posterior precision matrix is
Its determinant is \((9/4)(2)-1=7/2\), so
Also, \(Z^\mathsf{T}r=(3,1)^\mathsf{T}\), and hence
The future predictive mean is \(10+Z_*m=10+10/7-3/7=11\). Its variance is \(Z_*CZ_*^\mathsf{T}+1=2+1=3\): specifically, \(Z_*CZ_*^\mathsf{T}=4/7-8/7+18/7=2\). Thus \(y_*\mid y\sim N(11,3)\). A numerical forecasting routine applied to this same model and inputs should return these mean and variance values, up to rounding.
Using the Benchmark and Recognizing Its Limits
A closed-form forecast is useful as a validation case: enter the same design matrices, prior covariance, residual covariance, and conditioning observations into a numerical procedure, then compare its posterior mean and covariance with the formulas above. Agreement checks the implementation for this Gaussian linear case. It does not establish that the numerical procedure is correct for every nonlinear model or every uncertainty source.
A frequent mistake is to forecast only at the posterior mean random effect and report the future residual variance as the total predictive variance. In the random-intercept example, that would give variance 1 rather than \(1+4/9=1.444\;(\mathrm{mg/L})^2\). The omitted \(4/9\) is uncertainty about the individual effect. Conversely, if the target is the latent mean and not a future measured response, adding residual variance would include variation that is not part of the target.
Other checks follow directly from the assumptions and formulas:
- Check the target and units. The forecast mean must be on the response scale, and its variance must be in squared response units.
- Check covariance contributions. The posterior covariance \(C\) and future error covariance \(R_*\) must be positive semidefinite; a materially negative predictive variance signals an implementation or input problem.
- Check the design. Random-effect loadings in \(Z_*\) determine how posterior uncertainty carries into the forecast. A missing or incorrectly scaled loading can substantially change the variance.
- Check the model fit and assumptions. Strong residual patterns, outliers, nonconstant residual variance, or responses incompatible with a Gaussian model can make the benchmark inappropriate.
The conditional mean \(m\) is a posterior point estimate of the random effects. Using only this estimate gives a plug-in forecast, while the full predictive distribution also propagates posterior random-effect uncertainty and future residual variation. Simulation or numerical integration may be needed when the response is nonlinear in random effects, the relevant distributions are not Gaussian, or the desired forecast includes uncertainty not represented by the known \(\beta\), \(G\), and \(R\). In particular, these formulas do not include uncertainty from estimating those population parameters.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- If the forecast target is a latent future mean rather than a future observed response, which covariance term is omitted?
- In a scalar random-intercept model with prior variance 4 and two independent observations each with residual variance 1, what is the posterior variance?
- For a future response with random-effect loading 3, how does the posterior variance \(C\) contribute to predictive variance?
- Name two assumptions that would prevent direct use of the stated closed-form predictive formula.
Solutions. (1) Omit \(R_*\), because latent means do not include future residual error. (2) The posterior variance is \((1/4+1+1)^{-1}=4/9\). (3) The contribution is \(3^2C=9C\). (4) Examples include a nonlinear response in the random effects, non-Gaussian random effects, or residual errors correlated between observed and future responses when that correlation is not represented in the model.