Tutorials › Generalized Linear Mixed Models (GLMM) › Testing Random-Slope Covariance Under a Zero-Slope Null

Testing Fixed and Random Effects · Tutorial 392 of 698

Testing Random-Slope Covariance Under a Zero-Slope Null

You will learn to define the zero-slope null correctly, understand its boundary reference distribution, and check when likelihood-ratio inference needs calibration.

Advanced 12 min read

What You'll Learn

  • Write the random-slope null with both slope variance and intercept–slope covariance equal to zero.
  • Distinguish a covariance fixed by the null from a correlation that is undefined there.
  • Derive the one-sided likelihood-ratio mixture under suitable regularity and identifiability conditions.
  • Calculate and interpret a random-slope likelihood-ratio test in context.
  • Recognize when design limitations or small-sample behavior call for bootstrap calibration.
  • Check covariance-matrix feasibility and diagnose unreliable fits near the boundary.

Why the covariance belongs in the null

A random slope allows clusters to differ in how their response changes with a predictor. When the slope variance is zero, however, there is no between-cluster slope variation. Positive semidefiniteness of the random-effects covariance matrix then also requires the intercept–slope covariance to be zero. A test of the random-slope contribution must therefore remove both quantities; it cannot leave a free intercept–slope covariance in the null model.

This detail matters for both model fitting and inference. The intercept–slope correlation is not a parameter that can be estimated under the zero-slope null: its denominator contains the slope standard deviation, which is zero there. The fixed slope, by contrast, remains part of the mean model and can still be estimated. The question is whether the data support additional random variation in that slope.

Definition: For a model with random intercept \(b_{0j}\) and random slope \(b_{1j}\), write their covariance matrix as $$ G = \begin{pmatrix} \tau_{00} & \tau_{01} \\ \tau_{01} & \tau_{11} \end{pmatrix}, $$ where \(\tau_{00}\) and \(\tau_{11}\) are variances and \(\tau_{01}\) is the covariance. The random-slope null is \(H_0:\tau_{11}=0,\ \tau_{01}=0\), with \(\tau_{00}\) still estimated. The alternative allows \(\tau_{11}>0\) and a compatible value of \(\tau_{01}\). Under the null, the slope correlation \(\tau_{01}/\sqrt{\tau_{00}\tau_{11}}\) is undefined.

For example, a GLMM with predictor \(x_{ij}\), cluster \(j\), and a random intercept and slope can be written as

$$ g\{E(Y_{ij}\mid b_{0j},b_{1j})\} = \beta_0+\beta_1x_{ij}+b_{0j}+b_{1j}x_{ij}, \qquad \begin{pmatrix}b_{0j}\\b_{1j}\end{pmatrix} \sim N\left( \begin{pmatrix}0\\0\end{pmatrix},G\right). $$

Here \(g\) is the link function. The random-effects distribution and response distribution are those specified by the GLMM; clusters are assumed independent, and the fixed-effects structure and all other model components are held the same in the two models. The random-intercept variance is assumed to be a meaningful, estimable nuisance parameter under the null. The design must also contain information to distinguish slope-related variation from other covariance patterns. If those conditions fail, a simple large-sample reference distribution may not be reliable.

Feasibility and parameters at the boundary

A covariance matrix must be positive semidefinite. For the two-dimensional matrix above, this requires \(\tau_{00}\geq 0,\ \tau_{11}\geq 0\), and \(\tau_{00}\tau_{11}-\tau_{01}^2\geq 0\). In particular, if \(\tau_{11}=0\), then the determinant condition gives \(-\tau_{01}^2\geq 0\), so \(\tau_{01}=0\). This is why setting only the slope variance to zero while retaining a nonzero covariance is not a valid null model.

The distinction between covariance and correlation is important. Under the null, the covariance is fixed at zero by feasibility, while the correlation is undefined, not estimated as zero. A fitted correlation near the boundary can consequently be unstable: very small changes in variance estimates can produce large changes in the ratio. Do not use a Wald test for that correlation as though it were an ordinary, identifiable parameter under the null.

Worked Example: Checking the Covariance Matrix and the Null

Suppose a hypothetical fitted alternative reports an intercept variance of \(0.64\), a slope variance of \(0.09\), and an intercept–slope covariance of \(-0.18\). Check feasibility and identify what happens under the zero-slope null.

The determinant is $$ 0.64(0.09)-(-0.18)^2=0.0576-0.0324=0.0252. $$ It is positive, so the matrix is positive definite. The implied correlation is $$ \frac{-0.18}{\sqrt{0.64(0.09)}}= \frac{-0.18}{0.24}=-0.750. $$ Thus these alternative estimates describe a feasible covariance matrix with a negative intercept–slope association.

Under \(H_0\), the slope variance becomes zero. Feasibility then forces the covariance to zero as well, giving \(G=\begin{pmatrix}0.64&0\\0&0\end{pmatrix}\). The correlation is not zero under this null; it is undefined because its denominator is zero. The random intercept remains in the model.

Likelihood-ratio statistic and its reference law

Fit the null model with a random intercept but no random slope, and the alternative model with both random effects. Keep the fixed effects and other modeling choices identical. For a GLMM, compare the fitted marginal likelihoods. Let \(\ell_0\) and \(\ell_1\) denote the maximized log likelihoods under the null and alternative. The likelihood-ratio statistic is

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

A larger \(D\) indicates that allowing the random slope improves the fit. Because the null sets a variance on the boundary of the allowed parameter space, the usual reference distribution \(\chi^2_1\) does not generally apply. Under suitable large-sample conditions for this single added random slope, the random-intercept variance is interior, and the relevant information is identifiable, the asymptotic null law is

$$ D \ \overset{approx}{\sim}\ \tfrac12\chi^2_0+\tfrac12\chi^2_1. $$

Here \(\chi^2_0\) denotes a point mass at zero. For an observed \(D>0\), the upper-tail p-value under this mixture is one half the upper-tail probability from \(\chi^2_1\). This reference law accounts for the one-sided variance boundary. It is not a universal guarantee: weak design information, few clusters, or model misspecification can make its finite-sample calibration poor.

Why the mixture arises

The basic reason is that, after accounting for regular nuisance parameters, the local likelihood behaves like a quadratic function of a standardized score for the slope-variance direction. The feasible direction for that variance is one-sided: it cannot move below zero. The intercept–slope covariance must also be included in the alternative, but its behavior at the boundary is not that of a freely varying correlation under the null.

In the local covariance geometry, a small covariance change can be compatible with positive semidefiniteness when accompanied by a sufficiently small nonnegative slope variance. To first order at a positive intercept variance, the covariance direction can be profiled as a nuisance direction; the remaining slope-variance direction is constrained to be nonnegative. Under the stated regularity and information conditions, let \(Z\sim N(0,1)\) be the resulting standardized, nuisance-adjusted score. Maximizing the local quadratic likelihood over a nonnegative parameter produces

$$ D \approx \max(0,Z)^2. $$

Since a standard normal variable is nonpositive with probability \(1/2\), this expression is zero with probability \(1/2\). Conditional on being positive, its square has the \(\chi^2_1\) distribution. This gives the half-point-mass, half-\(\chi^2_1\) reference law. This justification also shows why the mixture relies on an identifiable, effectively one-dimensional boundary direction after nuisance adjustment. It should not be carried over automatically to a different number or arrangement of random effects.

Worked Example: Calculating the Mixture-Test P-Value

In a hypothetical GLMM analysis, the null and alternative maximized log likelihoods are \(\ell_0=-122.0\) and \(\ell_1=-120.8\). Assume the conditions for the one-slope mixture reference are reasonable. Test at \(\alpha=0.05\).

First calculate the statistic: $$ D=2\{-120.8-(-122.0)\}=2(1.2)=2.40. $$ For a positive statistic, the mixture p-value is $$ p=\tfrac12 P(\chi^2_1\geq 2.40) \approx \tfrac12(0.1213)=0.0607. $$

Because \(0.0607>0.05\), this test does not reject \(H_0\) at the 5% level. The result is not evidence that the population slope variance is exactly zero; it means these data do not provide sufficient evidence against the zero-slope-variance model at the chosen level. For comparison, using an ordinary \(\chi^2_1\) reference would give about \(0.1213\), twice the mixture tail probability, and would not be the appropriate boundary calculation under the stated conditions.

Calibration, diagnostics, and alternatives

Before interpreting the test, check that the two models are genuinely nested and differ only by the random-slope contribution. Verify that both fits converged, that the alternative covariance matrix is feasible, and that neither fit is trapped at a numerical boundary or a poor local optimum. Examine sensitivity to reasonable optimizer settings and starting values. If the slope predictor barely varies within clusters, or the number of independent clusters is small, the likelihood may contain little information about slope variance; a nominal asymptotic p-value can then be misleading.

A parametric bootstrap is a useful calibration alternative when the mixture approximation is questionable. Fit the null model, simulate data under it using its fitted parameters and the original design, refit both models to each simulated data set, and recompute \(D\). The simulated upper-tail proportion estimates the null tail probability. This procedure respects the fitted null structure, including the absence of both random-slope variance and covariance, but it is computationally intensive and depends on the null model being adequate.

A Wald test of the slope variance is not an equivalent substitute: ordinary Wald approximations assume a locally unconstrained, approximately normal estimator, whereas the null is a boundary point. A confidence set for the variance can present uncertainty in a different form, but it must also respect the boundary and the covariance structure. These approaches answer related questions, not identical ones; report the test and calibration method actually used.

Worked Example: A Small-Sample Bootstrap Check

Suppose the observed statistic is \(D=2.40\), and a hypothetical parametric bootstrap uses \(B=199\) simulations from the fitted null. In 13 simulations, the refitted likelihood-ratio statistic is at least \(2.40\). Using the common plus-one estimate, $$ \hat p_{\mathrm{boot}}=\frac{1+\#\{D^{(b)}\geq 2.40\}}{B+1} =\frac{1+13}{199+1}=\frac{14}{200}=0.0700. $$

The bootstrap estimate is above \(0.05\), so it also does not reject at the 5% level. Its value differs from the asymptotic mixture p-value of \(0.0607\); finite simulation variation and finite-sample behavior can both contribute. The bootstrap is an estimated calibration, not an exact p-value, and 199 simulations provide limited precision. More simulations would reduce Monte Carlo error, but would not repair a misspecified null model.

Common mistake and practical limits

Wrong reasoning: “I set the random-slope variance to zero, but I can leave the fitted intercept–slope covariance in the null because covariance is a separate parameter.” This produces an infeasible covariance matrix: with zero slope variance, positive semidefiniteness requires zero covariance. The correction is to compare the random-intercept null against an alternative that adds the random slope and its compatible covariance structure together. Also distinguish the covariance, which is forced to zero under the null, from the correlation, which is undefined there.

The test assesses whether the specified model benefits from a cluster-level random slope for the chosen predictor, conditional on its assumptions and design. It does not establish that cluster-specific slopes are exactly identical, nor does it show that the predictor has no fixed effect. A fixed slope and a random-slope variance describe different features of the model. The inference can also be sensitive to predictor scaling, misspecified random-effects distributions, or too few independent clusters; these are reasons to inspect the model and consider appropriate calibration, not reasons to reinterpret a nonsignificant result as proof of zero variation.

Key takeaway: A zero random-slope variance forces the associated intercept–slope covariance to zero, while leaving the fixed slope and usually the random intercept in the null model. Under suitable conditions, the single-slope likelihood-ratio test uses a half-\(\chi^2_0\), half-\(\chi^2_1\) reference; weak identification and small samples warrant extra caution or bootstrap calibration.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. If \(\tau_{11}=0\), what must \(\tau_{01}\) be, and why?
  2. Why is the random-effects correlation not estimated as zero under the zero-slope null?
  3. A fitted comparison gives \(\ell_0=-80.0\) and \(\ell_1=-78.5\). Calculate \(D\), then give the mixture p-value if \(P(\chi^2_1\geq 3.00)=0.0833\).
  4. Name two conditions or features that can make the asymptotic mixture calibration doubtful.

Solutions. (1) \(\tau_{01}=0\), because positive semidefiniteness requires \(\tau_{00}\tau_{11}-\tau_{01}^2\geq0\); with \(\tau_{11}=0\), this implies \(-\tau_{01}^2\geq0\). (2) The correlation divides covariance by \(\sqrt{\tau_{00}\tau_{11}}\), which is zero under the null, so the correlation is undefined. (3) \(D=2\{-78.5-(-80.0)\}=3.00\), and the mixture p-value is \(0.5(0.0833)=0.0417\). (4) Examples include a small number of independent clusters, little within-cluster variation in the slope predictor, weak identifiability of covariance patterns, or failure of model assumptions.

Clinical Biostats