Tutorials › Generalized Linear Mixed Models (GLMM) › Selecting Chi-Square Degrees of Freedom for Fixed-Effect Tests

Testing Fixed and Random Effects · Tutorial 362 of 698

Selecting Chi-Square Degrees of Freedom for Fixed-Effect Tests

Determine the correct chi-square degrees of freedom by identifying how many independent restrictions a fixed-effect test imposes.

Advanced 10 min read

What You'll Learn

  • Identify the number of independent restrictions in a fixed-effect null hypothesis.
  • Use the rank of a restriction matrix to handle duplicate or dependent equations.
  • Connect the restriction rank to Wald-test and likelihood-ratio-test degrees of freedom.
  • Check that nested models differ by the intended number of identifiable parameters.
  • Recognize when regularity or identifiability problems make the usual chi-square reference questionable.

Why the Degrees of Freedom Depend on Independent Restrictions

A fixed-effect test may be written as one equation, several equations, or a comparison of two nested models. The number of equations written down is not always the number of distinct claims being tested: some equations may repeat or imply others. For a regular fixed-effect Wald or likelihood-ratio test, the chi-square degrees of freedom are determined by the number of independent restrictions imposed by the null hypothesis.

This distinction matters in GLMMs because fixed effects are often tested in blocks, while the fitted model may use a particular coefficient coding or a set of linear contrasts. Counting coefficients or constraint lines without checking their independence can assign the wrong reference distribution and therefore the wrong p-value.

Definition: Let \(\beta\) be the vector of fixed-effect coefficients and write a linear null hypothesis as \(H_0:R\beta=r\), where \(R\) is a matrix and \(r\) is a vector. The number of independent restrictions is \(q=\operatorname{rank}(R)\), provided the constraints are consistent and identifiable. Under the regular conditions for the test, its asymptotic reference distribution is \(\chi^2_q\).

Finding the Rank of the Restrictions

The rank of \(R\) is the number of linearly independent rows in the restriction matrix. Equivalently, it is the number of independent scalar conditions imposed on \(\beta\). Repeating an equation, multiplying it by a nonzero constant, or adding a consequence of existing equations does not add a restriction. For a consistent set of equations, elementary row operations can reveal which rows are redundant without changing the set of solutions.

The rank is not necessarily the number of rows in \(R\), nor is it automatically the number of coefficients appearing in the model. For example, a joint test that three distinct coefficients all equal zero imposes three restrictions if those coefficients are separately identifiable. A test with three written equations can impose only two restrictions if one equation follows from the other two.

A restriction must also be identifiable: the data and model must provide information about the linear combination being tested. If a coefficient or contrast is not estimable, a nominal count of restrictions does not make the usual Wald or likelihood-ratio approximation valid. In practice, inspect the model design and estimation output for rank deficiency, aliased coefficients, or other evidence that the requested parameters cannot be distinguished.

Worked Example: A Likelihood-Ratio Test of Three Coefficients

Suppose a hypothetical binary-outcome GLMM has a full model with three identifiable fixed-effect coefficients \(\beta_2,\beta_3,\beta_4\), in addition to the other fixed effects. The null model sets all three to zero and retains the same random-effects structure. The fitted log likelihoods are \(-128.400\) for the full model and \(-133.525\) for the null model. The three restrictions are distinct and independent.

The likelihood-ratio statistic is twice the difference in maximized log likelihoods:

$$ G^2=2\{\ell_{\mathrm{full}}-\ell_{\mathrm{null}}\} =2\{-128.400-(-133.525)\} =2(5.125)=10.25. $$

Because the null hypothesis imposes three independent restrictions, \(q=3\). Under the regular large-sample conditions for Wilks' theorem, compare \(G^2\) with \(\chi^2_3\). The upper-tail probability is approximately \(P(\chi^2_3\ge 10.25)=0.01656\). At the 0.05 significance level, this is evidence against the joint null hypothesis that all three coefficients are zero. It is not evidence that each coefficient is individually nonzero.

Wald Tests Use the Same Restriction Count

For a Wald test of \(H_0:R\beta=r\), let \(\hat{\beta}\) be the estimated fixed-effect vector and let \(\widehat{\operatorname{Var}}(\hat{\beta})\) be its estimated covariance matrix. The Wald statistic measures the estimated distance from the null restrictions, accounting for their covariance. When \(R\) has full row rank, its usual form is:

$$ W=(R\hat{\beta}-r)^\mathsf{T} \left\{R\widehat{\operatorname{Var}}(\hat{\beta})R^\mathsf{T}\right\}^{-1} (R\hat{\beta}-r). $$

If the written restrictions are redundant, the matrix inside the inverse is singular. The solution is not to count every row and assign that many degrees of freedom. Instead, replace the restrictions with an equivalent independent set, or use the corresponding generalized-inverse formulation; the reference degrees of freedom are still the rank of the independent restrictions.

Worked Example: A Wald Test With a Redundant Equation

In a hypothetical GLMM, suppose the estimable coefficient vector is \(\beta=(\beta_1,\beta_2,\beta_3)^\mathsf{T}\). The null hypothesis is written as \(\beta_1+\beta_2=0\), \(2\beta_1+2\beta_2=0\), and \(\beta_2-\beta_3=0\). The second equation is exactly twice the first, so the three written equations impose only two independent restrictions. An independent restriction matrix is:

$$ A= \begin{pmatrix} 1&1&0\\ 0&1&-1 \end{pmatrix}, \qquad A\beta= \begin{pmatrix}0\\0\end{pmatrix}, \qquad \operatorname{rank}(A)=2. $$

Assume the hypothetical estimates are \(\hat{\beta}=(0.40,-0.10,-0.30)^\mathsf{T}\), and the estimated covariance matrix is \(0.04I_3\), where \(I_3\) is the three-by-three identity matrix. The two estimated restriction values are \(0.40-0.10=0.30\) and \(-0.10-(-0.30)=0.20\). Thus:

$$ A\widehat{\operatorname{Var}}(\hat{\beta})A^\mathsf{T} =0.04 \begin{pmatrix}2&1\\1&2\end{pmatrix}, \qquad \left\{A\widehat{\operatorname{Var}}(\hat{\beta})A^\mathsf{T}\right\}^{-1} =\frac{25}{3} \begin{pmatrix}2&-1\\-1&2\end{pmatrix}. $$

Substitution gives:

$$ W= \begin{pmatrix}0.30&0.20\end{pmatrix} \frac{25}{3} \begin{pmatrix}2&-1\\-1&2\end{pmatrix} \begin{pmatrix}0.30\\0.20\end{pmatrix} =1.1667. $$

The asymptotic reference distribution is \(\chi^2_2\), not \(\chi^2_3\), because the restriction rank is two. Its upper-tail probability is approximately \(0.5580\), so these hypothetical results do not provide evidence against the joint null at the 0.05 level. The statistic and p-value test the two independent restrictions together.

Why the Likelihood-Ratio Degrees of Freedom Match

For two nested, regular models, the likelihood-ratio test compares a less constrained model with a more constrained one. If the null model imposes \(q\) independent restrictions on the fixed effects, it removes \(q\) locally free parameter directions relative to the alternative. Wilks' theorem then gives a \(\chi^2_q\) limiting distribution for twice the log-likelihood difference. The key count is the difference in the models' identifiable parameter dimensions attributable to the restrictions, not simply the number of terms displayed in a formula.

The Wald test reaches the same degrees-of-freedom count from a different direction. The vector \(R\hat{\beta}-r\) has \(q\) independent components after redundant restrictions are removed. Its covariance-adjusted quadratic form has an asymptotic chi-square distribution with \(q\) degrees of freedom under the null. This explains why Wald and likelihood-ratio tests for the same regular null use the same \(q\), even though their observed statistics need not be equal.

1
Write the null precisely.
Express the fixed-effect null as \(R\beta=r\), or identify the corresponding nested null and alternative models.
2
Remove redundant conditions.
Find the rank of \(R\), checking that each restriction concerns an identifiable coefficient combination.
3
Assign the reference degrees of freedom.
Use \(q=\operatorname{rank}(R)\); for a regular nested likelihood comparison, confirm that this agrees with the number of independent parameters removed.
4
Check whether the approximation is credible.
Confirm convergence and inspect for rank deficiency, boundary estimates, or other violations of the regular conditions underlying the chi-square reference.

Worked Example: A One-Restriction Wald Test

Suppose a hypothetical logit GLMM estimates an exposure coefficient as \(0.30\) log-odds units per one-unit increase in exposure, with estimated standard error \(0.12\) log-odds units. The null hypothesis is that this single identifiable coefficient is zero. Assume the model converged, the coefficient is estimable, and the usual regular large-sample approximation is being used.

Here \(R=(1)\), so \(q=1\). The Wald statistic can be calculated from the estimate and standard error:

$$ W=\left(\frac{0.30-0}{0.12}\right)^2 =(2.5)^2=6.25. $$

Comparing with \(\chi^2_1\) gives an upper-tail p-value of approximately \(0.01242\). At the 0.05 level, the result is evidence against a zero exposure coefficient. The estimated association is positive on the log-odds scale; this test alone does not establish a causal effect. The degrees of freedom are one because there is one independent scalar restriction, not because the fitted model has only one coefficient.

Assumptions, Diagnostics, and Common Pitfalls

The ordinary chi-square reference is an asymptotic result, not a guarantee for every fitted GLMM. It relies on a correctly specified, regular comparison: the null is represented within the alternative; the tested parameters are identifiable and lie in the interior of their allowed parameter space; the likelihood is sufficiently well behaved; and the estimates are in a regime where the large-sample approximation is reasonable. For a likelihood-ratio test, the models must be fit in a way that makes their likelihoods comparable, and their difference must correspond to the fixed-effect restrictions under test. For a Wald test, the estimated covariance matrix must be usable for the independent contrasts.

Diagnostics should therefore check more than the arithmetic of the degrees of freedom. Confirm that the fitting procedure converged, the fixed-effect design is not rank deficient, and the restriction matrix has the rank assumed. For a likelihood-ratio test, verify that the null model is genuinely nested in the alternative and that no unintended model features changed. For a Wald test, check that the contrast covariance matrix is nonsingular after redundant rows have been removed. A reported singularity or non-estimable coefficient is a warning not to proceed with a mechanical degrees-of-freedom count.

The main alternatives are not competing rules for counting restrictions. Wald and likelihood-ratio procedures use different test statistics, but both use the same restriction rank for their regular chi-square reference. A single coefficient test is the special case \(q=1\); a joint test uses the rank of the full contrast set. In small or irregular samples the chi-square calibration may be poor, so a correct value of \(q\) does not by itself ensure a reliable p-value. The conditions and finite-sample behavior of the two procedures require separate consideration.

  • Wrong: “There are three equations, so the test has three degrees of freedom.” Correction: Compute the rank; dependent equations do not add independent restrictions.
  • Wrong: “The model has ten fixed-effect coefficients, so every test has ten degrees of freedom.” Correction: Count only the independent restrictions imposed by the particular null.
  • Wrong: “A coefficient appears in the formula, so it can be tested.” Correction: Check that the coefficient or contrast is identifiable in the fitted design.
  • Wrong: “The models are nested, so the degrees of freedom equal the number of changed lines of code.” Correction: Count the independent identifiable parameter restrictions represented by the model comparison.
Key takeaway: For a regular fixed-effect Wald or likelihood-ratio test, the chi-square degrees of freedom equal the number of independent, identifiable restrictions under the null. In matrix form, this is the rank of the restriction matrix.

Check Your Understanding

Answer each question, then check the solutions below.

  1. A null hypothesis sets four identifiable coefficients to zero, and those four restrictions are independent. What are the chi-square degrees of freedom?
  2. A test is written using three equations, but the second is twice the first and the third is independent of the first. What is the restriction rank?
  3. Two contrast rows are described only as identifiable. Is that enough to conclude the test has two degrees of freedom?
  4. A nested-model likelihood-ratio test removes two independent, identifiable fixed-effect directions under regular conditions. What reference distribution is used?
  5. A Wald test requests a contrast that is not estimable because the design matrix is rank deficient. Can the usual degrees-of-freedom rule alone justify its p-value?

Solutions. (1) \(q=4\), so use \(\chi^2_4\). (2) The restriction rank is \(2\): one equation is redundant and the remaining two are independent. (3) No. Identifiability of each contrast does not establish that the contrasts are mutually independent; calculate the rank of the restriction rows. (4) Use an asymptotic \(\chi^2_2\) reference distribution. (5) No. The requested contrast is not identifiable, so the usual Wald test and its nominal chi-square calibration are not justified merely by counting restrictions.

Clinical Biostats