Why a Conditional Slope Needs Its Own Standard Error
In an interaction model, the slope relating a predictor to an outcome can depend on another predictor. The estimated conditional slope is therefore usually a combination of regression coefficient estimates, rather than a single coefficient. Its standard error must account for the uncertainty in every coefficient in that combination—and for how their estimates vary together.
This tutorial develops that calculation. The key is to use the estimated variance-covariance matrix of the regression coefficients. Using only the standard errors of the individual coefficients, or adding their variances without the covariance term, can give the wrong uncertainty for a conditional slope.
Model and General Formula
Consider the two-predictor interaction model
Here \(Y\) is the outcome, \(X\) and \(Z\) are predictors, and the \(\beta\)'s are population regression coefficients. The conditional slope of the mean of \(Y\) with respect to \(X\), at a fixed value \(Z=z_0\), is \(\beta_1+\beta_3z_0\). The corresponding estimated slope is \(b_1+b_3z_0\), where each \(b_j\) estimates \(\beta_j\).
For the usual OLS standard error calculation, assume the conditional mean is correctly represented by this model and the errors have mean zero, are independent, and have constant variance. The conventional OLS covariance matrix estimate uses those constant-variance assumptions. Normality is not needed to calculate the standard error itself; it is relevant to exact small-sample inference. If a different, such as heteroskedasticity-robust, coefficient covariance matrix is used, the same linear-combination calculation applies to that matrix.
For the coefficient order \((b_0,b_1,b_2,b_3)\), write the estimated covariance matrix as \(\widehat{\mathrm{Var}}(\mathbf{b})\). The conditional slope estimate is the linear combination \(\mathbf{c}^{\mathsf T}\mathbf{b}\), where \(\mathbf{c}=(0,1,0,z_0)^{\mathsf T}\). Its estimated variance and standard error are
The intercept and the coefficient of \(Z\) do not appear in this particular slope combination, so their variances and covariances do not enter this calculation. The covariance that matters is between \(b_1\) and \(b_3\): the main-effect coefficient for \(X\), and the interaction coefficient.
Why the Covariance Term Appears
For any two random quantities \(U\) and \(V\), and fixed numbers \(a\) and \(d\), the variance of their weighted sum is
Apply this identity to \(U=b_1\), \(V=b_3\), \(a=1\), and \(d=z_0\). This gives the conditional-slope variance formula above. The covariance term measures whether samples that produce a larger estimate of \(b_1\) also tend to produce a larger or smaller estimate of \(b_3\). If the covariance is negative, the two estimates tend to offset each other in the sum at positive \(z_0\); if it is positive, they tend to move together. The term changes sign with \(z_0\), so the effect of a negative covariance reverses when \(z_0\) is negative.
A software output table may show a standard error for each coefficient but not the covariance between coefficients. A standard error is the square root of a diagonal element of the covariance matrix; the needed covariance is an off-diagonal element. If only the standard errors are available, the conditional-slope standard error generally cannot be calculated exactly from that information alone.
Worked Example: A Slope at a Fixed Moderator Value
Suppose a hypothetical model relates test score \(Y\), measured in points, to weekly study time \(X\), measured in hours, and class size \(Z\), measured in tens of students. The fitted interaction model gives \(b_1=1.20\) and \(b_3=0.35\). At \(z_0=2\), corresponding to a class size of 20 students, the estimated conditional slope is
points of test score per additional weekly study hour, at that class size. Suppose the estimated variances and covariance are \(\widehat{\mathrm{Var}}(b_1)=0.1600\), \(\widehat{\mathrm{Var}}(b_3)=0.0225\), and \(\widehat{\mathrm{Cov}}(b_1,b_3)=-0.0300\). Then
Thus the standard error is \(\sqrt{0.1300}=0.3606\) test-score points per weekly study hour. The covariance is negative and, at this positive moderator value, reduces the estimated variance compared with omitting the covariance term. It does not change the estimated slope of 1.90; it changes the estimate of its sampling variability.
Conditional Slopes With a Categorical Moderator
The same rule applies when \(Z\) is a zero-one indicator for group membership. In the model \(E(Y\mid X,G)=\beta_0+\beta_1X+\beta_2G+\beta_3XG\), the reference group (\(G=0\)) has slope \(\beta_1\), and the group with \(G=1\) has slope \(\beta_1+\beta_3\). The estimated slope for the second group is therefore a sum of two estimates, and its variance includes their covariance.
Worked Example: Comparing Slope Uncertainty Across Two Groups
In a hypothetical analysis, \(Y\) is blood pressure in millimeters of mercury, \(X\) is weekly exercise time in hours, and \(G=1\) identifies people in one program group; \(G=0\) is the reference group. The fitted model estimates \(b_1=-0.80\) and \(b_3=-0.40\) millimeters of mercury per exercise hour. The estimated slope for \(G=1\) is
millimeters of mercury per additional weekly exercise hour. Suppose \(\widehat{\mathrm{Var}}(b_1)=0.0900\), \(\widehat{\mathrm{Var}}(b_3)=0.0625\), and \(\widehat{\mathrm{Cov}}(b_1,b_3)=-0.0450\). Since the group indicator is \(G=1\), the calculation is
The estimated standard error of the slope for \(G=1\) is 0.2500 millimeters of mercury per exercise hour. For \(G=0\), the slope is \(b_1\) alone, so its standard error is \(\sqrt{0.0900}=0.3000\) millimeters of mercury per exercise hour. These calculations describe the fitted associations; they do not, by themselves, establish that exercise causes a change in blood pressure.
Centering Changes the Coefficients, Not the Rule
If a moderator has been centered, use its value on the centered scale in the formula. For example, if \(Z_c=Z-\bar{Z}\), then the conditional slope at a raw moderator value \(z_0\) is \(b_1+b_3(z_0-\bar{Z})\), not \(b_1+b_3z_0\). The standard error uses the same multiplier \(z_0-\bar{Z}\) in both the squared-variance term and the covariance term.
Worked Example: A Slope Three Units Above the Moderator Mean
Suppose a hypothetical model predicts an assessment score \(Y\) from weekly study hours \(X\) and a centered baseline score \(Z_c\), where \(Z_c=Z-5\). The estimates are \(b_1=2.40\) and \(b_3=-0.20\). At a baseline score of 8, \(Z_c=8-5=3\), so the estimated slope is
assessment-score points per additional weekly study hour. Suppose \(\widehat{\mathrm{Var}}(b_1)=0.0900\), \(\widehat{\mathrm{Var}}(b_3)=0.0100\), and \(\widehat{\mathrm{Cov}}(b_1,b_3)=0.0120\). Then
The estimated standard error is 0.5020 assessment-score points per weekly study hour. The positive covariance increases the estimated variance at this positive centered value. Using the raw score 8 as the multiplier would be incorrect because the fitted model uses the centered moderator \(Z_c\), not the raw score \(Z\).
Common Mistakes and Practical Checks
A frequent mistake is to calculate the variance of a conditional slope by adding only the coefficient variances. In the first example, that would give \(0.1600+4(0.0225)=0.2500\), leading to a standard error of \(0.5000\), rather than the correct \(0.3606\). The omitted covariance term is \(4(-0.0300)=-0.1200\), so the shortcut gives a different result. It is not generally conservative or liberal: depending on the covariance and moderator value, it can overstate or understate the uncertainty.
Another mistake is to add standard errors instead of variances. Standard errors are square roots of variances, and the variance-of-a-sum rule applies to variances and covariances. A reliable calculation follows this order: identify the coefficient combination, use the matching covariance-matrix entries, calculate its variance, and then take the square root.
Before reporting a result, check that the coefficient order and moderator value match the fitted model's coding and scale. For a group indicator, confirm which group is coded 0 and which is coded 1. For a centered moderator, use the centered value. Finally, check that the quantity inside the square root is nonnegative; a negative result usually signals a transcription, coding, or covariance-matrix error.
Check Your Understanding
For each question, identify the coefficient combination before calculating or explaining its uncertainty.
- In the model \(E(Y\mid X,Z)=\beta_0+\beta_1X+\beta_2Z+\beta_3XZ\), write the estimated slope for \(X\) at \(Z=z_0\) and its estimated variance.
- Why is the covariance between \(b_1\) and \(b_3\) needed to calculate the standard error of \(b_1+z_0b_3\)?
- For a zero-one group indicator \(G\), which group has slope \(b_1+b_3\), and which group has slope \(b_1\)?
- If a moderator is centered at 5 and the slope is requested at its raw value 8, what moderator value belongs in the conditional-slope formula?
- Can the exact standard error of a conditional slope generally be recovered from the individual coefficient standard errors alone? Explain what additional quantity is needed.