Why the Fitted Log Likelihoods Matter
A likelihood-ratio test compares two models fitted to the same response data. In a generalized linear mixed model (GLMM), this comparison requires care: the likelihood used for inference is generally the marginal likelihood, which accounts for the random effects by integrating them out. The statistic is simple to calculate once the right pair of fitted likelihoods has been identified, but a subtraction of software output is meaningful only when the models and fits are genuinely comparable.
The task here is to construct that statistic and identify the number of restrictions it tests. Interpreting its p-value also requires checking whether the usual chi-square approximation is suitable. A computed statistic is not, by itself, a guarantee that the reference distribution is valid.
For a GLMM, the marginal likelihood for cluster \(j\) is obtained by averaging its conditional response likelihood over the random-effects distribution. In a simple notation,
Here \(y_j\) denotes the observed responses in cluster \(j\), \(b_j\) its random effects, and \(\theta\) collects the model parameters. In practice, the integral may be evaluated approximately. The two models must use a compatible likelihood calculation; for example, changing the integration approximation between fits can make a small log-likelihood difference hard to interpret.
Constructing the Statistic and Counting Parameters
The larger model \(M_1\) must include the restricted model \(M_0\) as a special case. For a fixed-effect test, this means that imposing the null restrictions on the larger model recovers the smaller model. The response observations, outcome distribution, link, offset, and other parts of the analysis must be held comparable. If those features change, the difference in fitted log likelihoods can reflect more than the restrictions of interest.
The count \(k_1-k_0\) is the difference in the dimensions of the models’ free parameter spaces, not the number of rows in the data or the number of model terms as printed in a formula. A categorical predictor with three levels, for example, often adds two independent coefficients under a reference-level coding. If the larger model adds a block of \(q\) independent fixed-effect coefficients and both fits have the same random-effects structure, then \(df=q\). Shared nuisance parameters, such as a residual or random-intercept variance estimated in both models, contribute to both counts and cancel in the difference.
A short derivation explains the factor of two. The likelihood ratio in favor of the larger model is \(L_1/L_0\), where \(L_1\) and \(L_0\) are the maximized likelihoods. Taking its natural logarithm gives
The conventional statistic is twice this log ratio, \(G^2=2(\ell_1-\ell_0)\). If both optimizations find their global maxima and the models are nested, the larger model can reproduce the restricted fit, so \(\ell_1\geq\ell_0\) and \(G^2\geq0\). A noticeably negative value is therefore a warning to check the fits, nesting, and reported likelihoods.
When the usual chi-square approximation applies, the upper-tail p-value is \(P(\chi^2_{df}\geq G^2)\). The approximation assumes, among other things, an identifiable model with a well-behaved likelihood and null parameter values that are not on problematic boundaries. These conditions are especially important when the comparison changes the random-effects structure. They should be checked before reporting a chi-square p-value.
Verify that the restricted model is obtained from the larger model by imposing the null restrictions, and that both fits use the same outcome data and compatible likelihoods.
Record \(\ell_0\) and \(\ell_1\) from the fitted models, using enough digits to avoid unnecessary rounding error.
Compute \(G^2=2(\ell_1-\ell_0)\), then count the difference in free, identifiable parameters.
Use a chi-square tail probability with \(df=k_1-k_0\) only when the relevant regularity conditions are credible; otherwise report the statistic and explain why that reference may not apply.
Worked Comparisons
Worked Example: Testing a Two-Coefficient Fixed-Effect Block
Suppose hypothetical data from 48 clinics are fitted with two binary-outcome GLMMs. Both use the same observations, a logit link, and a random intercept for clinic, and both are fitted by maximum likelihood. The restricted model omits two independent coefficients for a predictor block; the larger model includes them. The fitted log likelihoods are \(\ell_0=-128.42\) and \(\ell_1=-123.10\). Assume both fits converged to appropriate maxima and the null parameter values meet the regularity conditions for the usual approximation.
The statistic is
The larger model adds two independent coefficients, while the random-intercept and other parameters are shared. Thus \(df=2\). The chi-square upper-tail probability is
The test provides evidence against the joint null that both added coefficients are zero, at conventional significance levels. This is a joint test of the block; the result does not say that each coefficient separately has a p-value of 0.0049.
Worked Example: Counting a Single Added Coefficient
Consider hypothetical binary responses from 30 clinics. Two maximum-likelihood GLMMs use the same observations, logit link, and random-intercept structure. The larger model adds one prespecified fixed-effect coefficient. Suppose \(\ell_0=-74.80\) and \(\ell_1=-72.98\), with both fits converged and the null coefficient an interior parameter value.
The likelihood-ratio statistic is
Only one independent coefficient was added, so \(df=1\). The upper-tail probability is approximately
At \(\alpha=0.05\), this result does not cross the specified significance threshold. It is appropriate to report the observed statistic, its one degree of freedom, the approximate p-value, and the model comparison in context. It would not be correct to describe this result as proof that the coefficient is zero.
Worked Example: A Random-Slope Comparison and a Boundary
Suppose hypothetical longitudinal data from 25 clinics are fitted with the same fixed effects and response distribution in both models. The restricted GLMM has a clinic random intercept; the larger GLMM adds a clinic random slope, allowing the random intercept and slope to have an unstructured covariance. The fitted log likelihoods are \(\ell_0=-91.60\) and \(\ell_1=-89.00\). Assume both fits converge and use the same likelihood approximation.
The computed statistic is
The larger covariance structure adds a random-slope variance and an intercept–slope covariance, so the nominal parameter-count difference is two. However, under the restricted model the random-slope variance is zero, a boundary value; the covariance with that zero-variance slope must also be zero. The ordinary regular chi-square conditions therefore do not hold automatically. Reporting \(G^2=5.20\) and the nominal difference of two parameters describes the calculation, but it does not justify using an ordinary \(\chi^2_2\) p-value. A suitable boundary-aware reference or another justified calibration is needed for inference.
Diagnostics, Alternatives, and Limitations
Before treating a computed difference as evidence, inspect the fitting record. Confirm convergence, check for warnings, and verify that each likelihood is the maximized likelihood for the stated model. In a GLMM, numerical integration can affect the reported likelihood. A comparison is most credible when both fits use the same integration method and sufficiently accurate settings. If the statistic is very small or the conclusion changes under modestly more accurate integration, investigate the numerical fit rather than interpreting extra decimal places.
Also check that the fits use exactly the same observations. A model that silently drops cases because of missing predictor values does not provide a directly comparable likelihood for this test. Confirm that offsets, response coding, and likelihood conventions match. For fixed-effect comparisons, restricted maximum likelihood (REML) likelihoods are generally not comparable across different fixed-effect structures; maximum likelihood is the usual basis for that comparison. Do not substitute a penalized objective for an ordinary maximized likelihood and then apply the standard likelihood-ratio reference without a separate justification.
A likelihood-ratio test assesses whether the larger model’s improvement in fit is sufficiently large relative to the null reference distribution. A Wald test instead uses an estimate and its estimated uncertainty to assess a restriction; it is a different calculation and can give a different finite-sample result. The choice between them depends on the inferential question and the reliability of the relevant approximations. Neither method repairs a misspecified response distribution, an unsuitable random-effects structure, separation, or a poorly converged fit.
The parameter-count difference is reliable only when the restrictions are identifiable and the model dimensions are correctly understood. Redundant coefficients, aliased design columns, or parameters that cannot be estimated from the data can make a formula-based count misleading. For an ordinary fixed-effect block test, count the independent restrictions after the model coding and design are taken into account. For random-effect comparisons, distinguish the number of nominal added covariance parameters from the reference distribution: boundary constraints can change the latter even when the subtraction \(k_1-k_0\) is clear.
A Common Mistake
A frequent error is to count only the additional named predictors and then report the usual chi-square p-value automatically. For example, adding a random slope may appear to add one term, but an unstructured random-intercept/random-slope covariance also involves a variance and a covariance; moreover, the null can place variance parameters on a boundary. The correction is to count the free parameters in each fitted model, verify the actual restrictions, and separately assess whether a standard chi-square reference is justified. Parameter counting and reference-distribution choice are related but are not the same task.
Check Your Understanding
For each question, first identify the comparison or calculation required. Brief solutions follow the questions.
- Two comparable nested GLMMs have maximized log likelihoods \(-40.25\) and \(-37.90\), with the latter from the larger model. Calculate \(G^2\).
- The larger model in Question 1 adds three independent fixed-effect coefficients, and the random-effects structure is unchanged. What is the chi-square degrees-of-freedom difference?
- Why is it a problem if the two models in a likelihood-ratio comparison use different observations?
- A random-slope model improves the maximized log likelihood over a random-intercept model. Why might the ordinary chi-square reference be unsuitable even when the nominal added parameter count is known?
- In a fixed-effect comparison, both models have the same random-intercept variance parameter. Does that shared parameter add to the difference in parameter counts? Explain.
Solutions. 1. \(G^2=2[(-37.90)-(-40.25)]=2(2.35)=4.70\). 2. The difference is three parameters, so the regular chi-square reference would use \(df=3\), if its assumptions hold. 3. The likelihood difference would combine a change in model restrictions with a change in the analyzed data, so it would not isolate the tested restrictions. 4. The null can set a random-effect variance to zero, which lies on the boundary of its allowed parameter space; regular chi-square conditions may fail. 5. No. A parameter estimated in both models contributes to both counts and cancels from \(k_1-k_0\).