Tutorials › Regression Analysis (Undergraduate) › Testing Differences Between Regression Slopes

Tests and Linear Contrasts · Tutorial 234 of 991

Testing Differences Between Regression Slopes

Use a linear contrast to test whether two regression predictors have different slopes, and interpret the result in context.

Intermediate 9 min read

What You'll Learn

  • Express a difference between two regression slopes as a linear contrast
  • Calculate the contrast estimate and its standard error using coefficient covariance
  • Form and test the null hypothesis that two slopes are equal
  • Use the appropriate regression degrees of freedom and interpret a two-sided p-value
  • Explain why separate tests of individual slopes do not test whether the slopes differ
  • Check whether comparing the slopes is meaningful given the predictors’ units

Why Compare Regression Slopes?

A regression model can describe how an outcome changes with each of several predictors. Sometimes the question is not whether either predictor has a nonzero slope, but whether the estimated change associated with one predictor differs from the change associated with another. For instance, a researcher might ask whether an additional hour of one activity is associated with a different change in an outcome than an additional hour of another activity.

This is a question about the difference between two coefficients. It is not answered by looking separately at the two coefficient tests. The relevant test uses the estimated difference and its uncertainty, including the covariance between the two coefficient estimates.

Writing a Difference of Slopes as a Contrast

Consider a multiple linear regression model with two quantitative predictors and no interaction:

$$ Y_i=\beta_0+\beta_1x_{1i}+\beta_2x_{2i}+\cdots+\beta_kx_{ki}+\varepsilon_i. $$

Here, \(\beta_1\) is the population regression slope for \(x_1\), holding the other predictors in the model fixed; \(\beta_2\) is the corresponding slope for \(x_2\). The question “Are these slopes equal?” can be written as a hypothesis about their difference:

$$ H_0:\beta_1-\beta_2=0 \qquad\text{versus}\qquad H_a:\beta_1-\beta_2\ne 0. $$

The expression \(\beta_1-\beta_2\) is a linear contrast: it combines regression coefficients using specified weights, here \(1\) for \(\beta_1\), \(-1\) for \(\beta_2\), and \(0\) for the other coefficients. Its estimate is \(b_1-b_2\), where \(b_1\) and \(b_2\) are the fitted coefficient estimates.

Definition: The difference between two regression slopes is the contrast \(\beta_1-\beta_2\). Its estimated value is \(b_1-b_2\). A test of equal slopes tests \(H_0:\beta_1-\beta_2=0\), using the standard error of this contrast.

A difference in slopes is most directly interpretable when the two predictors have comparable units and scales. For example, if both predictors are measured in hours, their slopes are changes in the outcome per hour. If one is measured in hours and the other in minutes, the numerical slopes refer to different-sized changes; a comparison may still be defined, but its interpretation depends on the chosen units.

Uncertainty in the Difference

The estimate \(b_1-b_2\) varies from sample to sample. Its variance depends on the variances of the two coefficient estimates and on their covariance:

$$ \operatorname{Var}(b_1-b_2) = \operatorname{Var}(b_1)+\operatorname{Var}(b_2) -2\operatorname{Cov}(b_1,b_2). $$

This follows from the general variance rule \(\operatorname{Var}(A+B)=\operatorname{Var}(A)+\operatorname{Var}(B)+2\operatorname{Cov}(A,B)\), using \(A=b_1\) and \(B=-b_2\). Since \(\operatorname{Cov}(b_1,-b_2)=-\operatorname{Cov}(b_1,b_2)\), the covariance term is subtracted. Taking the square root gives the estimated standard error:

$$ SE(b_1-b_2) = \sqrt{SE(b_1)^2+SE(b_2)^2 -2\widehat{\operatorname{Cov}}(b_1,b_2)}. $$

The covariance here is the estimated covariance between the two coefficient estimates from the same fitted model. It cannot generally be omitted or replaced by a comparison of the coefficients’ separate standard errors. As the earlier material on contrast standard errors explains, the covariance affects how uncertain the difference is.

The t Test for Equal Slopes

For the usual regression t test, assume the regression model has a correctly specified linear conditional mean, independent errors with mean zero and constant variance, and normally distributed errors for an exact small-sample t distribution. The predictor values are treated as fixed, or the analysis is understood conditional on them. The model must also be estimable: the predictors cannot be perfectly linearly dependent. Under these conditions, the contrast estimate has standard error \(SE(b_1-b_2)\), and under the null hypothesis its t statistic is compared with a t distribution using the residual degrees of freedom from the full fitted model.

$$ t=\frac{(b_1-b_2)-0}{SE(b_1-b_2)}. $$

For the two-sided alternative, the p-value is the probability, assuming \(H_0\) and the model assumptions, of observing a t statistic at least as far from zero as the one calculated. A small p-value is evidence against equal population slopes; it does not measure the probability that the null hypothesis is true.

Worked Example: Comparing Two Slopes Measured in Hours

Suppose a hypothetical model predicts a quiz score from weekly hours spent in two activities, along with other specified predictors. Both activity variables are measured in hours per week, and the outcome is measured in quiz-score points. The fitted slopes are \(b_1=1.80\) and \(b_2=1.10\) points per hour. Their standard errors are \(0.40\) and \(0.30\), and their estimated covariance is \(0.060\). The model has \(df=36\). For this hypothetical analysis, assume independent observations and that residual checks support the linearity, constant-variance, and approximate-normality conditions.

The estimated slope difference is

$$ b_1-b_2=1.80-1.10=0.700 \quad\text{quiz-score points per hour}. $$

The standard error of this difference is

$$ SE(b_1-b_2) = \sqrt{0.40^2+0.30^2-2(0.060)} = \sqrt{0.160+0.090-0.120} = \sqrt{0.130} = 0.361. $$

To test \(H_0:\beta_1-\beta_2=0\) against a two-sided alternative, calculate

$$ t=\frac{0.700-0}{0.361}=1.94. $$

With \(df=36\), the two-sided p-value is approximately \(0.060\). At significance level \(\alpha=0.05\), this result does not provide sufficient evidence that the two population slopes differ. The estimated difference is \(0.700\) quiz-score points per additional weekly hour, but the uncertainty is large enough that the test does not rule out an equal-slope value.

Worked Tests and Interpretation

Worked Example: A Negative Covariance Between Slope Estimates

In a separate hypothetical study, a model predicts a symptom score from hours of sleep and hours of light exercise per day, with both predictors measured in hours. The fitted slopes are \(b_{\text{sleep}}=-1.20\) and \(b_{\text{exercise}}=-0.20\) symptom-score points per hour. Their standard errors are \(0.50\) and \(0.40\), and the estimated covariance is \(-0.080\). The model has \(df=48\). Assume the observations are independent and diagnostics support the stated regression assumptions.

Take the difference as sleep slope minus exercise slope:

$$ b_{\text{sleep}}-b_{\text{exercise}} = -1.20-(-0.20) = -1.00 \quad\text{symptom-score points per hour}. $$

The contrast standard error is

$$ SE = \sqrt{0.50^2+0.40^2-2(-0.080)} = \sqrt{0.250+0.160+0.160} = \sqrt{0.570} = 0.755. $$

The test statistic for equal slopes is

$$ t=\frac{-1.00}{0.755}=-1.32. $$

With \(df=48\), the two-sided p-value is approximately \(0.193\). At \(\alpha=0.05\), there is not sufficient evidence that the two slopes differ. The negative estimated contrast says the sleep slope is one point per hour lower than the exercise slope in this fitted model. It does not establish that the population slopes are different. Because the coefficient covariance is negative, the contrast variance includes a positive contribution from subtracting twice that covariance.

Worked Example: Testing a Small Estimated Difference

A third hypothetical regression predicts a laboratory outcome, in measurement units, from two exposures measured in the same units. The estimated slopes are \(b_1=0.85\) and \(b_2=1.10\) outcome units per exposure unit. Their standard errors are \(0.22\) and \(0.25\), and their estimated covariance is \(0.030\). The residual degrees of freedom are \(60\). Assume the data and diagnostics satisfy the model conditions for this test.

The estimated contrast, in the stated order, is

$$ b_1-b_2=0.85-1.10=-0.250 \quad\text{outcome units per exposure unit}. $$

Its standard error is

$$ SE = \sqrt{0.22^2+0.25^2-2(0.030)} = \sqrt{0.0484+0.0625-0.0600} = \sqrt{0.0509} = 0.226. $$

Therefore,

$$ t=\frac{-0.250}{0.226}=-1.11. $$

With \(df=60\), the two-sided p-value is approximately \(0.271\). At the 5% significance level, the result does not provide evidence that the slopes differ. The fitted slope for predictor 1 is lower by \(0.250\) outcome units per exposure unit, but this estimated difference is small relative to its standard error.

A Practical Testing Sequence

For a slope comparison, state the contrast and its order before calculating. Reversing the order changes the sign of the estimate and t statistic but not the two-sided p-value. The same sign convention should be used when describing which slope is larger.

1
Define the contrast.
Write, for example, \(\beta_1-\beta_2\), and identify the units in which the two slopes are being compared.
2
State the hypotheses.
For equality, use \(H_0:\beta_1-\beta_2=0\). Choose a two-sided or directional alternative to match the research question.
3
Estimate the contrast and its uncertainty.
Calculate \(b_1-b_2\) and the standard error using both coefficient variances and their covariance.
4
Calculate and interpret the test.
Divide the estimated contrast by its standard error under the null, use the full model’s residual degrees of freedom, and report the p-value in context.

Why Separate Coefficient Tests Are Not Enough

A common mistake is to compare the individual coefficient p-values: if one slope is “significant” and the other is not, conclude that the slopes differ. That reasoning is incorrect. Each individual test asks whether one slope differs from zero; neither tests whether the two slopes differ from each other. A coefficient can be estimated precisely enough to differ from zero while its difference from another coefficient remains uncertain. Conversely, both individual tests can be inconclusive while the difference is estimated precisely enough to stand out. Only the contrast test directly addresses equality.

Another mistake is to calculate the difference’s standard error as \(\sqrt{SE(b_1)^2+SE(b_2)^2}\) without checking covariance. That expression is correct only when the coefficient estimates have zero covariance. In a multiple regression, coefficient estimates from the same model are often correlated. Use their estimated covariance when calculating the uncertainty of their difference.

Key takeaway: To test whether two regression slopes differ, test the contrast \(\beta_1-\beta_2\), not the two slopes separately. The contrast standard error must account for the covariance of the coefficient estimates, and the conclusion should describe evidence about the difference in context.

Check Your Understanding

Try these questions without looking back.

  1. Write the null hypothesis for testing whether \(\beta_2\) and \(\beta_4\) are equal.
  2. Why does the standard error of \(b_1-b_2\) include a covariance term?
  3. If a two-sided test of equal slopes has a large p-value, what conclusion is appropriate, and what conclusion is not justified?
  4. Why does finding one individually significant slope and one individually nonsignificant slope not establish that the slopes differ?
  5. What changes, and what stays the same, if the order of the contrast is reversed from \(b_1-b_2\) to \(b_2-b_1\)?