Tutorials › High-Dimensional Genomic Data Analysis › Comparing REML and ML in GWAS Null Models

Mixed-Model GWAS, Relatedness and Inflation Diagnostics · Tutorial 283 of 795

Comparing REML and ML in GWAS Null Models

Learn how ML and REML handle fixed effects differently, how that affects null-model variance estimates in mixed-model GWAS, and how to choose and check a fitting approach.

Advanced 11 min read

What You'll Learn

  • Define the Gaussian mixed model used for a GWAS null model.
  • Distinguish the ML and REML likelihoods and their treatment of fixed effects.
  • Derive the residual-degrees-of-freedom adjustment in a simple model.
  • Work through numerical estimates with and without nuisance covariates.
  • Recognize when REML likelihoods cannot be compared across fixed-effect designs.
  • Identify fitting diagnostics and limitations relevant to null-model estimation.

Why the Choice of Likelihood Matters

A mixed-model GWAS null model estimates variance components before testing each genetic marker. Those estimates determine the covariance structure used to account for relatedness and other modeled sources of variation. Maximum likelihood (ML) and restricted maximum likelihood (REML) use the same Gaussian model but treat the fixed effects differently when estimating that covariance structure. As a result, the estimated variance components can differ, particularly when the number of fixed effects is large relative to the sample size.

The distinction is not that one method accounts for fixed effects and the other ignores them. Both estimate fixed effects. The distinction is how their likelihoods use the information remaining after those effects are fitted. That distinction matters in a GWAS because the null model contains nuisance fixed effects—commonly an intercept and prespecified covariates—but excludes the marker currently being tested.

Model and Assumptions

Definition: In a Gaussian linear mixed model, the phenotype vector \(y\) is modeled as
$$ y=X\beta+u+\varepsilon,\qquad u\sim N(0,\sigma_g^2K),\qquad \varepsilon\sim N(0,\sigma_e^2I). $$
Here \(y\) has \(n\) observations, \(X\) is a known \(n\times p\) fixed-effect design matrix of full column rank, and \(\beta\) is a \(p\)-vector of unknown fixed effects. The random effect \(u\) represents modeled genetic or relatedness-associated variation, \(K\) is a specified positive semidefinite relatedness matrix, and \(\varepsilon\) is residual error. The random effects are independent. Thus \(y\sim N(X\beta,V)\), where \(V=\sigma_g^2K+\sigma_e^2I\).

The model assumes that the mean is correctly represented by \(X\beta\), that the covariance has the stated form, and that the Gaussian distribution is an adequate working model. The variance components are nonnegative, and \(V\) must be positive definite for the usual likelihood calculations. In practice, the observations, phenotype, covariates, and relatedness matrix must also be aligned consistently. A mismatch in sample order or an inappropriate covariance matrix cannot be repaired by choosing REML instead of ML.

For a GWAS null model, \(X\) includes the intercept and the chosen non-genetic or ancestry-related covariates, but not the marker being tested. The covariance parameters \(\theta=(\sigma_g^2,\sigma_e^2)\) are estimated from this model. Once fitted, the null model supplies a covariance estimate for marker association testing. The precise association procedure is not the subject here; the key point is that null-model fitting estimates covariance parameters conditional on a particular fixed-effect design.

What ML and REML Maximize

For a proposed covariance matrix \(V\), ML estimates \(\beta\) by generalized least squares:

$$ \widehat{\beta}(V)=(X'V^{-1}X)^{-1}X'V^{-1}y. $$

Define

$$ P=V^{-1}-V^{-1}X(X'V^{-1}X)^{-1}X'V^{-1}. $$

Then \(y'Py\) is the generalized residual quadratic form after fitting the fixed effects. The ML profile likelihood for the covariance parameters uses this residual fit and the determinant of \(V\):

$$ \ell_{\mathrm{ML}}(\theta) =-\frac{1}{2}\left[n\log(2\pi)+\log|V|+y'Py\right]. $$

REML instead bases covariance estimation on contrasts that remove the fixed effects. Let \(L\) be an \(n\times(n-p)\) matrix of full column rank satisfying \(L'X=0\). Then \(L'y\) has mean zero and covariance \(L'VL\). REML maximizes the likelihood of these error contrasts. Equivalently, for a fixed design \(X\), its log likelihood can be written up to constants independent of \(\theta\) as

$$ \ell_{\mathrm{REML}}(\theta) =-\frac{1}{2}\left[(n-p)\log(2\pi)+\log|V|+ \log|X'V^{-1}X|+y'Py\right]. $$

The determinant term involving \(X\) is part of the adjustment for estimating fixed effects. REML does not simply replace \(n\) by \(n-p\) in every mixed model; the displayed expression shows that its correction also depends on \(V\) and the design matrix. The likelihood is defined relative to a fixed set of contrasts, so its value is not directly comparable across different fixed-effect designs.

A Short Derivation: Why the Simple Variance Estimates Differ

The degrees-of-freedom difference can be seen exactly in the special case \(V=\sigma^2I\), with \(\sigma^2\) the only covariance parameter. For any fixed design \(X\), let

$$ \mathrm{SSE}=(y-X\widehat{\beta})'(y-X\widehat{\beta}). $$

The ML profile likelihood is proportional to \((\sigma^2)^{-n/2}\exp\{-\mathrm{SSE}/(2\sigma^2)\}\). Taking its log and differentiating with respect to \(\sigma^2\) gives

$$ \frac{\partial\ell_{\mathrm{ML}}}{\partial\sigma^2} =-\frac{n}{2\sigma^2}+\frac{\mathrm{SSE}}{2(\sigma^2)^2}=0 \quad\Longrightarrow\quad \widehat{\sigma}_{\mathrm{ML}}^2=\frac{\mathrm{SSE}}{n}. $$

For REML, the contrast vector has dimension \(n-p\), and its covariance is \(\sigma^2L'L\). Its log likelihood, as a function of \(\sigma^2\), contains \(-\frac{n-p}{2}\log(\sigma^2)-\frac{\mathrm{SSE}}{2\sigma^2}\). Differentiating yields

$$ -\frac{n-p}{2\sigma^2}+\frac{\mathrm{SSE}}{2(\sigma^2)^2}=0 \quad\Longrightarrow\quad \widehat{\sigma}_{\mathrm{REML}}^2=\frac{\mathrm{SSE}}{n-p}. $$

Under this independent, equal-variance model, \(\mathrm{SSE}/\sigma^2\) has a chi-squared distribution with \(n-p\) degrees of freedom, so this REML estimate is unbiased for \(\sigma^2\). The ML estimate is smaller on average because it divides by \(n\) even though \(p\) fixed effects were fitted. This exact result explains the basic adjustment, but it does not imply that every REML variance-component estimate is unbiased in a general mixed model.

Worked Example: Intercept-Only Variance Estimation

Suppose a hypothetical phenotype, measured in arbitrary units, is \(2,4,6,8\), and the model contains only an intercept with independent Gaussian errors of common variance. The sample mean is \(\bar{x}=(2+4+6+8)/4=5\). The residuals are \(-3,-1,1,3\), so

$$ \mathrm{SSE}=(-3)^2+(-1)^2+1^2+3^2=20. $$

Here \(n=4\) and \(p=1\). Therefore

$$ \widehat{\sigma}_{\mathrm{ML}}^2=\frac{20}{4}=5.000,\qquad \widehat{\sigma}_{\mathrm{REML}}^2=\frac{20}{4-1}=6.667. $$

Both estimates are in squared phenotype units. ML divides by the number of observations; REML uses the three independent dimensions left after removing the fitted intercept. The difference is substantial in this deliberately small example. With a much larger \(n\) and fixed \(p\), the denominators become relatively similar.

Worked GWAS-Style Null-Model Calculations

Worked Example: A Null Model With a Covariate

Consider a hypothetical four-person GWAS sample with phenotype values \(y=(1,2,4,5)'\). Suppose a prespecified binary nuisance covariate is \(c=(0,1,0,1)'\), and the null model has an intercept and this covariate. For illustration, take the independent-error special case, so \(V=\sigma^2I\); no relatedness variance is estimated in this calculation.

The mean phenotype among observations with \(c=0\) is \((1+4)/2=2.5\), and the mean among observations with \(c=1\) is \((2+5)/2=3.5\). The fitted values are therefore \((2.5,3.5,2.5,3.5)'\), and the residuals are \((-1.5,-1.5,1.5,1.5)'\). Thus

$$ \mathrm{SSE}=(-1.5)^2+(-1.5)^2+(1.5)^2+(1.5)^2=9.000. $$

There are \(n=4\) observations and \(p=2\) fixed effects, so the two variance estimates are

$$ \widehat{\sigma}_{\mathrm{ML}}^2=\frac{9}{4}=2.250,\qquad \widehat{\sigma}_{\mathrm{REML}}^2=\frac{9}{4-2}=4.500. $$

The REML estimate is twice the ML estimate here because only two residual dimensions remain after estimating the intercept and covariate effect. This example checks the full-rank requirement: the covariate is not constant, so its column is not a duplicate of the intercept. In a relatedness-aware null model, \(V\) is not \(\sigma^2I\), and the corresponding estimates require optimizing the mixed-model likelihoods rather than applying these simple residual-variance formulas.

Worked Example: Why REML Values Do Not Compare Across Marker Designs

Use the same hypothetical phenotype \(y=(1,2,4,5)'\). Compare a null fixed-effect design containing only an intercept with a second design containing an intercept and the binary vector \(g=(0,1,0,1)'\), treated here as a candidate marker dosage. This comparison is only to illustrate the likelihood issue; a GWAS null fit would not include the marker being tested.

For the intercept-only design, the fitted mean is \(3\), and the residuals are \((-2,-1,1,2)'\). Hence \(\mathrm{SSE}=4+1+1+4=10\), \(n=4\), and \(p=1\). In the independent-error case, the estimates are

$$ \widehat{\sigma}_{\mathrm{ML},0}^2=\frac{10}{4}=2.500,\qquad \widehat{\sigma}_{\mathrm{REML},0}^2=\frac{10}{3}=3.333. $$

For the design containing the intercept and \(g\), the fitted group means are \(2.5\) and \(3.5\), giving \(\mathrm{SSE}=9\). Now \(p=2\), so

$$ \widehat{\sigma}_{\mathrm{ML},1}^2=\frac{9}{4}=2.250,\qquad \widehat{\sigma}_{\mathrm{REML},1}^2=\frac{9}{2}=4.500. $$

The residual contrasts in the two designs are not the same: the first removes one fixed-effect direction, and the second removes two. Consequently, the two REML likelihoods are based on different contrast spaces. Comparing their numerical values as if they were likelihoods on a common scale is not a valid way to assess whether the marker improves the fixed-effect model. ML likelihoods are the usual likelihood basis for comparing such nested fixed-effect models, subject to the conditions of the comparison; REML is useful for covariance estimation when the fixed-effect design is held fixed.

Implications for Fitting a GWAS Null Model

When the null fixed-effect design is specified in advance and remains the same across a scan, REML is commonly used to estimate mixed-model covariance parameters. It accounts for the dimensions consumed by the fixed effects, which can matter in finite samples. ML is also a valid likelihood method under the model, but its variance-component estimates can be downward-biased in settings where many fixed effects have been estimated. In a general mixed model, the size and direction of the difference depend on the covariance structure and data; the simple denominator correction is not a universal formula.

The choice should follow the inferential task. For estimating covariance parameters under one fixed-effect design, REML is often a sensible default. If the scientific comparison changes the fixed-effect design, REML likelihood values from those designs are not directly comparable; ML is generally used for likelihood-based fixed-effect comparisons. This is a statement about likelihood comparison, not a claim that an ML comparison automatically solves every issue of model selection or test calibration.

A practical null-model fit should specify the fixed effects before estimating variance components. Adding or removing covariates changes the residual space and may change the variance estimates. When comparing fits for a GWAS scan, confirm that the phenotype, sample, fixed-effect design, and covariance structure are consistent. If marker-specific missingness changes the analyzed individuals, the null model and covariance matrix may no longer correspond to the same observations; simply reusing a fit without checking this alignment can be inappropriate.

Diagnostics, Alternatives, and Limitations

REML does not guarantee a well-behaved fit. Variance components can be estimated at a boundary, such as \(\widehat{\sigma}_g^2=0\), or the likelihood can be nearly flat in a direction that makes components difficult to distinguish. A nearly singular \(K\), a poorly conditioned fixed-effect design, or strong overlap between modeled covariance components can make optimization unstable. Inspect convergence information, parameter boundaries, and whether the fitted covariance is positive definite. Check that the covariate design has full column rank and that the intended observations are in the same order in \(y\), \(X\), and \(K\).

The model assumptions also deserve attention. Residual patterns inconsistent with the Gaussian mean or covariance model, influential observations, or a misspecified \(K\) can undermine both ML and REML. These methods estimate parameters within the model supplied; neither corrects confounding or makes an unsuitable covariance structure appropriate. If the phenotype is binary, the Gaussian model described here may be inappropriate, and methods for non-Gaussian mixed models require their own likelihood and estimation considerations.

ChoiceUseful whenMain caution
REMLEstimating covariance parameters with a fixed-effect design held constantRestricted likelihoods from different fixed-effect designs are not directly comparable
MLLikelihood-based comparisons that change fixed effects, under appropriate model-comparison conditionsVariance estimates can be downward-biased in finite samples when fixed effects are estimated

A frequent mistake is to say, “REML is always unbiased, so it is always the right choice.” The correction is narrower: REML removes fixed-effect directions from the likelihood, and in the simple independent Gaussian model it gives the unbiased residual variance estimate. General mixed-model REML estimates are not guaranteed to be unbiased, and the choice still depends on whether the goal is covariance estimation or comparison of fixed-effect structures.

Key takeaway: For a GWAS null model with a fixed, prespecified covariate design, REML is commonly used to estimate variance components while accounting for fixed-effect estimation. ML and REML need not give the same estimates. Do not compare REML likelihood values across models with different fixed-effect designs as though they were on a common scale.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. In a Gaussian model with \(n=20\), \(p=4\), and \(\mathrm{SSE}=64\), calculate the ML and REML estimates of the independent residual variance.
  2. Why does REML use contrasts satisfying \(L'X=0\)?
  3. A GWAS analyst compares REML likelihood values from a null model and a model that adds the tested marker. What is the problem with that comparison?
  4. Name two checks that can reveal a problematic mixed-model null fit.

Solutions. (1) The independent-error formulas give \(\widehat{\sigma}_{\mathrm{ML}}^2=64/20=3.200\) and \(\widehat{\sigma}_{\mathrm{REML}}^2=64/(20-4)=4.000\), in squared phenotype units. (2) Because \(L'X=0\), the fixed-effect mean is removed: \(E(L'y)=L'X\beta=0\). REML uses the remaining contrasts to estimate covariance parameters. (3) The fixed-effect design changes, so the models use different residual contrast spaces and their restricted likelihood values are not directly comparable; ML is generally used for such fixed-effect likelihood comparisons under appropriate conditions. (4) Examples include checking optimizer convergence and boundary estimates, confirming that \(X\) has full column rank, verifying sample and matrix alignment, and checking that the fitted covariance is positive definite.

Clinical Biostats