Tutorials › Exam SRM - Statistics for Risk Modeling › Deriving Conditional Slopes in Interaction Models

Exam SRM · Transformations and Collinearity · Tutorial 125 of 926

Deriving Conditional Slopes in Interaction Models

Learn how interaction-model slopes depend on the other predictor and how to quantify their uncertainty at a chosen value.

Advanced 11 min read

What You'll Learn

  • Differentiate a fitted two-predictor interaction model to obtain each conditional slope
  • Interpret how the product-term coefficient changes one predictor’s slope as the other predictor changes
  • Express a conditional slope as a linear combination of regression coefficients
  • Calculate its standard error using coefficient variances and covariances
  • Evaluate conditional slopes and construct tests or confidence intervals at specified predictor values
  • Avoid treating a main-effect coefficient as the slope at every value of the other predictor

Why Conditional Slopes Matter

In a regression model with an interaction between two continuous predictors, the association between one predictor and the response depends on the value of the other predictor. A coefficient on its own therefore does not always describe a predictor’s slope. To interpret the fitted model at a particular setting, calculate the conditional slope there, and account for the uncertainty in every coefficient that contributes to it.

This tutorial uses the ordinary least squares model with a product term. The same differentiation applies to the model’s fitted mean, whether or not a particular application supports a causal interpretation. The predictors and their units must be stated, since a slope’s units are response units per predictor unit.

Definition: For predictors \(x_1\) and \(x_2\), the two-predictor linear interaction model is $$ Y_i=\beta_0+\beta_1x_{i1}+\beta_2x_{i2}+\beta_3x_{i1}x_{i2}+\varepsilon_i. $$ Its fitted conditional mean is \(E[Y\mid x_1,x_2]=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_1x_2\), when \(E[\varepsilon\mid x_1,x_2]=0\). The conditional slope for \(x_1\) at \(x_2=c\) is \(\beta_1+c\beta_3\); the conditional slope for \(x_2\) at \(x_1=a\) is \(\beta_2+a\beta_3\).

Differentiate First, Then Interpret

Write the fitted mean as a function of the two predictors. Holding \(x_2\) fixed, differentiate with respect to \(x_1\); holding \(x_1\) fixed, differentiate with respect to \(x_2\). The resulting slopes are local rates of change in the fitted mean. Since the model is linear in each predictor when the other is fixed, each conditional slope is constant as that predictor varies at the fixed value.

$$ \frac{\partial E[Y\mid x_1,x_2]}{\partial x_1}=\beta_1+\beta_3x_2, \qquad \frac{\partial E[Y\mid x_1,x_2]}{\partial x_2}=\beta_2+\beta_3x_1. $$

The coefficient \(\beta_3\) describes how the conditional slope for one predictor changes as the other predictor increases by one unit. For example, increasing \(x_2\) by one unit changes the slope for \(x_1\) by \(\beta_3\). This is a change in slope, not the slope itself. In particular, \(\beta_1\) is the slope for \(x_1\) only when \(x_2=0\), and \(\beta_2\) is the slope for \(x_2\) only when \(x_1=0\).

Worked Example: Finding Both Slopes at a Specified Setting

A hypothetical model describes annual maintenance cost \(Y\), in hundreds of dollars, using building age \(x_1\), in years, and inspections per year \(x_2\). The fitted model is $$ \widehat{Y}=8+0.50x_1-1.00x_2+0.12x_1x_2. $$ Assume the regression errors are independent and distributed \(N(0,4)\), with mean zero and variance \(4\). At \(x_1=10\) years and \(x_2=2\) inspections per year, find the fitted cost and each conditional slope.

Method. Differentiate the fitted mean for each slope. The error distribution does not change these derivatives; it describes uncertainty around the mean response.

Fitted cost. Substitute the specified values: $$ \widehat{Y}=8+0.50(10)-1.00(2)+0.12(10)(2) =8+5-2+2.4=13.4. $$ Thus, the fitted annual cost is \(13.4\) hundreds of dollars, or $1,340.

Slope for building age. The derivative is \(0.50+0.12x_2\). At \(x_2=2\), $$ 0.50+0.12(2)=0.50+0.24=0.74. $$ At two inspections per year, one additional year of building age corresponds to an increase of \(0.74\) hundreds of dollars in fitted annual cost, or $74 per year of age.

Slope for inspections. The derivative is \(-1.00+0.12x_1\). At \(x_1=10\), $$ -1.00+0.12(10)=-1.00+1.20=0.20. $$ At building age ten years, one additional inspection per year corresponds to an increase of \(0.20\) hundreds of dollars in fitted annual cost, or $20.

Check. The interaction coefficient is \(0.12\). Increasing either fixed predictor by one unit raises the other predictor’s conditional slope by \(0.12\) hundreds of dollars per relevant unit, matching the way both slopes change with the fixed predictor.

Standard Errors for Conditional Slopes

A conditional slope estimated from data is a linear combination of estimated regression coefficients. Its standard error must reflect both the uncertainty in those coefficients and the covariance between them. Let \(\widehat{\beta}_1\) and \(\widehat{\beta}_3\) be the fitted coefficients, and let \(\widehat{\operatorname{Var}}(\widehat{\beta}_1)\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_3)\), and \(\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3)\) be the corresponding entries of their estimated covariance matrix.

Theorem: At \(x_2=c\), the estimated conditional slope for \(x_1\) is \(\widehat{\beta}_1+c\widehat{\beta}_3\). Its estimated variance and standard error are $$ \widehat{\operatorname{Var}}(\widehat{\beta}_1+c\widehat{\beta}_3) =\widehat{\operatorname{Var}}(\widehat{\beta}_1) +c^2\widehat{\operatorname{Var}}(\widehat{\beta}_3) +2c\,\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3), $$ $$ \operatorname{SE}(\widehat{\beta}_1+c\widehat{\beta}_3) =\sqrt{\widehat{\operatorname{Var}}(\widehat{\beta}_1+c\widehat{\beta}_3)}. $$ For the slope for \(x_2\) at \(x_1=a\), interchange \(\widehat{\beta}_1\) with \(\widehat{\beta}_2\) and use \(a\) in place of \(c\).

The covariance term can be positive, negative, or zero, so it must not be dropped unless the covariance is known to be zero. The variance formula is also a special case of the variance of a linear contrast. If \(\widehat{\boldsymbol{\beta}}=(\widehat{\beta}_0,\widehat{\beta}_1,\widehat{\beta}_2,\widehat{\beta}_3)^\mathsf{T}\), the slope for \(x_1\) at \(x_2=c\) is the contrast with coefficient vector \((0,1,0,c)^\mathsf{T}\).

Why the Covariance Formula Holds

For any two random variables \(U\) and \(V\), and constants \(r\) and \(s\), expanding the variance of \(rU+sV\) gives \(\operatorname{Var}(rU+sV)=r^2\operatorname{Var}(U)+s^2\operatorname{Var}(V)+2rs\operatorname{Cov}(U,V)\). Use \(U=\widehat{\beta}_1\), \(V=\widehat{\beta}_3\), \(r=1\), and \(s=c\). This yields the conditional-slope variance directly:

1
Expand the variance.
\(\operatorname{Var}(\widehat{\beta}_1+c\widehat{\beta}_3)=\operatorname{Var}(\widehat{\beta}_1)+\operatorname{Var}(c\widehat{\beta}_3)+2\operatorname{Cov}(\widehat{\beta}_1,c\widehat{\beta}_3)\).
2
Apply constant-multiple rules.
\(\operatorname{Var}(c\widehat{\beta}_3)=c^2\operatorname{Var}(\widehat{\beta}_3)\), and \(\operatorname{Cov}(\widehat{\beta}_1,c\widehat{\beta}_3)=c\operatorname{Cov}(\widehat{\beta}_1,\widehat{\beta}_3)\).
3
Estimate and take the square root.
Replace the unknown variances and covariance with the fitted covariance-matrix entries. The standard error is the nonnegative square root of the resulting estimated variance.

Under the usual OLS model, errors have conditional mean zero, are independent, and have constant variance \(\sigma^2\); the design matrix must have full column rank. The covariance matrix estimated from the regression fit then supplies the standard errors. If errors are additionally conditionally normal, the usual \(t\)-based inference for a coefficient contrast is exact under the model. With a robust covariance estimate, the same linear-combination formula applies using its entries, though the inferential reference procedure must match the chosen robust method.

The derivative and variance calculation concern uncertainty in the fitted mean slope. They do not include the residual variance for a new individual response. A prediction interval for a future response answers a different question and adds response-level variation.

Worked Example: Including the Coefficient Covariance

For a hypothetical portfolio administration model, the estimated coefficient for portfolio size \(x_1\) is \(\widehat{\beta}_1=1.20\), and the estimated product-term coefficient is \(\widehat{\beta}_3=-0.30\). The predictor \(x_2\) is an automation score. At \(x_2=2\), calculate the conditional slope and its standard error using the fitted covariance entries \(\widehat{\operatorname{Var}}(\widehat{\beta}_1)=0.16\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_3)=0.01\), and \(\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3)=0.018\). Assume the hypothetical regression errors are independent \(N(0,9)\), and the residual degrees of freedom are 40.

Conditional slope. At \(x_2=2\), $$ \widehat{\beta}_1+2\widehat{\beta}_3=1.20+2(-0.30)=1.20-0.60=0.60. $$

Estimated variance. Substitute all three covariance entries: $$ 0.16+2^2(0.01)+2(2)(0.018) =0.16+0.04+0.072=0.272. $$ Therefore, the standard error is \(\sqrt{0.272}=0.5215\), or \(0.522\) to three decimals.

Optional inference check. The test statistic for a zero conditional slope is \(0.60/0.5215=1.15\). With 40 degrees of freedom, the two-sided 5% critical value is approximately \(2.021\), so this test does not reject a zero slope at the 5% level. A corresponding 95% interval is \(0.60\mathbin{\pm}2.021(0.5215)\), or approximately \([-0.454,1.654]\), rounded to three decimals.

Common mistake avoided. Omitting the covariance gives the incorrect variance \(0.16+0.04=0.20\), and the incorrect standard error \(\sqrt{0.20}=0.447\). The missing cross term is \(2(2)(0.018)=0.072\), so the correct standard error is \(0.522\).

Using the Full Covariance Matrix

When both conditional slopes are needed, calculate each as its own linear combination. The covariance between \(\widehat{\beta}_2\) and \(\widehat{\beta}_3\) contributes to the uncertainty in the \(x_2\) slope; the covariance between \(\widehat{\beta}_1\) and \(\widehat{\beta}_3\) contributes to the uncertainty in the \(x_1\) slope. Do not substitute one pair of covariance entries for the other.

Worked Example: Two Slopes and a Confidence Interval

In a hypothetical model of claim-review time, \(x_1\) is workload and \(x_2\) is a process score. The fitted coefficients are \(\widehat{\beta}_1=0.80\), \(\widehat{\beta}_2=-0.40\), and \(\widehat{\beta}_3=0.20\). The relevant estimated covariance matrix, in the order \((\widehat{\beta}_1,\widehat{\beta}_2,\widehat{\beta}_3)\), is $$ \begin{pmatrix} 0.25&0&-0.030\\ 0&0.09&0.015\\ -0.030&0.015&0.04 \end{pmatrix}. $$ Assume independent normal regression errors \(N(0,16)\), 36 residual degrees of freedom, and evaluate at \(x_2=3\) and \(x_1=2\).

Slope for workload. At \(x_2=3\), the estimate is $$ 0.80+3(0.20)=1.40. $$ Its variance is $$ 0.25+3^2(0.04)+2(3)(-0.030) =0.25+0.36-0.18=0.43, $$ so its standard error is \(\sqrt{0.43}=0.6557\), or \(0.656\) to three decimals.

Slope for process score. At \(x_1=2\), the estimate is $$ -0.40+2(0.20)=0. $$ Its variance uses the entries for \(\widehat{\beta}_2\) and \(\widehat{\beta}_3\): $$ 0.09+2^2(0.04)+2(2)(0.015) =0.09+0.16+0.06=0.31. $$ Its standard error is \(\sqrt{0.31}=0.5568\), or \(0.557\) to three decimals.

Confidence interval for the workload slope. Using the 95% \(t\) critical value \(2.028\) for 36 degrees of freedom, the interval is $$ 1.40\mathbin{\pm}2.028(0.6557)=1.40\mathbin{\pm}1.330, $$ which is approximately \([0.070,2.730]\), rounded to three decimals. The interval is for the conditional mean slope at \(x_2=3\), not for an individual claim-review time.

Check. The workload-slope variance uses the negative covariance with the product coefficient, which reduces the variance here. The process-score slope uses a different, positive covariance entry. Both variances are positive, as required.

Common Interpretation Traps

  • Reporting a main-effect coefficient as a universal slope. The coefficient \(\widehat{\beta}_1\) is the \(x_1\) slope only at \(x_2=0\). At another value \(c\), use \(\widehat{\beta}_1+c\widehat{\beta}_3\).
  • Dropping the covariance term. Coefficient estimates from the same regression fit are generally not independent. Use the covariance matrix, not only the standard errors listed for individual coefficients.
  • Using a variance where a standard error is requested. Calculate the variance first, then take its square root.
  • Ignoring units or the evaluation point. State the value held fixed and interpret the resulting slope in response units per predictor unit.
  • Extrapolating without caution. A calculated slope is mathematically defined at any value, but its practical interpretation may be unreliable if that value lies far outside the predictor values represented in the data.

The method is aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus: differentiate to identify the conditional effect, express it as a coefficient contrast, and use the relevant covariance entries to quantify its uncertainty. Always identify the conditioning value before interpreting or testing an interaction-model slope.

Check Your Understanding

For each problem, compute the requested conditional slope or uncertainty using the stated values.

  1. A fitted interaction model has \(\widehat{\beta}_1=1.10\) and \(\widehat{\beta}_3=0.20\). Find the estimated slope for \(x_1\) at \(x_2=3\). (Answer: \(1.70\).)
  2. A model has \(\widehat{\beta}_2=-0.50\) and \(\widehat{\beta}_3=0.08\). Find the estimated slope for \(x_2\) at \(x_1=5\). (Answer: \(-0.10\).)
  3. For the slope of \(x_1\), suppose \(x_2=2\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_1)=0.36\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_3)=0.04\), and \(\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3)=0.03\). Calculate its standard error. (Answer: \(0.800\).)
  4. At \(x_2=4\), let \(\widehat{\beta}_1=0.70\), \(\widehat{\beta}_3=-0.15\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_1)=0.09\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_3)=0.01\), and \(\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3)=-0.012\). Find the slope estimate and its standard error. (Answer: slope \(0.10\); standard error \(\sqrt{0.154}=0.392\), rounded to three decimals.)
  5. At \(x_2=2\), let \(\widehat{\beta}_1=0.50\), \(\widehat{\beta}_3=0.10\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_1)=0.09\), \(\widehat{\operatorname{Var}}(\widehat{\beta}_3)=0.01\), and \(\widehat{\operatorname{Cov}}(\widehat{\beta}_1,\widehat{\beta}_3)=0.015\). With 25 residual degrees of freedom, calculate the conditional-slope standard error and 95% \(t\) interval, using \(t^*=2.060\). (Answer: slope \(0.70\), standard error \(\sqrt{0.19}=0.436\), and interval approximately \([-0.198,1.598]\), rounded to three decimals.)
Clinical Biostats