Tutorials › Generalized Linear Mixed Models (GLMM) › Nested Fixed-Effect Models and Likelihood-Ratio Tests

Testing Fixed and Random Effects · Tutorial 355 of 698

Nested Fixed-Effect Models and Likelihood-Ratio Tests

Learn to identify valid nested fixed-effect comparisons in GLMMs and express the likelihood-ratio statistic and its reference degrees of freedom.

Advanced 12 min read

What You'll Learn

  • Define nesting through restrictions on a larger model’s fixed-effect parameters.
  • Check that the response, observations, random-effects structure, and likelihood basis match.
  • Formulate the likelihood-ratio statistic from maximized marginal likelihoods.
  • Relate the degrees of freedom to the number of independent fixed-effect restrictions.
  • Recognize when a model comparison is not a valid fixed-effect likelihood-ratio test.

Why Nesting Matters

A fixed-effect test often asks whether a collection of terms improves the model after accounting for clustering. The likelihood-ratio test (LRT) answers this by comparing a reduced GLMM with a larger one that contains it. The comparison is meaningful only when the reduced model is genuinely a special case of the larger model, and when both likelihoods refer to the same data and model structure.

For this tutorial, the focus is on identifying that relationship and writing the comparison correctly. The central question is not simply whether one model has more predictors. It is whether the smaller model can be obtained from the larger model by imposing restrictions on its fixed effects while leaving the rest of the model unchanged.

Definition of Nested Fixed-Effect Models

Let \(Y\) denote the observed responses, \(X\) the fixed-effect design matrix, and \(b\) the random effects. A GLMM specifies a conditional response distribution given \(b\), a link connecting its conditional mean to fixed and random effects, and a distribution for \(b\). For example, a common linear predictor is \(X\beta+Zb\), where \(Z\) is the random-effect design matrix.

The likelihood used for ordinary fixed-effect comparisons is the marginal likelihood: it averages the conditional response likelihood over the random-effects distribution. Thus, when the random-effects distribution has density \(f(b;\theta)\), the marginal likelihood has the form below. Here \(\beta\) denotes fixed-effect parameters and \(\theta\) denotes random-effect distribution parameters.

$$ L(\beta,\theta;Y) = \int \left\{\prod_{i=1}^{n} f(Y_i\mid b;\beta)\right\} f(b;\theta)\,db $$

The product notation assumes conditional independence of the responses given the random effects; the integral accounts for their dependence after the random effects are integrated out. A model’s maximized likelihood is the largest value of this marginal likelihood over its allowed fixed-effect and random-effect parameters.

Definition: A reduced fixed-effect model is nested in a full fixed-effect model when it can be obtained by imposing one or more restrictions on the full model’s fixed-effect parameters, with the response distribution, observed data, link, offset (if any), and random-effects structure held fixed. The restrictions must leave the reduced model’s possible distributions for the observations contained within those of the full model.

For example, if the full model has fixed effects \(\beta_0,\beta_1,\beta_2\) and the reduced model omits the term associated with \(\beta_2\), then the reduced model is obtained by the restriction \(H_0:\beta_2=0\), provided the other model components are unchanged. More generally, the null hypothesis may impose several independent linear restrictions on the full model’s fixed-effect parameters.

The same idea can be expressed through design spaces: the reduced fixed-effect design must span a subspace of the full model’s fixed-effect design. Different contrast codings do not by themselves make models different if they span the same space. Conversely, merely using fewer named terms does not establish nesting if the models’ design spaces are not contained one within the other.

Formulating the Likelihood-Ratio Comparison

Write \(L_R\) for the likelihood maximized under the reduced model and \(L_F\) for the likelihood maximized under the full model. Because the reduced parameter space is contained in the full parameter space, the full model can reproduce every fit available to the reduced model. Therefore \(L_F\geq L_R\).

$$ \lambda=\frac{L_R}{L_F}\leq 1, \qquad D=-2\log(\lambda) =2\{\ell_F-\ell_R\}, \qquad \ell_F=\log L_F,\quad \ell_R=\log L_R $$

The statistic \(D\) is nonnegative; larger values indicate that the full model improves the maximized likelihood more than would be expected from the restrictions in the reduced model. Under the null hypothesis and suitable regularity conditions, \(D\) is commonly compared with a chi-square reference distribution. Its degrees of freedom are the number of independent restrictions imposed on the full model, equivalently the difference in the effective dimensions of the two fixed-effect parameter spaces.

This reference is an asymptotic result, not an automatic guarantee for every fitted GLMM. It requires, among other conditions, identifiable parameters, a null value that is not on a parameter-space boundary, and a sufficiently informative sample for the approximation to be useful. Testing a fixed effect while keeping the random-effects structure fixed is distinct from testing a variance component, where boundary issues can change the reference distribution.

Worked Comparisons

Worked Example: Testing One Treatment Coefficient

Suppose hypothetical binary outcomes are observed in 40 clinics. Both models use a logit link and the same clinic random-intercept distribution, \(b_j\sim N(0,\sigma_b^2)\). The reduced model has an intercept and a baseline covariate; the full model adds a treatment indicator with coefficient \(\beta_T\). The null is \(H_0:\beta_T=0\).

The treatment term is the only change, so the reduced model is nested in the full model. Assume the maximized marginal log likelihoods are \(\ell_R=-102.4\) and \(\ell_F=-98.9\). Then

$$ D=2\{\ell_F-\ell_R\} =2\{-98.9-(-102.4)\} =2(3.5)=7.00. $$

There is one independent restriction, so the reference distribution is \(\chi^2_1\), subject to the regularity and approximation conditions just described. The upper-tail probability is approximately \(P(\chi^2_1\geq7.00)=0.0082\). In this hypothetical comparison, the evidence is inconsistent with \(H_0\) at the 0.05 level. The comparison supports an association between treatment assignment and the conditional outcome in this model; it does not by itself establish a causal effect.

Worked Example: Testing a Multi-Level Factor

Consider hypothetical counts from patients nested within hospitals. Both Poisson log-link GLMMs use the same hospital random intercept, the same offset for exposure time, and the same observations. The full model includes a four-level care-setting factor, while the reduced model omits it. Using one level as the reference, the factor contributes three independent fixed-effect coefficients. The joint null sets all three coefficients to zero.

Suppose the maximized log likelihoods are \(\ell_R=-211.6\) and \(\ell_F=-207.2\). The likelihood-ratio statistic is

$$ D=2\{-207.2-(-211.6)\} =2(4.4)=8.80. $$

The restriction count is three, so the comparison uses \(\chi^2_3\) as its approximate null reference. Its upper-tail probability at 8.80 is about 0.032. At a 0.05 significance level, this hypothetical result provides evidence that at least one care-setting coefficient differs from zero, conditional on the other model terms. It does not identify which level differs; that requires follow-up contrasts or another targeted analysis.

Worked Example: Testing an Interaction Block

Suppose a hypothetical study records a count outcome from patients grouped in clinics. Both candidate models use a Poisson log-link, the same clinic random-intercept structure, the same offset, and the same observations. Both include treatment and a continuous baseline score as main effects. The full model adds their interaction. With treatment coded as a two-level factor, the interaction adds one slope coefficient, \(\beta_{TS}\), and the reduced model is obtained by setting \(\beta_{TS}=0\).

Assume the fitted maximized log likelihoods are \(\ell_R=-74.30\) and \(\ell_F=-70.95\). Substitution gives

$$ D=2\{-70.95-(-74.30)\} =2(3.35)=6.70. $$

There is one restriction. The approximate \(\chi^2_1\) upper-tail probability is about 0.0096. Under the stated model and regularity conditions, this is evidence against the null of no treatment-by-score interaction. In context, it indicates that the association between baseline score and the modeled expected count differs by treatment group; it does not imply that treatment caused that difference.

Justification: Why the Statistic Cannot Be Negative

The nonnegativity follows directly from nesting, not from a special property of GLMM software. Let \(\Theta_R\) and \(\Theta_F\) be the reduced and full parameter spaces, including all parameters allowed to vary in the comparison. Nesting means that every reduced-model parameter value corresponds to an allowed full-model value, so \(\Theta_R\subseteq\Theta_F\). Taking a supremum over a larger set cannot yield a smaller maximum:

$$ \sup_{\psi\in\Theta_F} L(\psi;Y) \geq \sup_{\psi\in\Theta_R} L(\psi;Y), \qquad L_F\geq L_R. $$

Since the logarithm is increasing, \(\ell_F\geq\ell_R\), hence \(D=2(\ell_F-\ell_R)\geq0\). If software reports a noticeably negative value, the models may not actually be nested, the likelihoods may not be comparable, or numerical optimization may have failed to find the relevant maxima.

Checks, Alternatives, and Limitations

Before formulating an LRT, verify that both fits use the same response values and rows, the same conditional response family and link, and the same random-effects structure and likelihood basis. The full model must add only the fixed-effect terms being tested. In particular, changing the random-effects structure at the same time makes it unclear which change accounts for a likelihood difference.

For an ordinary fixed-effect LRT, the likelihoods should be maximized on the same marginal-likelihood basis. Restricted maximum likelihood (REML) criteria are not ordinary likelihoods for direct comparisons across different fixed-effect design spaces. The distinction between ML and REML comparisons is treated separately in the course.

Wald tests are a different approach: they use estimated coefficients and their estimated covariance matrix rather than comparing the two maximized likelihoods. A Wald test may be convenient for a single coefficient, while an LRT naturally assesses a joint block of restrictions. Neither method removes the need to specify the model and null hypothesis correctly. Information criteria can compare candidate models for relative fit with a complexity penalty, but they do not provide the same null-hypothesis test.

Several warning signs deserve attention: the full model’s likelihood is lower than the reduced model’s; one or both fits fail to converge; estimates are extreme or effectively unidentified; or the response rows differ because missing values were handled differently. Sparse binary outcomes or separation can also undermine estimation and the usual large-sample calibration. In such cases, do not treat a computed chi-square probability as automatically reliable; inspect model fitting and consider whether the proposed inferential method is appropriate.

A common mistake is to say, “The full model has more predictors, so it is nested, and the likelihood-ratio test is valid.” More terms alone are not enough. The reduced model must be obtainable from the full model by restrictions, and all other components and data must be held fixed. Another mistake is to interpret a significant joint test as proof that every added coefficient is nonzero. The test addresses the block of restrictions as a whole.

Key takeaway: A fixed-effect likelihood-ratio comparison requires a reduced model contained within a full model, with the random-effects structure and other likelihood-defining components held constant. Form the statistic as twice the difference in maximized log likelihoods, and count the independent fixed-effect restrictions for its asymptotic reference degrees of freedom.

Check Your Understanding

For each question, identify the comparison or calculation and then check the solution.

  1. A full GLMM adds two fixed-effect coefficients to a reduced model. The models use the same observations and all other model components are unchanged. What is the null restriction count?
  2. A reduced model has maximized log likelihood \(-56.8\), and its nested full model has maximized log likelihood \(-53.9\). Calculate the likelihood-ratio statistic.
  3. Two models use the same fixed effects and observations, but one has a random intercept and the other has a random intercept plus a random slope. Is this the fixed-effect comparison defined here?
  4. A full model adds a three-level factor to a model that already has an intercept. How many independent restrictions correspond to omitting that factor, assuming ordinary reference coding and no aliased coefficients?

Solutions. (1) The null imposes two independent restrictions, so the restriction count is 2. (2) \(D=2\{-53.9-(-56.8)\}=2(2.9)=5.80\). (3) No. The random-effects structure changes, so this is not a comparison that differs only in fixed effects. (4) The factor has two independent coefficients relative to the reference level; omitting it imposes two restrictions.

Clinical Biostats