Why Test a Linear Contrast?
A fixed-effect hypothesis in a generalized linear mixed model (GLMM) need not concern one coefficient by itself. It may concern a difference between coefficients, a weighted average of effects, or the effect at a particular value of a predictor when an interaction is present. Each can be written as a linear contrast of the fixed-effect coefficients. A Wald test evaluates whether that specified contrast equals a stated null value, using its estimate and estimated variance.
For example, a coefficient in a logit-link model may represent a treatment effect at the reference value of a continuous predictor. With a treatment-by-time interaction, the treatment effect at a later time is a sum of the treatment coefficient and a multiple of the interaction coefficient. Testing only the treatment coefficient would answer a different question. The contrast must therefore match the scientific question before its standard error or test statistic is calculated.
Model, Contrast, and Assumptions
For observation \(j\) in cluster \(i\), write a GLMM as
Here \(g\) is the link function, \(\beta\) is the vector of \(p\) fixed-effect coefficients, and \(b_i\) is the cluster-level random-effect vector. The response distribution, link, and random-effects distribution are specified by the model. In the usual formulation, responses are conditionally independent given the random effects and covariates. The fixed-effect interpretations and contrasts below are on the model’s linear-predictor scale unless a transformation is explicitly stated.
Let \(\hat{\beta}\) be the fitted fixed-effect estimate, and let \(\widehat V\) be its estimated covariance matrix. The estimated contrast is \(c^{\mathsf T}\hat{\beta}\), and its estimated variance is \(c^{\mathsf T}\widehat Vc\). This calculation uses covariances as well as variances: estimates of different coefficients are often correlated. A Wald test assumes the contrast is estimable and that its estimated variance is positive.
The reference distribution is approximate. It relies on a sufficiently regular, correctly specified model and a setting in which the fixed-effect estimator is approximately multivariate normal with covariance estimated adequately. In GLMMs, this is generally a large-sample approximation; it is not an exact finite-sample test. In particular, sparse data, few independent clusters, near-separation, or unstable estimation can make the approximation poor. The random-effects structure and other model choices are treated as fixed for this test.
The Wald Statistic for One Contrast
When the null hypothesis holds and the large-sample approximation is adequate, \(W\) is compared with a chi-square distribution with one degree of freedom. The p-value is \(P(\chi^2_1\ge W)\). Equivalently, one can divide the contrast’s distance from its null value by its estimated standard error, square the resulting signed statistic, and compare the square with \(\chi^2_1\). The test is two-sided: the square removes the sign, while the direction and size of the estimated contrast should still be reported.
The justification follows from the approximate distribution of the estimator. If \(\hat{\beta}\) is approximately \(N(\beta,V)\), then \(c^{\mathsf T}\hat{\beta}\) is approximately normal with mean \(c^{\mathsf T}\beta\) and variance \(c^{\mathsf T}Vc\). Under \(H_0\), standardizing the contrast gives an approximately standard normal variable. Its square has a chi-square distribution with one degree of freedom. Replacing the unknown covariance \(V\) with its estimate \(\widehat V\) yields the stated Wald statistic.
Worked Example: Testing the Average of Two Treatment Effects
Suppose a hypothetical logit-link GLMM estimates treatment effects in two prespecified subgroups. The fixed-effect estimates are \(\hat{\beta}_1=0.30\) and \(\hat{\beta}_2=0.50\), and their estimated covariance matrix is
Test whether the equally weighted average of the subgroup treatment effects is zero. Thus \(c=(0.5,0.5)^{\mathsf T}\), \(c_0=0\), and the null is \(H_0:0.5\beta_1+0.5\beta_2=0\).
The estimated contrast is \(0.5(0.30)+0.5(0.50)=0.40\). Its estimated variance includes the covariance term:
The Wald statistic is \(W=(0.40-0)^2/0.0275=0.16/0.0275=5.818\). Comparing with \(\chi^2_1\) gives \(p\approx0.0159\). At the 0.05 significance level, the test provides evidence that the equally weighted average treatment effect differs from zero on the log-odds scale. It does not establish that each subgroup effect differs from zero: the tested hypothesis concerns their specified average.
Contrasts for Ratios and Interactions
A contrast can test a scientifically meaningful target that is not itself a model coefficient. In a log-link model, for example, a contrast \(c^{\mathsf T}\beta\) may be the log of a rate ratio. In a logit-link model, it may be a log odds ratio. If the target ratio is \(r>0\), testing that the ratio equals \(r\) is equivalent to testing \(c^{\mathsf T}\beta=\log(r)\). The contrast and null value must be expressed on the same scale.
Worked Example: Testing a Specified Odds Ratio
Suppose a hypothetical logit-link GLMM gives a treatment log-odds coefficient \(\hat{\beta}=0.52\), with estimated variance \(0.0144\). Test whether the corresponding conditional odds ratio is \(1.5\). On the log-odds scale, the null value is \(c_0=\log(1.5)=0.405465108\ldots\), with \(c=1\).
Using the full-precision null value, the Wald statistic is
Thus \(W\approx0.911\), with one degree of freedom and \(p\approx0.340\). At the 0.05 level, this test does not provide sufficient evidence against the null that the conditional odds ratio is \(1.5\). This result is not proof that the ratio equals \(1.5\). The test concerns the fixed-effect coefficient on the log-odds scale, conditional on the GLMM’s random effects; it does not directly test a population-averaged odds ratio.
Interactions provide a common reason to form a contrast rather than read one coefficient in isolation. For a model with treatment \(T\), time \(t\), and their interaction, the treatment effect on the linear-predictor scale at time \(t\) is \(\beta_T+t\beta_{Tt}\). At a chosen time, that expression is a linear contrast. If time is centered or measured in different units, the coefficient values and the contrast weights change accordingly, so the scale and coding must be stated.
Worked Example: Treatment Effect at a Chosen Time
In a hypothetical logit-link GLMM, suppose the treatment coefficient is \(\hat{\beta}_T=0.40\) and the treatment-by-time coefficient is \(\hat{\beta}_{Tt}=-0.12\). Time is measured in years from baseline. Their estimated variances are \(0.04\) and \(0.0025\), and their estimated covariance is \(-0.004\). Test whether the treatment effect at \(t=2\) years is zero on the log-odds scale.
The target contrast is \(\beta_T+2\beta_{Tt}\), so \(c=(1,2)^{\mathsf T}\) and \(c_0=0\). The estimate is \(0.40+2(-0.12)=0.16\). Its estimated variance and Wald statistic are
The one-degree-of-freedom p-value is approximately \(0.386\). At the 0.05 level, the test does not provide sufficient evidence that the treatment effect at two years differs from zero on the log-odds scale. The estimated conditional odds ratio at that time is \(\exp(0.16)\approx1.17\), but the Wald test just calculated is the test of the log-odds contrast against zero.
Checking the Calculation and Choosing an Approach
Before interpreting a result, verify that the contrast represents the intended hypothesis and that its variance was calculated from the full covariance matrix. A negative covariance can reduce the variance of a sum, as in the interaction example; a positive covariance can increase it. Omitting the covariance terms can therefore change the standard error, test statistic, and conclusion. Also check that coefficient ordering in \(c\) matches the ordering in \(\hat{\beta}\) and \(\widehat V\).
A single-coefficient Wald test is the special case in which \(c\) selects one coefficient. A likelihood-ratio test is an alternative way to assess a specified restriction by comparing fitted models. The Wald calculation is direct once the estimate and covariance matrix are available, but it can be sensitive to the local curvature and parameterization of the likelihood. The likelihood-ratio approach requires fitting the constrained and unconstrained models and also relies on suitable large-sample conditions. Neither approach automatically resolves weak information or a poorly specified model.
Other warning signs include very large standard errors, estimates that change markedly under reasonable model refits, convergence warnings, and sparse outcome patterns. These may signal that the normal approximation or covariance estimate is unreliable. The chi-square reference distribution does not repair those problems. Report the contrast definition, estimate, standard error, test statistic, degrees of freedom, p-value, link-scale interpretation, and any ratio-scale transformation. A small p-value is evidence against the specified null under the model and approximation; it is not the probability that the null is true.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If \(\hat{\beta}_1=0.6\), \(\hat{\beta}_2=0.2\), and their estimated covariance matrix has diagonal entries \(0.09\) and \(0.04\) and off-diagonal entries \(0.01\), find the estimate and variance of \(\beta_1-\beta_2\).
- For a contrast estimate of \(0.30\), null value \(0\), and estimated variance \(0.01\), calculate the Wald statistic. What is its approximate two-sided p-value?
- In a log-link GLMM, what null value on the coefficient scale corresponds to testing whether a rate ratio is \(2\)?
- Why is a test of an interaction model’s treatment coefficient alone generally not a test of the treatment effect at all time points?
Solutions. (1) The estimate is \(0.6-0.2=0.40\). Its variance is \(0.09+0.04-2(0.01)=0.11\), because the contrast weights have opposite signs. (2) \(W=(0.30-0)^2/0.01=9.00\); against \(\chi^2_1\), the p-value is approximately \(0.00270\), so the null is rejected at the 0.05 level. (3) The null value is \(\log(2)\approx0.6931\), since the log-link coefficient contrast is the log rate ratio. (4) With an interaction, the treatment effect depends on time: at time \(t\), it is \(\beta_T+t\beta_{Tt}\). The treatment coefficient alone gives the effect at the coded time zero, so another time requires a corresponding linear contrast.