Tutorials › Statistical Genetics › Generalized Least Squares for Fixed Effects

Linear Mixed Models in Genetics · Tutorial 500 of 989

Generalized Least Squares for Fixed Effects

Learn how to estimate fixed effects and quantify their uncertainty when genetic or other shared effects make observations correlated.

Intermediate 10 min read

What You'll Learn

  • State the assumptions that define the generalized least-squares fixed-effects problem.
  • Derive the GLS estimator from the requirement of unbiasedness.
  • Obtain the estimator’s covariance and explain when it is a standard error.
  • Calculate fixed-effect estimates with correlated observations by hand.
  • Interpret how covariance changes the weighting of individuals and covariate adjustment.
  • Recognize why an incorrect covariance model can distort precision and influence.

Why Covariance Changes Fixed-Effect Estimation

In a genetic mixed model, individuals are not necessarily independent. Relatives may share polygenic effects, and a genomic relationship matrix can represent the pattern of that sharing. Even when the scientific target is a fixed effect, such as a covariate-adjusted mean or a marker coefficient, the correlation among observations matters: it changes how much information the data contain and how observations should be weighted.

Generalized least squares (GLS) estimates fixed effects using the covariance matrix of the observations. The result is conditional on the covariance matrix used. In a mixed model, that matrix may be built from a residual covariance and one or more genetic covariance components. The focus here is the fixed-effect estimator and its covariance when that observation covariance is specified.

Model and assumptions: Let \(y\) be an \(n\)-vector of outcomes, \(X\) an \(n\times p\) fixed-effects design matrix, and \(\beta\) a \(p\)-vector of fixed effects. The model is \(y=X\beta+e\), with \(E(e)=0\) and \(\operatorname{Cov}(e)=V\). Assume \(V\) is known for the calculation, symmetric positive definite, and \(X\) has full column rank. Normality is not required to derive the GLS estimator. If \(e\sim N(0,V)\), the estimator also has an exact normal sampling distribution.

The covariance matrix \(V\) has variances on its diagonal and covariances off the diagonal. For example, a simple genetic mixed-model covariance might be \(V=\tau^2K+\sigma^2I\), where \(K\) is a genomic relationship matrix, \(\tau^2\) is a genetic variance component, and \(\sigma^2\) is a residual variance component. This is an example of the covariance structure, not a claim that its components are known in applications. The GLS calculations below treat \(V\) as specified; estimating variance components is a separate problem.

The GLS Estimator and Its Covariance

Ordinary least squares minimizes the unweighted sum of squared residuals. GLS instead minimizes the residual quadratic form weighted by \(V^{-1}\). Because directions with greater variance or shared covariance contribute differently to the information, this weighting can change both estimates and uncertainty.

Definition: Given the model and assumptions above, the generalized least-squares estimator of \(\beta\) is
$$ \hat{\beta}_{\mathrm{GLS}} =(X^\mathsf{T}V^{-1}X)^{-1}X^\mathsf{T}V^{-1}y. $$
Its covariance matrix is \(\operatorname{Cov}(\hat{\beta}_{\mathrm{GLS}})=(X^\mathsf{T}V^{-1}X)^{-1}\). The standard error of a coefficient is the square root of its diagonal entry in this matrix.

The inverse in this expression exists under the stated assumptions. Since \(V\) is positive definite, so is \(V^{-1}\). For any nonzero \(p\)-vector \(a\), full column rank of \(X\) gives \(Xa\ne0\), and therefore \(a^\mathsf{T}X^\mathsf{T}V^{-1}Xa=(Xa)^\mathsf{T}V^{-1}(Xa)>0\). Thus \(X^\mathsf{T}V^{-1}X\) is invertible.

Derivation: Unbiasedness and Minimum Variance

The estimator is linear in \(y\). To see why its form is appropriate, consider any linear estimator \(Ay\), where \(A\) is a \(p\times n\) matrix. Its expectation is \(AX\beta\). It is unbiased for every \(\beta\) precisely when \(AX=I_p\). Among these linear unbiased estimators, GLS has the smallest covariance matrix.

1
Construct a linear unbiased estimator.
Set \(A_0=(X^\mathsf{T}V^{-1}X)^{-1}X^\mathsf{T}V^{-1}\). Then \(A_0X=I_p\), so \(A_0y\) is unbiased.
2
Compare it with any other linear unbiased estimator.
If \(Ay\) is unbiased, write \(A=A_0+D\). Since \(AX=A_0X=I_p\), the difference satisfies \(DX=0\).
3
Compare covariances.
Expand \(\operatorname{Cov}(Ay)=AVA^\mathsf{T}\). The cross terms vanish because \(A_0VD^\mathsf{T}=(X^\mathsf{T}V^{-1}X)^{-1}X^\mathsf{T}D^\mathsf{T}=0\), using \(DX=0\). The remaining difference is \(DVD^\mathsf{T}\), which is positive semidefinite because \(V\) is positive definite.

Consequently, \(\operatorname{Cov}(Ay)-\operatorname{Cov}(A_0y)=DVD^\mathsf{T}\) is positive semidefinite: no linear unbiased estimator has smaller variance in any linear combination of the coefficients. Direct substitution gives \(A_0VA_0^\mathsf{T}=(X^\mathsf{T}V^{-1}X)^{-1}\). This establishes the GLS covariance formula and the best linear unbiased property under the specified covariance. If \(e\) is multivariate normal, any linear transformation of \(y\) is normal, so \(\hat{\beta}_{\mathrm{GLS}}\sim N\bigl(\beta,(X^\mathsf{T}V^{-1}X)^{-1}\bigr)\).

Worked Calculations

The examples use hypothetical data. Outcomes and covariates are specified explicitly, and each covariance matrix is treated as known. When a model includes an intercept and a covariate, the intercept is the fitted mean at covariate value zero; that value need not be substantively typical.

Worked Example: GLS Mean for Two Correlated Individuals

Suppose two hypothetical related individuals have outcomes \(y=(2,4)^\mathsf{T}\), measured in outcome units. The model contains an intercept only, \(X=(1,1)^\mathsf{T}\), and the specified covariance matrix is \(V=\begin{pmatrix}1&0.5\\0.5&1\end{pmatrix}\), in squared outcome units. This matrix is positive definite because its eigenvalues are \(1.5\) and \(0.5\).

The inverse is \(V^{-1}=\begin{pmatrix}4/3&-2/3\\-2/3&4/3\end{pmatrix}\). Thus \(X^\mathsf{T}V^{-1}X=4/3\), and \(X^\mathsf{T}V^{-1}y=4\). Applying the GLS formula,

$$ \hat{\beta}_{\mathrm{GLS}} =\frac{X^\mathsf{T}V^{-1}y}{X^\mathsf{T}V^{-1}X} =\frac{4}{4/3}=3. $$

The fitted common mean is 3 outcome units. Its variance is \((4/3)^{-1}=0.75\) squared outcome units, so its standard error is \(\sqrt{0.75}=0.866\) outcome units. The estimate happens to equal the ordinary average, but the variance calculation accounts for the positive correlation; treating the two observations as independent would give variance \(1/2=0.5\), understating uncertainty.

Worked Example: Covariate Adjustment With a Corrected Cross-Product

Consider two hypothetical individuals with outcomes \(y=(0,6)^\mathsf{T}\) outcome units and covariate values \(x=(1,3)^\mathsf{T}\). Fit an intercept and a covariate effect, so \(X=\begin{pmatrix}1&1\\1&3\end{pmatrix}\). Let \(V=\begin{pmatrix}2&1\\1&2\end{pmatrix}\) in squared outcome units. Its eigenvalues are 3 and 1, so it is positive definite, and \(V^{-1}=\begin{pmatrix}2/3&-1/3\\-1/3&2/3\end{pmatrix}\).

First compute the information matrix. The intercept cross-product is \(1^\mathsf{T}V^{-1}1=2/3\). The intercept–covariate cross-product is \(1^\mathsf{T}V^{-1}x=4/3\). The covariate cross-product is

$$ x^\mathsf{T}V^{-1}x =(1,3) \begin{pmatrix} 2/3&-1/3\\ -1/3&2/3 \end{pmatrix} \begin{pmatrix}1\\3\end{pmatrix} =\frac{2}{3}-1-1+6 =\frac{14}{3}=4.667. $$

Next, \(V^{-1}y=(-2,4)^\mathsf{T}\). Therefore \(1^\mathsf{T}V^{-1}y=2\), while the covariate cross-product is \(x^\mathsf{T}V^{-1}y=(1,3)(-2,4)^\mathsf{T}=-2+12=10\). In particular, these weighted cross-products are \(4.667\) and \(10\), respectively; both use the displayed inverse matrix and vectors.

$$ X^\mathsf{T}V^{-1}X= \begin{pmatrix}2/3&4/3\\4/3&14/3\end{pmatrix}, \qquad X^\mathsf{T}V^{-1}y= \begin{pmatrix}2\\10\end{pmatrix}. $$

Solving \((X^\mathsf{T}V^{-1}X)\hat{\beta}=(2,10)^\mathsf{T}\) gives \(\hat{\beta}_0=-3\) outcome units and \(\hat{\beta}_1=3\) outcome units per covariate unit. For example, the fitted value at covariate value 1 is \(-3+3(1)=0\), and at value 3 it is \(-3+3(3)=6\). The coefficient describes the fitted change in outcome per one-unit increase in the covariate, conditional on this model; it does not establish a causal effect.

The coefficient covariance is \((X^\mathsf{T}V^{-1}X)^{-1} =\begin{pmatrix}3.5&-1\\-1&0.5\end{pmatrix}\) in the corresponding squared units. Hence the standard error of the covariate coefficient is \(\sqrt{0.5}=0.707\) outcome units per covariate unit. With two observations and two fitted coefficients, there are no residual degrees of freedom for estimating an additional common scale from residuals; the covariance stated here follows from treating \(V\) itself as specified.

Worked Example: Correlation Changes the Effective Weight of a Pair

Suppose three hypothetical individuals have outcomes \(y=(1,3,4)^\mathsf{T}\) outcome units. The first two are correlated, while the third is independent of them. Fit an intercept only, with \(X=(1,1,1)^\mathsf{T}\), and use \(V=\begin{pmatrix}1&0.8&0\\0.8&1&0\\0&0&1\end{pmatrix}\). The correlated block has eigenvalues 1.8 and 0.2, and the third eigenvalue is 1, so \(V\) is positive definite.

The inverse of the correlated block is \(\frac{1}{0.36}\begin{pmatrix}1&-0.8\\-0.8&1\end{pmatrix}\), which has row sums \(1/1.8=0.5556\). Including the independent third observation, \(X^\mathsf{T}V^{-1}X=2/1.8+1=2.1111\). For the numerator, the first two observations contribute \((1+3)/1.8=2.2222\), and the third contributes 4, giving \(X^\mathsf{T}V^{-1}y=6.2222\).

$$ \hat{\beta}_{\mathrm{GLS}} =\frac{6.2222}{2.1111} =2.947. $$

The GLS mean is 2.947 outcome units. The correlated pair has average 2 and contributes total weight \(2/1.8=1.1111\), while the independent individual contributes weight 1. The estimate is therefore \(\{1.1111(2)+1(4)\}/(1.1111+1)=2.947\). The variance is \(1/2.1111=0.4737\) squared outcome units. By contrast, the unweighted average is \(8/3=2.667\); it gives the pair the same total weight as two independent observations. GLS reflects that the pair supplies less independent information.

Interpretation, Scope, and Common Pitfalls

GLS separates the fixed-effect design from the covariance weighting. The columns of \(X\) specify which fixed effects are being estimated; \(V\) specifies how outcome deviations co-vary across observations. A coefficient is interpreted in the scale and units of its outcome and covariate, conditional on the other columns in \(X\). Its standard error describes sampling variability under the specified \(V\), not uncertainty about whether \(V\) itself is correct.

In genetic applications, relatedness can make a group of individuals less informative than the same number of independent individuals. Covariates can also be correlated with patterns in \(V\), so GLS estimates may differ from ordinary least-squares estimates, not merely have different standard errors. A correctly chosen covariance model is therefore central to calibrated fixed-effect inference. In practice, variance components often need to be estimated; the formulas here do not prescribe how to estimate them.

  • Wrong reasoning: “There are \(n\) individuals, so the intercept variance is the residual variance divided by \(n\).” Correction: That shortcut assumes independent observations with a common variance. With general \(V\), the intercept variance is \((1^\mathsf{T}V^{-1}1)^{-1}\).
  • Wrong reasoning: “A GLS coefficient is automatically causal because relatedness has been modeled.” Correction: GLS adjusts the weighting and covariance under the stated model. Causal interpretation requires additional design and identification assumptions.
  • Wrong reasoning: “A smaller GLS standard error proves the covariance model is better.” Correction: The standard error is conditional on the specified covariance. A misspecified \(V\) can produce misleading uncertainty, even when the formula has been computed correctly.
  • Wrong reasoning: “The ordinary mean and GLS mean must differ whenever observations are correlated.” Correction: They can coincide in special designs, as in the two-person equal-variance example, even though their variance calculations differ.
Key takeaway: For fixed effects with observation covariance \(V\), use \( (X^\mathsf{T}V^{-1}X)^{-1}X^\mathsf{T}V^{-1}y \) for the GLS estimate and \( (X^\mathsf{T}V^{-1}X)^{-1} \) for its covariance. Interpret both as conditional on the specified covariance model.

Check Your Understanding

Use the model assumptions and calculations in this tutorial to answer the following questions.

  1. Why must \(X\) have full column rank and \(V\) be positive definite for the displayed GLS estimator to exist?
  2. In the two-individual intercept example, why does the estimated mean equal the ordinary average while its variance differs from the variance under independence?
  3. In the covariate-adjustment example, what are the units and conditional interpretation of the covariate coefficient?
  4. Explain why the correlated pair in the three-individual example contributes less total information than two independent observations.
  5. Which assumption justifies treating the GLS covariance matrix as the estimator’s sampling covariance, and what does that covariance not account for when \(V\) is estimated from data?
Clinical Biostats