Tutorials › Generalized Linear Mixed Models (GLMM) › Likelihood-Ratio Test for a Random-Intercept Variance

Testing Fixed and Random Effects · Tutorial 375 of 698

Likelihood-Ratio Test for a Random-Intercept Variance

Learn to formulate and compute a likelihood-ratio test for a random-intercept variance, and understand why its null distribution may not be the usual chi-square distribution.

Advanced 12 min read

What You'll Learn

  • State the null and alternative hypotheses for a random-intercept variance test.
  • Specify the conditional and marginal likelihoods being compared.
  • Calculate the likelihood-ratio statistic from fitted log likelihoods.
  • Explain why a zero variance violates a key condition for the usual Wilks chi-square reference.
  • Check model comparability, fitting diagnostics, and the interpretation of a boundary estimate.
  • Distinguish ordinary chi-square calibration from boundary-aware inference.

Why Test a Random-Intercept Variance?

A random intercept represents unexplained differences in outcome level between clusters, such as clinics, schools, or patients observed repeatedly. Testing its variance asks whether the data support this source of between-cluster heterogeneity, given the fixed effects and other model components. The question is not whether a particular cluster effect is nonzero: the target is the population variance of the random intercepts.

This test has a complication that ordinary fixed-effect likelihood-ratio tests do not: a variance cannot be negative. The null value of zero is therefore at the edge of the allowed parameter space, rather than in its interior. That boundary matters when deciding how to calibrate the test statistic.

Definition: For clusters \(i=1,\ldots,m\) and observations \(j=1,\ldots,n_i\), a random-intercept GLMM can be written as $$ g\{E(Y_{ij}\mid b_i)\}=x_{ij}^{T}\beta+b_i,\qquad b_i\sim N(0,\tau^2). $$ Here \(g\) is the link function, \(x_{ij}\) is the fixed-effect design vector, \(\beta\) is the fixed-effect coefficient vector, and \(\tau^2\geq 0\) is the random-intercept variance. Conditional on the random effects, outcomes are assumed independent and follow the specified response distribution. The marginal likelihood is obtained by integrating each cluster's conditional likelihood over the distribution of its random intercept.

For the test considered here, the fixed-effects design, response distribution, link, and any other model components are held the same in both models. The null model sets \(\tau^2=0\); the alternative estimates \(\tau^2\) subject to \(\tau^2\geq0\). Under the null, the random intercept is degenerate at zero, so there is no random-intercept variation. The alternative allows positive variation.

Hypotheses: $$ H_0:\tau^2=0 \qquad\text{versus}\qquad H_a:\tau^2>0. $$ The null and alternative are nested: the null model is included in the alternative model at its boundary value \(\tau^2=0\).

Constructing the Likelihood-Ratio Test

Let \(\ell_0\) be the maximized marginal log likelihood under \(H_0\), and let \(\ell_1\) be the maximized marginal log likelihood under the alternative, with \(\tau^2\) constrained to be nonnegative. The likelihood-ratio statistic is

$$ T=2(\ell_1-\ell_0). $$

The comparison must use the same observations, response model, link, and fixed-effects structure in both fits. In particular, changing fixed effects at the same time as testing \(\tau^2\) would make the likelihood difference address more than the random-intercept variance. For a GLMM variance comparison, use comparable maximized likelihoods; likelihood criteria that do not represent the same likelihood are not interchangeable.

The statistic cannot be negative. The alternative permits the null value \(\tau^2=0\), so maximizing over its parameter space cannot produce a smaller likelihood than maximizing under the null alone. Thus \(\ell_1\geq\ell_0\) and \(T\geq0\). If the fitted alternative places \(\hat{\tau}^2\) at zero, the two maximized likelihoods coincide and \(T=0\).

1
Fit the null model.
Keep the specified fixed effects and other components, but set the random-intercept variance to zero. Record its maximized log likelihood, \(\ell_0\).
2
Fit the alternative model.
Use the same data and fixed-effects structure, estimate \(\tau^2\geq0\), and record \(\ell_1\) and \(\hat{\tau}^2\).
3
Calculate and calibrate.
Compute \(T=2(\ell_1-\ell_0)\). Choose a null reference distribution appropriate to the boundary problem rather than assuming automatically that the regular fixed-effect reference applies.

Why the Usual Chi-Square Argument Is Not Automatic

For many regular likelihood-ratio tests, Wilks' theorem gives an asymptotic chi-square reference distribution, with degrees of freedom determined by the number of restrictions. A central condition is that the null parameter value lies in the interior of a smooth parameter space: locally, small changes in the tested parameter must be possible in both directions.

That condition fails here. The variance parameter must satisfy \(\tau^2\geq0\), so at \(H_0:\tau^2=0\) a negative perturbation is not allowed. The likelihood near the null is therefore not being compared along the same two-sided local parameter space assumed in the ordinary chi-square argument. The random-intercept distribution also collapses to a point at the null. Consequently, treating \(T\) as automatically having a \(\chi^2_1\) distribution is not justified just because one variance parameter is being tested.

A familiar regularity check helps clarify the issue. If a parameter were free to move either above or below its null value, one restriction would commonly lead to a one-degree-of-freedom chi-square reference under the usual large-sample conditions. A variance is different: its allowed local movement at zero is one-sided. The number of parameters alone does not repair this failure of the regularity conditions. The appropriate boundary calibration depends on the model and inferential assumptions.

Worked Example: A Binary Outcome Across Clinics

Hypothetical data and fits. Suppose 480 patients, 20 from each of 24 clinics, have binary outcomes. Both models include the same treatment indicator and age as fixed effects, with a logit link. The null model has maximized log likelihood \(\ell_0=-152.80\). The random-intercept alternative has \(\ell_1=-150.90\) and \(\hat{\tau}^2=0.31\), on the log-odds intercept scale.

The likelihood-ratio statistic is $$ T=2\{\ell_1-\ell_0\} =2\{-150.90-(-152.80)\} =2(1.90) =3.80. $$

For comparison only, a \(\chi^2_1\) upper-tail calculation gives approximately \(P(\chi^2_1\geq3.80)=0.0513\). This is not, by itself, a justified p-value for this variance test: the null is on the boundary, so the ordinary \(\chi^2_1\) reference may not apply. The calculation shows why the reference choice can affect a borderline conclusion; it does not establish a rejection at significance level \(\alpha=0.05\). A boundary-appropriate calibration is needed before reporting an inferential conclusion.

Assumptions and Fitting Checks

The likelihood-ratio calculation is simple, but its meaning depends on the model and the comparison being defensible. Important conditions include:

  • Independent clusters. The likelihood generally treats different clusters as independent. Dependence between clusters not represented in the model can undermine the likelihood calculation.
  • A suitable conditional response model. The chosen response distribution and link should be reasonable, and the assumed conditional independence of observations within a cluster, given its random intercept and covariates, should be plausible.
  • A suitable random-intercept distribution. The stated model assumes normally distributed cluster intercepts with common variance \(\tau^2\). Poor fit or major departures can affect the test's behavior and interpretation.
  • Comparable nested fits. The data and fixed-effects structure must be held constant, and the alternative must include the null as \(\tau^2=0\). Optimizer failure or inaccurate integration can make the likelihood difference unreliable.
  • Enough information for the intended calibration. Asymptotic reference results are not guarantees of accurate finite-sample behavior. The number of independent clusters is especially relevant to information about between-cluster variation.

Inspect the estimated variance, convergence messages, gradients, and whether the optimizer is at a boundary. A variance estimate at zero can be a legitimate fit, not necessarily a software error; it can also signal weak information about heterogeneity. Conversely, a small positive estimate is not proof that a random intercept is needed. The test statistic and its calibrated reference distribution, not the variance estimate alone, govern the test decision.

Worked Example: A Positive Statistic Is Not a Complete Test

Hypothetical data and fits. Suppose a binary response is recorded for 300 pupils in 15 schools. Both models contain the same fixed intercept and a school-level predictor. Their maximized log likelihoods are \(\ell_0=-88.40\) without a random intercept and \(\ell_1=-86.30\) with one; the fitted variance is \(\hat{\tau}^2=0.18\).

The calculation is $$ T=2\{-86.30-(-88.40)\}=2(2.10)=4.20. $$ The ordinary \(\chi^2_1\) upper-tail probability is about \(0.0404\). Reporting this as the test p-value and rejecting at \(\alpha=0.05\) would assume the regular chi-square reference without addressing the boundary. The correct next step is to use a calibration justified for this boundary test and these data, then compare its p-value with \(0.05\). The statistic alone does not decide the test.

Before interpreting even that statistic, verify that both fits used all 300 pupils, the same fixed effects and response specification, and converged adequately. If the alternative fit changed the school-level predictor or failed to maximize the likelihood, the subtraction would not isolate the random-intercept variance as intended.

Worked Example: The Alternative Estimate Is at Zero

Hypothetical data and fits. Suppose 160 observations come from 20 clusters. A common fixed-effects structure is used in both models. The null fit has \(\ell_0=-104.60\); after fitting the alternative subject to \(\tau^2\geq0\), the software reports \(\hat{\tau}^2=0\) and \(\ell_1=-104.60\).

Then $$ T=2\{-104.60-(-104.60)\}=0. $$ There is no likelihood improvement from allowing a positive variance in this fit. The result is not evidence that the true variance is exactly zero: it says that the constrained alternative's maximized likelihood occurs at the null value for these data. Nor does it establish that all clusters have identical underlying outcome levels. Any inferential p-value should still follow the chosen null calibration; for a right-tail test with a nonnegative statistic, an observed value of zero is not evidence against \(H_0\).

Alternatives, Limitations, and Common Mistakes

The likelihood-ratio approach compares the best-fitting models directly and respects the constraint \(\tau^2\geq0\) during fitting. It is often more natural here than a Wald test based on an estimate divided by a standard error: at a boundary, a symmetric, approximately normal estimate is not a safe default. But using a likelihood ratio does not remove the boundary problem; calibration remains essential. A score-based test is another possible approach, but it too requires an appropriate reference distribution and assumptions. For small or unusual samples, simulation-based calibration may be considered, provided the simulation design and fitted null model are suitable.

The test also answers a limited question. It assesses evidence for this random-intercept variance under the specified conditional model and fixed-effects structure. It does not test whether the fixed effects are correct, establish a causal effect, or guarantee that the random-intercept distribution captures every form of cluster dependence. When model fit is poor or there are very few independent clusters, a nominal asymptotic result may be a poor guide.

Common mistake: “One variance parameter is tested, so the likelihood-ratio statistic must have a \(\chi^2_1\) distribution.” The correction is that the ordinary Wilks result requires regularity conditions, including an interior null value. Since \(\tau^2=0\) is a boundary of the allowed parameter space, the usual reference cannot be assumed. Report the statistic, state the calibration used, and justify that calibration for the setting.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. State the null and alternative hypotheses when testing a single random-intercept variance.
  2. Two comparable fitted models have \(\ell_0=-72.5\) and \(\ell_1=-70.9\). Calculate \(T\). What additional issue must be addressed before using it for a test decision?
  3. Explain in one sentence why the usual regular \(\chi^2_1\) reference is not automatic for this test.
  4. An alternative fit reports \(\hat{\tau}^2=0\) and the same maximized log likelihood as the null fit. Calculate the likelihood-ratio statistic and interpret it carefully.
  5. Name two model-comparison checks that should be made before interpreting the statistic.

Solutions. (1) \(H_0:\tau^2=0\) versus \(H_a:\tau^2>0\). (2) \(T=2\{-70.9-(-72.5)\}=2(1.6)=3.20\). A boundary-appropriate null reference must be justified; the ordinary \(\chi^2_1\) reference is not automatic. (3) Zero is the boundary of the allowed nonnegative variance space, whereas the regular Wilks argument requires an interior null value. (4) \(T=2(\ell_1-\ell_0)=0\); the alternative gives no likelihood improvement and its constrained maximum is at the null value, but this does not prove the population variance is zero. (5) For example, check that both fits used the same observations and fixed-effects structure, that the models are nested, and that both fits converged adequately.

Clinical Biostats