Tutorials › Generalized Linear Mixed Models (GLMM) › Testing Fixed Effects While Holding Random Structure Fixed

Testing Fixed and Random Effects · Tutorial 368 of 698

Testing Fixed Effects While Holding Random Structure Fixed

You will learn how to isolate a fixed-effect hypothesis by changing only the fixed-effects specification and how to assess the resulting likelihood-ratio test.

Advanced 12 min read

What You'll Learn

  • Define what it means for two GLMMs to share the same random-effects structure.
  • Check whether fixed-effect specifications are nested and use the same observations and response model.
  • Calculate and interpret a likelihood-ratio statistic for a fixed-effect hypothesis.
  • Identify regularity conditions that support a chi-square reference distribution.
  • Recognize why changing random effects between fits prevents attributing a likelihood difference solely to fixed effects.
  • Diagnose convergence, sparse-data, and model-specification problems that can undermine a comparison.

Why Hold the Random Structure Fixed?

A GLMM separates systematic differences in the conditional mean from variation associated with clusters or other grouping units. When the scientific question concerns a fixed effect, the comparison should change the fixed-effects specification while leaving the random-effects structure unchanged. Otherwise, the difference in fit can reflect either change, and it is not isolated evidence about the fixed-effect hypothesis.

For example, suppose patient outcomes are clustered within clinics. A comparison of a model with treatment and clinic random intercepts against a model without treatment but with the same clinic random intercepts addresses whether treatment contributes to the fixed-effects specification, conditional on that random-effects model. It does not test whether the random intercept is needed, nor does it establish that the chosen random-effects model is correct.

Definition: Two GLMM specifications have the same random-effects structure when they use the same grouping factors, random-effect terms and design structure, distributional assumptions for the random effects, and covariance constraints. The random-effect covariance parameters are generally estimated anew in each fit; they need not have the same estimated values.

For cluster \(i\), a common representation is \(g\{E(Y_{ij}\mid b_i)\}=x_{ij}^{T}\beta+z_{ij}^{T}b_i+o_{ij}\), where \(g\) is the link, \(x_{ij}\) and \(z_{ij}\) are the fixed- and random-effect design vectors, \(b_i\) is a random effect, and \(o_{ij}\) is an offset if present. Holding the random structure fixed means retaining the same specification for \(z_{ij}\) and the distribution and covariance structure of \(b_i\), while changing the columns or restrictions in the fixed-effects design.

Conditions for a Fixed-Effect Comparison

The usual likelihood-ratio comparison is most straightforward when the models are nested: the reduced model is obtained by imposing \(q\) restrictions on the fixed effects of the full model. For example, dropping one coefficient imposes one restriction, while removing a categorical predictor represented by three coefficients imposes three restrictions jointly. The two models must use the same outcome observations and the same conditional response distribution, link, offset, and random-effects structure.

For GLMMs, the likelihood used for this test is the likelihood of the observed data after integrating over the random effects. The nuisance parameters, including random-effect covariance parameters, are estimated separately under each fixed-effects specification. Thus, “holding the random structure fixed” means holding its form fixed, not forcing its estimated variance components to be numerically identical.

Theorem: Let \(M_0\) be a reduced GLMM and \(M_1\) a nested full GLMM that differs only by \(q\) fixed-effect restrictions. If both models use the same observations and response model, the random-effects structure is identical, the likelihoods are maximized on the same basis, and the null parameter is regular and interior, then under \(H_0\), the likelihood-ratio statistic is asymptotically distributed as \(\chi^2_q\).

Regularity matters. The fitted models should be identifiable, the likelihood should be sufficiently smooth near the null value, and the estimates should not be constrained by a boundary or otherwise be nonregular. Sparse binary outcomes, separation, very few independent clusters, or poorly identified covariance parameters can make the chi-square approximation unreliable. Holding random effects constant across the comparison does not remove those problems.

Likelihood-Ratio Statistic and Its Justification

Write \(\ell_0\) and \(\ell_1\) for the maximized log likelihoods under the reduced and full models, respectively. Because every parameter value allowed by the reduced model is also allowed by the full model, maximization gives \(\ell_1\geq\ell_0\). The likelihood-ratio statistic is therefore nonnegative:

$$ G^2 = 2(\ell_1-\ell_0). $$

Under the null hypothesis, the full model contains \(q\) additional fixed-effect directions that do not improve the population fit beyond random sampling variation. Locally, the log likelihood is approximated by a quadratic function of the parameter displacement. After scaling by its information, the \(q\) unrestricted directions contribute the sum of \(q\) squared, approximately standard-normal quantities. That sum has a \(\chi^2_q\) distribution, which gives the reference law in the theorem. This argument requires regularity; it is not a guarantee for small or irregular samples.

The p-value is the probability, assuming \(H_0\) and the reference approximation, of observing a statistic at least as large as the one calculated. A small p-value is evidence against the restrictions in \(M_0\), not a probability that \(H_0\) is true. The degrees of freedom are the number of independent fixed-effect restrictions, not the number of clusters or observations.

Worked Example: Testing One Treatment Coefficient

Consider hypothetical binary outcomes from 480 patients in 24 clinics. The outcome is whether a patient experiences a specified event; treatment is coded 0 or 1, and baseline severity is included as a covariate. Both candidate logistic GLMMs include a clinic random intercept with the same distributional specification. The reduced model includes severity but omits treatment; the full model includes both severity and treatment. The fits use the same 480 patients and report maximized marginal log likelihoods \(\ell_0=-245.10\) and \(\ell_1=-241.80\).

The models are nested, and the only fixed-effect restriction is that the treatment coefficient equals zero, so \(q=1\). The likelihood-ratio statistic is

$$ G^2=2\{\ell_1-\ell_0\} =2\{-241.80-(-245.10)\} =2(3.30)=6.60. $$

Using a \(\chi^2_1\) reference distribution gives \(p\approx0.0102\). At significance level \(\alpha=0.05\), reject \(H_0:\beta_{\text{treatment}}=0\). These hypothetical results provide evidence that adding treatment improves fit, conditional on the specified model. They do not establish causation, quantify the treatment effect on their own, or demonstrate that the clinic random-intercept structure is adequate.

Worked Example: Joint Test of a Three-Level Factor

Suppose a hypothetical study records a binary outcome for 300 participants in 20 centers. A three-level program factor is represented by two indicator coefficients, and age is included in both models. Both models use the same centers, observations, logistic response model, and center random-intercept structure. The reduced model omits the program factor; the full model includes both program indicators. Suppose the maximized log likelihoods are \(\ell_0=-183.10\) and \(\ell_1=-180.40\).

The null hypothesis is that both program coefficients equal zero. There are \(q=2\) restrictions, so the test is a joint test of the factor rather than two separate tests. The statistic is

$$ G^2=2\{-180.40-(-183.10)\}=2(2.70)=5.40. $$

For \(\chi^2_2\), the upper-tail probability is approximately \(0.0672\). At \(\alpha=0.05\), do not reject the joint null hypothesis. The observed likelihood improvement is not sufficiently large for this test to reject at that level. This conclusion does not prove that the program has no association with the outcome; it reports the result of this joint test under its assumptions.

What Goes Wrong When the Random Structure Changes?

A likelihood difference is not a clean fixed-effect test if one fit has a random intercept and the other has both a random intercept and a random slope. The larger model has changed the fixed-effects question and the modeled dependence structure at once. Even when the specifications can be arranged as nested models in a broader sense, the resulting comparison does not isolate the fixed-effect hypothesis, and the usual degrees of freedom and reference distribution may not apply.

Worked Example: A Tempting but Invalid Attribution

In a hypothetical binary-outcome analysis of 200 observations from 10 clinics, a treatment coefficient is included in the full fixed-effects specification. One fit uses a clinic random intercept, while a second fit adds a clinic-specific random treatment slope. Suppose their log likelihoods are \(-101.0\) and \(-99.0\), respectively. The numerical difference gives \(2\{-99.0-(-101.0)\}=4.00\).

It would be wrong to report this as a one-degree-of-freedom test of the treatment fixed effect. The fixed-effects specification has not been described as the sole change: the random-effects structure also differs. The difference of 4.00 reflects the fit of two distinct model specifications, not an isolated treatment test. Moreover, adding a variance component can introduce boundary-related complications. To test the fixed treatment effect, refit the reduced and full models with the same random-intercept structure (or another prespecified common structure), changing only the fixed treatment term.

Diagnostics, Alternatives, and Limits

Before interpreting a result, verify that both fits converged, that the reported likelihoods correspond to the intended models, and that the same observations were used. Check for warnings, extreme estimates, large standard errors, separation in binary outcomes, and evidence that the random-effects structure is weakly identified. A singular or near-singular covariance estimate is a warning that the assumed structure may be difficult to estimate; it does not by itself prescribe a different fixed-effect test. If the response is sparse or the number of independent clusters is small, the asymptotic p-value may be poorly calibrated.

The likelihood-ratio test is one approach, not the only one. A Wald test evaluates an estimate relative to its estimated standard error and can be convenient for a single coefficient, but it may be sensitive to small-sample approximations. A joint Wald test can assess multiple coefficients. Comparing information criteria addresses a model-selection objective rather than a null-hypothesis test. These alternatives answer related but not identical questions; none makes a changed random structure an isolated fixed-effect comparison.

The key limitation is conditionality on the model choices. A significant result does not validate the link, the random-effects distribution, or the selected covariance structure. A nonsignificant result may reflect limited information rather than a negligible effect. Report the fixed-effect hypothesis, the shared random structure, the likelihood-ratio statistic, degrees of freedom, p-value, and the practical effect estimate with an appropriate interval when the goal includes effect size.

Common pitfall: “The full model has a larger likelihood, so the added fixed effect is supported.” The full model will have a likelihood at least as large when it contains the reduced model, even if the improvement is only random variation. Use the likelihood-ratio statistic and its justified reference distribution, and ensure that the compared models differ only in the fixed-effect restrictions being tested.

Check Your Understanding

Answer each question using the model-comparison principles above.

  1. A full model adds two fixed-effect coefficients to a reduced model. Both use the same data and random structure. What are the degrees of freedom for the usual likelihood-ratio test?
  2. The reduced and full models have log likelihoods \(-72.6\) and \(-69.9\). Calculate \(G^2\).
  3. Why should random-effect covariance parameters be re-estimated in each model rather than fixed to the same estimated numbers?
  4. A model comparison changes both the fixed treatment term and the random-slope structure. Can its likelihood-ratio statistic be interpreted as an isolated test of the treatment fixed effect?

Solutions. (1) \(q=2\), because the full model adds two independent fixed-effect restrictions under the null. (2) \(G^2=2\{-69.9-(-72.6)\}=2(2.7)=5.40\). (3) The structure is held fixed, but its covariance parameters are nuisance parameters whose values may differ when the fixed effects change; each model’s likelihood must be maximized within that model. (4) No. Both the fixed and random specifications changed, so the comparison does not isolate the treatment fixed-effect hypothesis.

Clinical Biostats