GeneSuite
Documentation / Understand the methods

From Gaussian regression to the linear mixed model

Contents · Abbreviations

1 Why start here?

An animal’s phenotype reflects its genetic value, its environment and unexplained variation. We want to distinguish these contributions, predict genetic values and describe how uncertain those predictions are. Relatives carry information about one another, and animals with few records should not be treated as if their performance were known precisely.

Linear mixed models express these ideas through means and covariances. This chapter connects the Gaussian regression model to best linear unbiased prediction (BLUP) and the animal model. It assumes familiarity with means, variances, normal distributions and basic matrix multiplication. We begin with known covariance parameters. Estimating them is a separate problem, introduced near the end.

By the end, you should be able to explain shrinkage, construct the mixed-model equations, distinguish a breeding value from a phenotype, and understand how a pedigree supplies information for an animal without its own record.

These notes complement the existing Bayesian linear regression notes. The central connection is that a Gaussian distribution for random effects produces the same quadratic penalty that appears in Gaussian-prior regression.

2 A statistical model for observations

Write the linear mixed model as

\[ y=X\beta+Zu+e, \]

with

\[ u\sim N(0,K),\qquad e\sim N(0,R),\qquad \operatorname{Cov}(u,e)=0. \]

We assume joint Gaussianity, so the zero cross-covariance also implies independence. Throughout the derivation, \(K\) and \(R\) are known positive-definite matrices and \(X\) has full column rank. Singular covariance models and redundant fixed-effect columns need additional care and are deferred to later chapters.

Symbol Dimension Meaning
\(y\) \(n\times1\) Observed phenotypes
\(X\) \(n\times p\) Design matrix for fixed effects
\(\beta\) \(p\times1\) Unknown fixed-effect coefficients
\(Z\) \(n\times q\) Incidence/design matrix for random effects
\(u\) \(q\times1\) Realized random effects to predict
\(K\) \(q\times q\) Covariance matrix of random effects
\(R\) \(n\times n\) Residual covariance matrix

Here \(K\) denotes the entire random-effect covariance. Later we will reserve \(G\) for a genomic relationship matrix, avoiding two meanings for the same symbol.

2.1 Conditional and marginal distributions

Conditional on \(u\),

\[ y\mid u,\beta\sim N(X\beta+Zu,R). \]

Integrating over the random effects gives

\[ y\mid\beta\sim N(X\beta,V),\qquad V=ZKZ^\top+R. \]

These are two views of the same model. The conditional view helps us predict individual effects. The marginal view helps us estimate fixed effects and covariance parameters. Related observations can be correlated through \(K\), through \(R\), or both.

2.2 What makes an effect fixed or random?

A fixed effect is represented by an unknown coefficient without a probability distribution in this model. A random effect is assigned a distribution whose covariance specifies how information is shared and how strongly estimates are regularized.

For example, herd can be fixed when the aim is to adjust for a particular set of herd differences, or random when a population distribution of herd effects is appropriate. This is a scientific modelling decision; it is not determined solely by how many herds occur in the data. In either case we must consider confounding, connectedness and whether the assumptions suit the study design.

3 Shrinkage in the simplest possible example

Suppose an animal has \(r\) independent records after adjustment for a known population mean \(\mu\):

\[ y_j=\mu+u+e_j,\qquad u\sim N(0,\sigma_u^2),\qquad e_j\sim N(0,\sigma_e^2). \]

The record mean has residual variance \(\sigma_e^2/r\). Multiplying its Gaussian likelihood by the Gaussian distribution for \(u\) gives

\[ u\mid\bar y,\mu\sim N\left( \lambda(\bar y-\mu), \left[\frac{1}{\sigma_u^2}+\frac{r}{\sigma_e^2}\right]^{-1} \right), \qquad \lambda=\frac{\sigma_u^2}{\sigma_u^2+\sigma_e^2/r}. \]

The prediction is the adjusted record mean multiplied by a number between zero and one. With little information, it stays close to the population mean. With more independent records, it moves towards the animal’s observed mean. Larger residual variation produces more shrinkage; larger between-animal variation produces less.

For \(\sigma_u^2=1\), \(\sigma_e^2=3\) and \(\bar y-\mu=2\):

Records \(r\) Shrinkage multiplier \(\lambda\) Predicted effect
1 0.25 0.50
3 0.50 1.00
9 0.75 1.50

This particular calculation assumes independent residuals and no additional permanent animal effect. Repeated records with shared environmental effects contain less independent information than this simple formula assumes.

4 Deriving the mixed-model equations

This is the classical mixed-model prediction construction (Henderson, 1975; Robinson, 1991).

For known \(K\) and \(R\), consider the quadratic objective

\[ Q(\beta,u)= (y-X\beta-Zu)^\top R^{-1}(y-X\beta-Zu)+u^\top K^{-1}u. \]

The first term penalizes lack of fit in units of residual covariance. The second penalizes random effects according to their covariance. It is not an arbitrary extra penalty: it comes from the Gaussian distribution of \(u\).

Let \(r=y-X\beta-Zu\). Setting the derivatives to zero gives

\[ X^\top R^{-1}r=0,\qquad Z^\top R^{-1}r=K^{-1}u. \]

Rearranging yields Henderson’s mixed-model equations:

\[ \underbrace{\begin{bmatrix} X^\top R^{-1}X & X^\top R^{-1}Z\\ Z^\top R^{-1}X & Z^\top R^{-1}Z+K^{-1} \end{bmatrix}}_{C} \begin{bmatrix}\hat\beta\\\hat u\end{bmatrix} = \begin{bmatrix}X^\top R^{-1}y\\Z^\top R^{-1}y\end{bmatrix}. \]

The precision matrix \(K^{-1}\) stabilizes the random-effect block. Even if two animals have identical incidence columns, the covariance model can make their joint prediction well defined. It cannot, however, repair arbitrary non-identifiability in the fixed-effect part.

In the special case \(K=\sigma_u^2I\) and \(R=\sigma_e^2I\), multiplying both sides by \(\sigma_e^2\) places \(\alpha I=(\sigma_e^2/\sigma_u^2)I\) in the random-effect block. Thus the familiar ridge parameter is a ratio of variance components. The intercept and other fixed effects are not penalized in this formulation.

5 BLUE, BLUP and the Bayesian connection

Define

\[ B=(X^\top V^{-1}X)^{-1}. \]

An equivalent solution is

\[ \hat\beta=BX^\top V^{-1}y,\qquad \hat u=KZ^\top V^{-1}(y-X\hat\beta). \]

The first expression is generalized least squares. The second uses the covariance between effects and observations, \(\operatorname{Cov}(u,y)=KZ^\top\), to predict effects from adjusted records. The mixed-model and marginal expressions agree; neither requires an explicit dense inverse in a practical large-scale implementation.

BLUE means best linear unbiased estimator of an estimable fixed-effect contrast. BLUP means best linear unbiased predictor of a random-effect contrast, where “best” means minimum mean squared prediction error within the linear unbiased class under the assumed covariances. Unbiasedness averages over both random effects and residuals. It does not mean \(E(\hat u\mid u)=u\): shrinkage generally prevents that conditional equality.

The linear optimality result needs the specified first and second moments; Gaussianity additionally supplies the conditional-distribution interpretation. With \(\beta\) known,

\[ E(u\mid y,\beta)=KZ^\top V^{-1}(y-X\beta). \]

With an improper flat prior on \(\beta\), known covariances and a proper resulting posterior, the joint posterior of \((\beta,u)\) is Gaussian, with mean equal to the mixed-model solution and covariance \(C^{-1}\). A proper informative prior on \(\beta\) changes these equations. These equivalences do not make a fixed-covariance BLUP analysis a fully Bayesian variance-component analysis.

6 Introducing the pedigree animal model

Pedigree relationships and their sparse precision representation underpin the animal model (Henderson, 1976).

For additive genetic values \(a\), write

\[ y=X\beta+Za+e,\qquad a\sim N(0,\sigma_a^2 A),\qquad e\sim N(0,\sigma_e^2I). \]

\(A\) is the numerator relationship matrix. Under the ordinary pedigree model, \(A_{ii}=1+F_i\), where \(F_i\) is the inbreeding coefficient, and off-diagonal entries describe additive relationships relative to the chosen founder base. The genetic covariance is \(\sigma_a^2 A\), not \(A\) alone.

Consider two unrelated, non-inbred founders and their offspring:

Animal Sire Dam Phenotype
A1 unknown unknown 8
A2 unknown unknown 12
A3 A1 A2 unobserved

Their relationship matrix is

\[ A=\begin{bmatrix}1&0&1/2\\0&1&1/2\\1/2&1/2&1\end{bmatrix}. \]

With an intercept, \(\sigma_a^2=1\) and \(\sigma_e^2=1\),

\[ y=\begin{bmatrix}8\\12\end{bmatrix},\quad X=\begin{bmatrix}1\\1\end{bmatrix},\quad Z=\begin{bmatrix}1&0&0\\0&1&0\end{bmatrix}. \]

Solving gives \(\hat\mu=10\) and \(\hat a=(-1,1,0)^\top\). The parents’ deviations are shrunk from \((-2,2)\) to \((-1,1)\). The offspring prediction equals their average, zero, because its unobserved Mendelian sampling term has conditional mean zero. Zero here means the model’s genetic reference level; it does not mean that the offspring’s true breeding value is known to be zero.

6.1 Information from an offspring record

If the offspring A3 also has a phenotype of 14, its record changes the estimated intercept to 11 and the genetic predictions to \((-1,1,1)^\top\). Information can travel through relationships in both directions; it is not limited to passing parental predictions to offspring.

7 What uncertainty belongs to a prediction?

The prediction error is \(a-\hat a\), rather than the observed residual \(y-X\hat\beta-Z\hat a\). These quantities answer different questions. For the general model, let

\[ P=V^{-1}-V^{-1}XB X^\top V^{-1}. \]

The prediction error covariance of the BLUP is

\[ \operatorname{Var}(u-\hat u)=K-KZ^\top PZK. \]

This includes uncertainty from estimating fixed effects. It equals the random-effect block of \(C^{-1}\) when \(C\) uses the unscaled precision convention above. If the equations are multiplied by \(\sigma_e^2\), their inverse must also be rescaled before interpreting its entries as variances.

Under this known-covariance model, a common reliability measure is

\[ \mathrm{Rel}_i=1-\frac{\mathrm{PEV}_i}{K_{ii}}. \]

In the example the parent prediction-error variances (PEVs) are \(0.75\) and their reliabilities are \(0.25\). The offspring PEV is \(1\) and reliability is zero: its prediction is available, but this balanced example supplies no information about its genetic value beyond the prior variance after allowing for the unknown mean.

Reliability concerns uncertainty in a genetic value. Predicting a new phenotype also involves residual variation and possibly new environmental effects. With estimated covariance parameters, a plug-in PEV generally does not include all variance-component uncertainty.

8 Known covariances, REML and Bayesian inference

For restricted likelihood see Patterson and Thompson (1971); for the broader likelihood and Bayesian quantitative-genetics framework see Sorensen and Gianola (2002).

The derivations so far condition on covariance parameters, denoted collectively by \(\theta\). These may include genetic and residual variances and, for several traits, covariance matrices.

Supplied-covariance solving computes \(\hat\beta\) and \(\hat u\) at specified \(\theta\). It answers the prediction problem without estimating \(\theta\).

restricted maximum likelihood (REML) followed by prediction estimates \(\theta\) from residual contrasts and then substitutes \(\hat\theta\) into the prediction equations. Up to constants independent of \(\theta\), the restricted log likelihood is

\[ \ell_R(\theta)=-\tfrac12\left\{ \log|V|+\log|X^\top V^{-1}X|+y^\top Py+(n-p)\log(2\pi) \right\}. \]

The resulting predictor is commonly called empirical BLUP. Because its covariances depend on the data, it is generally no longer linear in \(y\).

Fully Bayesian inference assigns priors to \(\theta\) and integrates over its posterior. A posterior mean such as \(E(u\mid y)\) averages over covariance uncertainty rather than evaluating a prediction formula at a single estimate.

These are different inferential tasks. A numerical linear solver does not by itself estimate variance components or quantify their uncertainty.

9 Connecting the equations to gsuite

In a supplied-covariance standalone YAML (a human-readable model-configuration format) model, \(X\) is specified by fixed, the grouping/incidence information by the random-effect group, and \(K\) by the relationship and covariance declarations. For the three-animal example, the central model declarations would be:

relationships:
  A: {type: pedigree, input: pedigree}
covariances:
  genetic: [[1.0]]
  residual: [[1.0]]
model:
  data: observations
  fixed: '1'
  random:
    genetic:
      group: individual
      relationship: A
      covariance: genetic
  residual: residual
analysis: {task: solve}

This is a model fragment, not a complete runnable file: input tables, trait mapping, execution and output declarations are also required. For complete existing examples see the YAML example catalog and the pedigree analysis tutorial. Interface support and qualification are described in the model catalog; the equations alone do not establish support for an arbitrary model.

9.1 An illustrative multitrait model

The framework accommodates many combinations of traits, relationships and random effects. As one illustration, a four-trait model for animal \(i\) and trait \(t\) can be written

\[ y_{it}=\mu_t+a_{it}+h_{\operatorname{herd}(i),t} +f_{\operatorname{family}(i),t}+c_{it}+e_{it}. \]

Here \(a\) denotes genetic values, \(h\) herd effects, \(f\) family effects and \(c\) individual-environment effects. Assume independence between these effect classes, with covariance between traits within each class. With effects stacked trait by trait, representative covariance blocks are

\[ \operatorname{Var}(a)=\Sigma_a\otimes H,\quad \operatorname{Var}(h)=\Sigma_h\otimes I_h,\quad \operatorname{Var}(f)=\Sigma_f\otimes I_f,\quad \operatorname{Var}(c)=\Sigma_c\otimes I_{\rm animal}. \]

For one complete four-trait record per observed animal and the same ordering, \(R=\Sigma_e\otimes I_{\rm observed}\). Missing trait records require selecting the corresponding rows and covariance entries. Different stacking conventions change Kronecker order, not the statistical model.

\(H\) combines pedigree and genomic information; its construction, genomic adjustment and pedigree blending belong to the single-step chapter. SNP-effect and animal-effect representations will be connected explicitly there.

With exactly one visit per animal, an independent individual-environment component and an unrestricted within-record residual component cannot generally be estimated separately: only their sum is identified from those records. They can nevertheless be specified separately when their covariance matrices are supplied, as in the four-trait benchmark. This is one example of the broader model framework, rather than a development endpoint. Biological naming does not establish statistical identifiability.

10 Model, formulation and computation

The statistical model specifies \(X\), \(Z\), \(K\), \(R\) and the target of inference. A formulation expresses that model in particular unknowns, for example animal or marker effects. A numerical method solves the resulting equations, using direct factorization or an iterative algorithm.

A preconditioner changes how an iterative solver reaches a solution. If it is used only for that purpose, it does not change the model’s target equations. An approximate preconditioner can therefore produce the same accepted solution as an exact one, while taking a different number of iterations. Adding a ridge to the model covariance, changing blending or dropping an effect changes the target and needs a separate scientific justification.

Numerical residual checks assess whether the specified equations were solved. They do not demonstrate that the model fits the biology or predicts new data well. Those require model checking and appropriately designed validation.

11 Guided reading

  • Refresher: Bayesian linear regression notes. Revisit Gaussian priors and posterior precision, then identify the analogous \(K^{-1}\) term in this chapter.
  • BLUP interpretation: Robinson (1991) explains random-effect prediction and its connections across statistical traditions.
  • Foundations and selection: Henderson (1975) develops estimation and prediction under a selection model. Read after the derivation, focusing on its assumptions. The small example here does not model selection.
  • Inference beyond supplied covariances: Sorensen and Gianola (2002) connects likelihood estimation and Bayesian analysis in quantitative genetics.

Continue with the advanced notes and their shared bibliography.

12 References

Henderson, C. R. (1975). Best Linear Unbiased Estimation and Prediction under a Selection Model. Biometrics, 31(2), 423–447. https://doi.org/10.2307/2529430.
Henderson, C. R. (1976). A Simple Method for Computing the Inverse of a Numerator Relationship Matrix Used in Prediction of Breeding Values. Biometrics, 32(1), 69. https://doi.org/10.2307/2529339.
Patterson, H. D., and Thompson, R. (1971). Recovery of inter-block information when block sizes are unequal. Biometrika, 58(3), 545–554. https://doi.org/10.1093/biomet/58.3.545.
Robinson, G. K. (1991). That BLUP is a Good Thing: The Estimation of Random Effects. Statistical Science, 6(1), 15–32. https://doi.org/10.1214/ss/1177011926.
Sorensen, D., and Gianola, D. (2002). Likelihood, Bayesian, and MCMC Methods in Quantitative Genetics. Springer New York. https://doi.org/10.1007/b98952.