Why Conditional Slopes Need Their Own Tests
In an interaction model, the association between a predictor and a response depends on the value or group of another variable. A coefficient test for the predictor alone therefore does not necessarily answer whether its slope is zero for a particular group or at a particular moderator value. To answer that question, first express the conditional slope as a combination of model coefficients, then test that combination.
The method is a direct application of linear contrasts. The estimate of a conditional slope may combine several estimated coefficients, and its standard error must reflect both their uncertainty and their covariance. Ignoring that covariance can produce the wrong standard error and test result.
Writing the Conditional Slope as a Contrast
Consider a model with quantitative response \(Y\), predictor \(x\), and moderator \(z\):
Here \(x_iz_i\) is the interaction term. For a fixed moderator value \(z=z_0\), the terms involving \(x\) are \((\beta_1+\beta_3z_0)x\). Thus the slope of the model mean with respect to \(x\), at \(z_0\), is \(\beta_1+z_0\beta_3\). The term \(\beta_2z_0\) changes the model mean at that moderator value, but not its slope with respect to \(x\).
A binary group indicator is a special case. Let \(G=0\) denote one group and \(G=1\) the other, and fit \(Y_i=\beta_0+\beta_1x_i+\beta_2G_i+\beta_3x_iG_i+\varepsilon_i\). The slope for \(G=0\) is \(\beta_1\); for \(G=1\), it is \(\beta_1+\beta_3\). The difference between the \(G=1\) and \(G=0\) slopes is \(\beta_3\).
More generally, a linear contrast is \(L=\mathbf{c}^{\mathsf T}\boldsymbol{\beta}\), a specified weighted sum of regression coefficients. If \(\widehat{\mathbf{V}}\) is the estimated covariance matrix of the coefficient estimates, the estimated contrast and its standard error are:
For the slope at \(z_0\), the relevant weights on \((\beta_1,\beta_3)\) are \((1,z_0)\). For a binary group slope at \(G=1\), the weights on those coefficients are \((1,1)\). A test of whether a conditional slope equals a benchmark \(L_0\) uses \(H_0:L=L_0\) and the statistic \(t=(\hat{L}-L_0)/SE(\hat{L})\), with the regression residual degrees of freedom.
Why the Covariance Is Part of the Standard Error
For a conditional slope \(L=\beta_1+z_0\beta_3\), the estimated slope is a sum of two estimates. The variance of a sum includes a covariance term:
This follows by expanding the variance of a linear combination: for random quantities \(A\) and \(B\), \(\operatorname{Var}(A+cB)=\operatorname{Var}(A)+c^2\operatorname{Var}(B)+2c\operatorname{Cov}(A,B)\). Setting \(A=\hat{\beta}_1\), \(B=\hat{\beta}_3\), and \(c=z_0\) gives the expression above. The covariance may be positive, negative, or zero; it cannot generally be omitted.
Assumptions for the Tests
The formulas for a contrast are algebraically valid for fitted coefficients, but the usual regression \(t\) test and its reference distribution depend on the model assumptions. For the interaction model, assume the conditional mean has the stated linear form, observations are independent, errors have mean zero and a common variance, and errors are normally distributed for an exact \(t\) reference distribution. The predictor and moderator values must also provide information to estimate the coefficients; in particular, the model terms must not be perfectly collinear.
In practice, assess whether the interaction model is a reasonable description of the data and whether the residual behavior is consistent with these assumptions. The worked examples below stipulate that the interaction form and residual checks are adequate, observations are independent, and the model is estimable. Without such justification, a computed \(t\) statistic does not by itself establish that the reported test is trustworthy.
Worked Example: Testing a Slope in One Group
Suppose a hypothetical study models a response \(Y\), measured in points, by predictor \(x\), measured in study hours, and binary group \(G\). The fitted model is \(\hat{Y}=\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2G+\hat{\beta}_3xG\). The estimated slope coefficients are \(\hat{\beta}_1=1.20\) points per hour and \(\hat{\beta}_3=-0.50\) points per hour. Their estimated variances are \(0.16\) and \(0.09\), and their estimated covariance is \(-0.04\). There are 24 residual degrees of freedom. Test whether the slope for \(G=1\) is zero, two-sided.
The conditional slope for \(G=1\) is \(\beta_1+\beta_3\), so the estimate is \(1.20+(-0.50)=0.700\) points per hour. Its estimated variance includes the covariance:
For \(H_0:\beta_1+\beta_3=0\) against \(H_a:\beta_1+\beta_3\ne0\),
With \(df=24\), the two-sided \(p\)-value is approximately \(0.1025\). At the 0.05 significance level, this is not sufficient evidence that the \(G=1\) slope differs from zero. The estimate is positive, but the test does not establish that the population slope is positive. The stated model and residual conditions are assumed to have been checked, and the model is estimable.
Testing a Slope at a Chosen Moderator Value
When \(z\) is quantitative, a conditional slope can be tested at any specified value \(z_0\) for which the fitted model is meaningful. The null hypothesis for a zero slope is \(H_0:\beta_1+z_0\beta_3=0\). To test another benchmark, replace zero with that benchmark. The test concerns the slope of the fitted mean response with respect to \(x\) at \(z_0\), not the coefficient \(\beta_1\) alone except when \(z_0=0\).
Worked Example: Testing a Slope at a Moderator Value
In a hypothetical model, \(Y\) is measured in units and \(x\) in hours. The quantitative moderator \(z\) is measured in tens of units. The fitted coefficients are \(\hat{\beta}_1=0.80\) units per hour and \(\hat{\beta}_3=0.35\) units per hour per unit of \(z\). The estimated variances are \(0.04\) and \(0.01\), and the estimated covariance is \(0.005\). At \(z_0=2\), test whether the slope of \(Y\) on \(x\) is zero. Suppose \(df=36\).
The conditional slope estimate is
units per hour. Its estimated variance and standard error are
For \(H_0:\beta_1+2\beta_3=0\) against a two-sided alternative,
With 36 degrees of freedom, the two-sided \(p\)-value is less than \(0.001\). The data provide evidence that the conditional slope at \(z=2\) differs from zero; the estimated association is an increase of 1.50 response units per additional hour at that moderator value. This is an association described by the model, not a causal effect. For this hypothetical analysis, assume the value \(z=2\) is within the observed moderator range, the interaction model is appropriate, observations are independent, residual checks support constant variance and approximate normality, and the model terms are estimable.
Testing Whether Two Conditional Slopes Differ
To compare slopes at two moderator values, subtract their conditional-slope expressions. At \(z_a\) and \(z_b\), the slopes are \(\beta_1+z_a\beta_3\) and \(\beta_1+z_b\beta_3\). Their difference, defined as the slope at \(z_b\) minus the slope at \(z_a\), simplifies to \((z_b-z_a)\beta_3\). The common \(\beta_1\) term cancels. Thus testing whether these two slopes are equal is equivalent to testing whether this contrast is zero. In the binary-group model, the corresponding slope difference is simply \(\beta_3\).
Worked Example: Comparing Slopes at Two Moderator Values
A hypothetical interaction model relates \(Y\), measured in milligrams, to \(x\), measured in days, and a quantitative moderator \(z\). The estimated interaction coefficient is \(\hat{\beta}_3=-0.25\) milligrams per day per unit of \(z\), with standard error \(0.10\). Compare the slope at \(z=3\) with the slope at \(z=1\), using the order “at 3 minus at 1.” Suppose the model has 28 residual degrees of freedom.
The difference in slopes is
Its estimate is \(2(-0.25)=-0.50\) milligrams per day. Multiplying a coefficient by 2 multiplies its standard error by \(|2|\), so the contrast standard error is \(2(0.10)=0.20\) milligrams per day. Testing \(H_0:2\beta_3=0\) against \(H_a:2\beta_3\ne0\) gives
With \(df=28\), the two-sided \(p\)-value is approximately \(0.01855\). At the 0.05 level, the data provide evidence that the conditional slopes differ. The estimated slope at \(z=3\) is 0.50 milligrams per day smaller than the slope at \(z=1\). This conclusion assumes the interaction model is suitable across the moderator range from 1 to 3, with independent observations, acceptable residual behavior, and estimable model terms.
A Reliable Testing Sequence
Substitute the specified group or moderator value into the model and collect the terms multiplying the predictor.
Write the slope, slope difference, or benchmark comparison as a linear combination of coefficients, then state \(H_0\) and \(H_a\).
Use the contrast weights and the estimated coefficient covariance matrix; do not discard covariance terms.
Form the \(t\) statistic, use the regression residual degrees of freedom, and report the conclusion in the response and predictor units.
Common Mistake: Testing the Wrong Coefficient
A frequent error is to use the \(t\) test for \(\beta_1\) as if it tested the slope for every group or moderator value. In the quantitative-moderator model, \(\beta_1\) is the slope only at \(z=0\); at \(z=2\), for example, the slope is \(\beta_1+2\beta_3\). Likewise, in a binary-group model, \(\beta_1\) is the slope for \(G=0\), while the slope for \(G=1\) is \(\beta_1+\beta_3\). The correction is to write the requested slope explicitly and test that linear contrast with its own standard error.
A related mistake is to calculate the variance of a sum by adding only the coefficient variances. The correct expression includes twice the covariance, multiplied by the contrast weights. Because the covariance can materially change the result, a slope contrast cannot generally be tested by combining coefficient standard errors alone.
Check Your Understanding
For each question, identify the relevant contrast before deciding what a coefficient test would answer.
- In \(Y=\beta_0+\beta_1x+\beta_2G+\beta_3xG+\varepsilon\), what is the slope for \(G=1\), and what is the difference between the \(G=1\) and \(G=0\) slopes?
- For \(Y=\beta_0+\beta_1x+\beta_2z+\beta_3xz+\varepsilon\), write the slope of \(Y\) on \(x\) at \(z=4\).
- If the variances of \(\hat{\beta}_1\) and \(\hat{\beta}_3\) are 0.09 and 0.04, and their covariance is \(-0.01\), calculate the variance of \(\hat{\beta}_1+2\hat{\beta}_3\).
- In the quantitative-moderator model, express the slope at \(z=5\) minus the slope at \(z=2\) as a coefficient contrast.
- Why is the standard error of a conditional slope not generally obtained by adding the standard errors of its component coefficients?