Tutorials › Generalized Linear Models › Testing Equality Of Category-Specific Slopes

Multinomial Logit Models · Tutorial 504 of 981

Testing Equality Of Category-Specific Slopes

Translate equality of category-specific slopes into linear contrasts, calculate their uncertainty, and test whether the contrasts are zero.

Intermediate 12 min read

What You'll Learn

  • Define slope-equality hypotheses in a baseline-category multinomial logit
  • Represent selected category comparisons with a restriction matrix
  • Calculate the variance of a slope difference using covariance between estimates
  • Construct Wald statistics and determine their degrees of freedom
  • Distinguish equal slopes from the hypothesis that all slopes are zero
  • Interpret test results without confusing log-odds effects with probability effects

What Does “Equal Slopes” Mean?

A predictor can affect the log odds of several response categories by different amounts. Asking whether its category-specific slopes are equal is a question about contrasts between coefficients. It is not automatically a question about whether the predictor has no effect. The distinction matters: several categories can share the same nonzero slope.

Use a baseline-category multinomial logit with response categories \(1,\ldots,J\), taking category \(J\) as the reference. For a scalar predictor \(x\), write the model as

$$ \log\!\left(\frac{P(Y=j\mid x)}{P(Y=J\mid x)}\right) =\alpha_j+\beta_j x,\qquad j=1,\ldots,J-1. $$

Here \(\beta_j\) is the slope for the log odds of category \(j\) versus the reference category. For notation in comparisons involving the reference, set \(\beta_J=0\). This is a convenient convention for writing contrasts; it does not add a separately estimated parameter.

Definition: A category-slope equality hypothesis specifies that \(\beta_j=\beta_k\) for chosen categories \(j\) and \(k\), or that several chosen slopes are equal. Written as a linear hypothesis, it has the form \(H_0:R\theta=r\), where \(\theta\) is the vector of model parameters, \(R\) is a fixed restriction matrix, and \(r\) is a fixed vector. For equality contrasts, the corresponding entries of \(r\) are zero.

For example, equality between the slopes for categories 1 and 2 is \(H_0:\beta_1-\beta_2=0\). Equality of slopes for three categories can be expressed with two independent contrasts, such as \(\beta_1-\beta_3=0\) and \(\beta_2-\beta_3=0\). These two restrictions imply that all three slopes are equal. Adding the contrast \(\beta_1-\beta_2=0\) would be redundant.

Calculating the Uncertainty of a Contrast

The uncertainty of a difference depends on the covariance between its two coefficient estimates. If \(\hat\beta_j\) and \(\hat\beta_k\) are estimated slopes, then

$$ \widehat{\operatorname{Var}}(\hat\beta_j-\hat\beta_k) = \widehat{\operatorname{Var}}(\hat\beta_j) +\widehat{\operatorname{Var}}(\hat\beta_k) -2\widehat{\operatorname{Cov}}(\hat\beta_j,\hat\beta_k). $$

This follows by expanding the variance of a linear combination. It applies whether the estimates are positively or negatively correlated. The covariance must come from the fitted model's covariance matrix; treating the estimates as independent without justification can give the wrong standard error.

Result: For any fixed vector \(a\) and estimator covariance matrix \(\widehat{\operatorname{Var}}(\hat\theta)\), the estimated variance of \(a^\mathsf{T}\hat\theta\) is \(a^\mathsf{T}\widehat{\operatorname{Var}}(\hat\theta)a\). In particular, the contrast \(\hat\beta_j-\hat\beta_k\) uses the vector with \(+1\) in position \(j\), \(-1\) in position \(k\), and zeros elsewhere.

To verify the result, write \(a^\mathsf{T}\hat\theta=\sum_s a_s\hat\theta_s\). By bilinearity of covariance,

$$ \operatorname{Var}\!\left(\sum_s a_s\hat\theta_s\right) =\sum_s\sum_t a_sa_t\operatorname{Cov}(\hat\theta_s,\hat\theta_t) =a^\mathsf{T}\operatorname{Var}(\hat\theta)a. $$

Replacing the unknown covariance matrix by its estimate gives the stated estimated variance. For the difference, the two diagonal terms are the individual variances and the two off-diagonal terms combine to \(-2\widehat{\operatorname{Cov}}(\hat\beta_j,\hat\beta_k)\). \(\square\)

Worked Example: Comparing Two Nonreference Slopes

Suppose a three-category model uses category 3 as the reference. For a predictor \(x\), the estimates for categories 1 and 2 are \(\hat\beta_1=0.80\) and \(\hat\beta_2=0.50\), with estimated covariance matrix

$$ \widehat{\operatorname{Var}} \begin{pmatrix}\hat\beta_1\\\hat\beta_2\end{pmatrix} = \begin{pmatrix} 0.0400&0.0200\\ 0.0200&0.0625 \end{pmatrix}. $$

Test \(H_0:\beta_1=\beta_2\) against a two-sided alternative, using a large-sample Wald test.

The estimated contrast is \(0.80-0.50=0.30\). Its estimated variance is

$$ 0.0400+0.0625-2(0.0200)=0.0625, \qquad \widehat{\operatorname{SE}}(\hat\beta_1-\hat\beta_2)=\sqrt{0.0625}=0.25. $$

Thus the one-degree-of-freedom Wald statistic is \(W=(0.30/0.25)^2=1.44\). Its large-sample \(p\)-value is \(P(\chi^2_1\geq 1.44)\), approximately \(0.230\). At conventional significance levels, these data do not provide strong evidence that the two slopes differ. The estimated common value under the equality hypothesis is not what this test estimates; the test asks only whether their difference is zero.

The Wald Test for Several Equality Restrictions

Suppose the parameter vector is \(\theta\), with estimator \(\hat\theta\), and consider \(q\) independent restrictions \(R\theta=r\). The Wald test compares the estimated restriction error \(R\hat\theta-r\) with its estimated covariance matrix. In the usual large-sample setting, the statistic has an approximate chi-square distribution with \(q\) degrees of freedom under the null.

Theorem: Assume the model is identifiable and regular, the true parameter is an interior point, and the estimator satisfies \(\sqrt{n}(\hat\theta-\theta_0)\xrightarrow{d}N(0,V)\), where \(V\) is positive definite. Suppose \(\widehat{\operatorname{Var}}(\hat\theta)\) consistently estimates \(V/n\), and \(R\) has full row rank \(q\). Under \(H_0:R\theta_0=r\), the Wald statistic $$ W=(R\hat\theta-r)^\mathsf{T} \left[R\widehat{\operatorname{Var}}(\hat\theta)R^\mathsf{T}\right]^{-1} (R\hat\theta-r) $$ converges in distribution to \(\chi^2_q\).

For a multinomial logit fitted by maximum likelihood, these conditions are the standard large-sample conditions: in particular, the likelihood is sufficiently smooth near the true parameter, the information is nonsingular, and the observations satisfy the sampling assumptions supporting the stated asymptotic normality. The restriction covariance must be nonsingular; the full-row-rank condition and positive-definite \(V\) ensure this here.

To prove the result, let \(A=RVR^\mathsf{T}\), which is positive definite because \(R\) has full row rank. Under the null, \(R\theta_0-r=0\), so

$$ \sqrt{n}(R\hat\theta-r) =R\sqrt{n}(\hat\theta-\theta_0) \xrightarrow{d}N(0,A). $$

Also, consistency of the covariance estimator implies \(nR\widehat{\operatorname{Var}}(\hat\theta)R^\mathsf{T}\xrightarrow{p}A\). Consequently, the Wald statistic can be written as

$$ W= \left[\sqrt{n}(R\hat\theta-r)\right]^\mathsf{T} \left[nR\widehat{\operatorname{Var}}(\hat\theta)R^\mathsf{T}\right]^{-1} \left[\sqrt{n}(R\hat\theta-r)\right]. $$

By the continuous mapping theorem and Slutsky's theorem, this converges in distribution to \(Z^\mathsf{T}A^{-1}Z\), where \(Z\sim N(0,A)\). The vector \(A^{-1/2}Z\) has distribution \(N(0,I_q)\), so \(Z^\mathsf{T}A^{-1}Z\) is the sum of squares of \(q\) independent standard normal variables. That sum has distribution \(\chi^2_q\), proving the result. \(\square\)

Worked Example: Testing Equality Across Three Categories

Suppose categories 1, 2, and 3 have estimated slopes for \(x\) of \(0.60\), \(0.40\), and \(0.50\), respectively. Category 4 is the reference. Assume the estimated covariance matrix of the three slopes is \(0.04I_3\), where \(I_3\) is the \(3\times3\) identity matrix. Test whether the three slopes are equal.

Use category 3 as the comparison anchor. The null is represented by the two restrictions \(\beta_1-\beta_3=0\) and \(\beta_2-\beta_3=0\). The estimated contrast vector is

$$ d= \begin{pmatrix} 0.60-0.50\\ 0.40-0.50 \end{pmatrix} = \begin{pmatrix}0.10\\-0.10\end{pmatrix}. $$

Each contrast has variance \(0.04+0.04=0.08\). Their covariance is \(0.04\): both contrasts contain \(-\hat\beta_3\), and the three slope estimates are otherwise uncorrelated. Therefore,

$$ \widehat{\operatorname{Var}}(d)= \begin{pmatrix}0.08&0.04\\0.04&0.08\end{pmatrix}, \qquad \left[\widehat{\operatorname{Var}}(d)\right]^{-1} = \begin{pmatrix}16.6667&-8.3333\\-8.3333&16.6667\end{pmatrix}. $$

The Wald statistic is

$$ W=d^\mathsf{T}\widehat{\operatorname{Var}}(d)^{-1}d =0.50. $$

There are two independent restrictions, so compare with \(\chi^2_2\). Since \(P(\chi^2_2\geq w)=\exp(-w/2)\), the \(p\)-value is \(\exp(-0.25)\approx0.779\). The sample slopes are close, and this test does not indicate evidence against their equality. The null allows their shared slope to be nonzero; it does not assert that all three slopes are zero.

Equality Is Not the Same as No Predictor Effect

The no-effect hypothesis for predictor \(x\), in the baseline-category model, is \(\beta_1=\cdots=\beta_{J-1}=0\). It tests whether changing \(x\) leaves every modeled category-versus-reference log odds unchanged. In contrast, an equality test among selected nonreference categories tests whether their slopes match, regardless of their shared value. A predictor can therefore have a substantial effect while passing an equality test.

If the reference category is included in an equality claim, the convention \(\beta_J=0\) matters. For example, equality of slopes for categories 1 and \(J\) is \(\beta_1=0\). Requiring all categories to have equal slopes, including the reference, is equivalent to requiring every nonreference slope to be zero. But equality only among categories 1 and 2 does not impose that requirement.

Worked Example: Equality Can Hold Despite a Predictor Effect

Return to the estimates \(0.80\) and \(0.50\) and covariance matrix from the first example. The equality test uses the contrast \((1,-1)^\mathsf{T}\) and gave \(W=1.44\). Now test the different null \(H_0:\beta_1=\beta_2=0\), meaning no effect on either nonreference logit.

The estimate vector is \(b=(0.80,0.50)^\mathsf{T}\), and its covariance matrix is \(S=\begin{pmatrix}0.04&0.02\\0.02&0.0625\end{pmatrix}\). Its determinant is \(0.04(0.0625)-0.02^2=0.0021\), hence

$$ S^{-1}=\frac{1}{0.0021} \begin{pmatrix}0.0625&-0.02\\-0.02&0.04\end{pmatrix}. $$

The two-degree-of-freedom Wald statistic for no effect is

$$ W=b^\mathsf{T}S^{-1}b =\frac{0.0625(0.80^2)-2(0.02)(0.80)(0.50)+0.04(0.50^2)}{0.0021} =\frac{0.0340}{0.0021} \approx16.19. $$

For \(\chi^2_2\), the upper-tail probability is \(\exp(-16.19/2)\approx0.000305\). Thus the estimates are compatible with equal slopes at the first test's level of evidence, while strongly inconsistent with both slopes being zero. Equality and no effect answer different scientific questions.

Common Pitfall and Practical Interpretation

Wrong reasoning: “The test of equal slopes is not significant, so the predictor has no effect.” This confuses a difference, \(\beta_j-\beta_k\), with the coefficients themselves. A failure to reject equality does not establish that the common slope is zero, and it does not establish exact equality.

Correction: Write the null as an explicit contrast before choosing the test. For equality among selected categories, use independent differences and calculate their covariance from the full fitted covariance matrix. For no predictor effect, set all relevant nonreference slopes to zero and test those restrictions instead. The number of degrees of freedom is the rank of the independent restriction matrix, not the number of pairwise comparisons one can list.

These are statements about log-odds slopes. Equal slopes for two nonreference logits mean that the log odds of either category versus the baseline change at the same rate per unit increase in \(x\); they do not imply that the corresponding category probabilities change equally. Probability changes depend on the full set of category logits and on the covariate values.

Key takeaway: Express equality of selected category-specific slopes as zero-valued linear contrasts. Use \(R\widehat{\operatorname{Var}}(\hat\theta)R^\mathsf{T}\) for their joint uncertainty, and keep the equality hypothesis separate from the hypothesis that all relevant slopes vanish.

Check Your Understanding

Answer each question by identifying the restriction being tested and, where needed, the covariance information required.

  1. In a four-category baseline logit with category 4 as reference, write two independent restrictions for equality of the slopes for categories 1, 2, and 3.
  2. If \(\widehat{\operatorname{Var}}(\hat\beta_1)=0.09\), \(\widehat{\operatorname{Var}}(\hat\beta_2)=0.04\), and \(\widehat{\operatorname{Cov}}(\hat\beta_1,\hat\beta_2)=0.01\), calculate the estimated variance and standard error of \(\hat\beta_1-\hat\beta_2\).
  3. Why is testing \(\beta_1=\beta_2\) generally different from testing \(\beta_1=\beta_2=0\)?
  4. For \(q\) independent restrictions, what is the large-sample reference distribution of the Wald statistic under the null, and why must the restrictions be independent?
  5. What does equality of two nonreference slopes say about log odds, and what does it not imply about category probabilities?
Clinical Biostats