Tutorials › Regression Analysis (Undergraduate) › A Worked Analysis of Differences in Dose Slopes by Group

Interactions Among Groups · Tutorial 367 of 991

A Worked Analysis of Differences in Dose Slopes by Group

Learn how to fit and compare group-specific dose-response slopes, interpret the test, and see where predictions are supported by observed doses.

Intermediate 9 min read

What You'll Learn

  • Write a linear model that allows dose slopes to differ by group.
  • Fit each group’s line and interpret its intercept and slope in context.
  • Test a contrast between the two dose slopes using a pooled standard error.
  • Calculate fitted outcomes at selected doses and describe how to plot them.
  • Check the dose ranges represented in each group and identify extrapolation.
  • Distinguish evidence of a slope difference from evidence that slopes are equal.

Introduction

A dose-response relationship can differ across groups in more than its starting level. For example, two groups might have different expected outcomes at zero dose, while the outcome also changes at a different rate with dose in each group. To investigate that question, fit a line for each group and compare the slopes directly. The slope contrast—not whether one group’s slope is individually “significant” and the other’s is not—is the quantity that addresses whether the dose-response rates differ.

The analysis below uses a small, entirely hypothetical data set. The outcome is an assay measurement in units, and dose is measured in milligrams per day. The calculations illustrate a linear model, a test of the difference in slopes, a plot of fitted values, and a check of which doses are represented in both groups. A fitted association does not, by itself, establish that changing dose causes the outcome to change.

Model and Assumptions

Let \(Y\) be the outcome, \(x\) the dose, and let \(G=0\) indicate Group A and \(G=1\) indicate Group B. A model with a separate intercept and slope for each group is

$$ Y_i=\beta_0+\beta_1x_i+\beta_2G_i+\beta_3x_iG_i+\varepsilon_i. $$

For Group A, setting \(G=0\) gives the fitted line \(\beta_0+\beta_1x\). For Group B, setting \(G=1\) gives \((\beta_0+\beta_2)+(\beta_1+\beta_3)x\). Thus \(\beta_2\) is the difference in intercepts, and \(\beta_3\) is the difference in slopes (Group B minus Group A). The group-specific lines can equivalently be fitted separately by ordinary least squares; the model above expresses both lines together.

Definition: A group-specific dose slope is the change in the fitted mean outcome associated with a one-unit increase in dose within a stated group, holding the group fixed. In this model the Group A slope is \(\beta_1\), the Group B slope is \(\beta_1+\beta_3\), and their difference is \(\beta_3\). The slope’s units are outcome units per milligram per day.

For the usual pooled \(t\)-test of the slope difference, assume the conditional mean is linear in dose within each group; observations have independent errors with mean zero; and the errors have a common variance \(\sigma^2\) across doses and groups. Normal errors give the test its exact small-sample \(t\) distribution. The data should also provide dose variation within each group, so that each group’s slope can be estimated. These are model assumptions, not facts guaranteed by fitting lines. Inspecting the data and residuals can help assess whether they are plausible.

Fitting the Group-Specific Lines

Worked Example: Estimate Each Group’s Dose Slope

Suppose the hypothetical observations are as follows. Each row represents a different individual, and all outcomes are measured in assay units.

Dose (mg/day)Group A outcomeGroup B outcome
01114
11020
21421
31822
41728

For each group, the least-squares slope is \(b_1=\sum_i(x_i-\bar{x})(y_i-\bar{y})/\sum_i(x_i-\bar{x})^2\), and the intercept is \(b_0=\bar{y}-b_1\bar{x}\). In both groups, \(\bar{x}=2\), and

$$ S_{xx}=\sum_i(x_i-\bar{x})^2=(-2)^2+(-1)^2+0^2+1^2+2^2=10. $$

For Group A, \(\bar{y}_A=14\). Its cross-product sum is \(6+4+0+4+6=20\), so \(b_{1A}=20/10=2\) assay units per mg/day. Its intercept is \(b_{0A}=14-(2)(2)=10\). The fitted line is \(\hat{Y}_A=10+2x\).

For Group B, \(\bar{y}_B=21\). Its cross-product sum is \(14+1+0+1+14=30\), so \(b_{1B}=30/10=3\) assay units per mg/day. Its intercept is \(b_{0B}=21-(3)(2)=15\). The fitted line is \(\hat{Y}_B=15+3x\).

The estimated slope difference, Group B minus Group A, is \(3-2=1\) assay unit per mg/day. In the combined model, these estimates correspond to \(b_1=2\), \(b_2=15-10=5\), and \(b_3=1\). The intercept difference describes the fitted difference at dose zero; it is not the slope difference.

Testing Whether the Slopes Differ

The formal question is whether the population slopes are equal. In the combined model this is a test of the interaction coefficient:

$$ H_0:\beta_3=0 \qquad\text{versus}\qquad H_a:\beta_3\ne 0. $$

A standard pooled test estimates the common error variance from the residuals around both fitted lines. With \(n\) observations and four fitted coefficients (two intercepts and two slopes), the residual degrees of freedom are \(df=n-4\). For two groups with within-group dose sums of squares \(S_{xx,A}\) and \(S_{xx,B}\), the standard error of the estimated slope difference is

$$ SE(b_{1B}-b_{1A})= \sqrt{MSE\left(\frac{1}{S_{xx,A}}+\frac{1}{S_{xx,B}}\right)}, \qquad MSE=\frac{SSE}{df}. $$

Here \(SSE\) is the sum of squared residuals from both group-specific lines. This standard error relies on the common error-variance assumption; it is not the appropriate pooled formula if that assumption is implausible.

Justification: Within one group, the estimated slope can be written \(b_1=\sum_i(x_i-\bar{x})Y_i/S_{xx}\). Under independent errors with variance \(\sigma^2\), its variance is \(\sigma^2/S_{xx}\), because the variance of the numerator is \(\sigma^2\sum_i(x_i-\bar{x})^2=\sigma^2S_{xx}\). The two groups’ slope estimates are independent when their observations are independent, so the variance of their difference is \(\sigma^2(1/S_{xx,A}+1/S_{xx,B})\). Replacing \(\sigma^2\) by the pooled estimate \(MSE\) gives the stated standard error.

Worked Example: Test the Difference in Dose Slopes

Use the fitted lines from the hypothetical data. The Group A residuals (observed minus fitted) are \(1,-2,0,2,-1\), and the Group B residuals are \(-1,2,0,-2,1\). Each group’s sum of squared residuals is \(1+4+0+4+1=10\), so the combined \(SSE=10+10=20\). There are \(n=10\) observations and four fitted coefficients, giving \(df=10-4=6\) and \(MSE=20/6=3.333\) assay-units-squared.

Both groups have \(S_{xx}=10\), and the estimated slope difference is 1 assay unit per mg/day. Therefore,

$$ SE=\sqrt{3.333\left(\frac{1}{10}+\frac{1}{10}\right)} =\sqrt{0.6667}=0.8165. $$

The test statistic is \(t=(1-0)/0.8165=1.225\), with \(df=6\). The two-sided \(p\)-value is approximately 0.267. At significance level \(\alpha=0.05\), this is not sufficient evidence to reject equal slopes. The data do not establish that the slopes are equal; they leave substantial uncertainty about their difference.

A 95% confidence interval provides a scale for that uncertainty. Using \(t^*=2.447\) for 6 degrees of freedom, the interval is

$$ 1\mathbin{\pm}2.447(0.8165) =1\mathbin{\pm}1.998 =(-0.998,\ 2.998) $$

assay units per mg/day. Under the model and sampling procedure, intervals calculated this way capture the true slope difference in 95% of repeated samples. This particular interval includes zero and also allows for appreciable differences in either direction.

Plotting Fitted Values and Checking Dose Overlap

Worked Example: Plot the Lines Where Both Groups Have Data

For the fitted lines \(\hat{Y}_A=10+2x\) and \(\hat{Y}_B=15+3x\), calculate predictions at each observed dose:

Dose (mg/day)Group A fitted outcomeGroup B fitted outcome
0\(10+2(0)=10\)\(15+3(0)=15\)
1\(10+2(1)=12\)\(15+3(1)=18\)
2\(10+2(2)=14\)\(15+3(2)=21\)
3\(10+2(3)=16\)\(15+3(3)=24\)
4\(10+2(4)=18\)\(15+3(4)=27\)

A graph can place dose on the horizontal axis and fitted outcome in assay units on the vertical axis, then draw one line for each group through its fitted values. Distinct symbols can show the observed outcomes as well. Label the groups and axes with units. The fitted values are estimates of conditional mean outcomes, not predictions guaranteed for individual observations.

In this data set, the observed dose range is 0 to 4 mg/day in both groups. The shared range is found by taking the larger lower endpoint and the smaller upper endpoint: \([\max(0,0),\min(4,4)]=[0,4]\). Thus every dose shown falls within the observed range of each group.

The overlap check matters especially when group ranges differ. For instance, if Group A were observed only from 0 to 4 mg/day and Group B only from 3 to 7 mg/day, the shared range would be \([\max(0,3),\min(4,7)]=[3,4]\). Comparing fitted lines at doses well below 3 or above 4 would use extrapolation for at least one group. Even when a model calculates such fitted values, they are not supported by observations from both groups at those doses. Limited overlap can therefore make a broad comparison of dose-response patterns depend heavily on the assumed linear form.

Common Mistakes and Why the Analysis Matters

The slope contrast gives a direct answer to whether the fitted dose-response rates differ, in a way that separate descriptions of the two lines cannot. The plot shows the estimated patterns, while the test quantifies uncertainty about their slope difference. The overlap check adds an important qualification: a comparison across a dose range is most grounded where both groups have observations.

  • Comparing two separate significance results. “The slope is significant in Group A but not in Group B” does not establish that the slopes differ. Test the contrast \(H_0:\beta_3=0\) directly.
  • Reading a non-significant result as proof of equality. A \(p\)-value above \(\alpha\) means the data did not provide sufficient evidence against the null under the test assumptions. It does not prove that the population slopes are identical.
  • Omitting a group main effect while including a dose-by-group interaction. The group-specific lines generally need both an intercept difference and a slope difference. In the model used here, \(\beta_2\) allows the intercepts to differ, while \(\beta_3\) allows the slopes to differ.
  • Interpreting an extrapolated comparison as equally well supported. A fitted line can extend beyond observed doses, but predictions there require assumptions about how the relationship continues. Report the ranges and pay particular attention to their overlap.
  • Giving the slope the wrong units or a causal interpretation. Here a slope is measured in assay units per mg/day. The regression describes an association; a causal dose effect requires an appropriate study design and supporting assumptions.
Key takeaway: Fit one line per group, define the slope contrast in context, and test that contrast directly. Interpret the result alongside the fitted lines, model assumptions, and dose ranges represented in each group.

Check Your Understanding

Work through these questions using the definitions and calculations above.

  1. In the model \(Y_i=\beta_0+\beta_1x_i+\beta_2G_i+\beta_3x_iG_i+\varepsilon_i\), what are the Group A and Group B slopes, and what does \(\beta_3\) measure?
  2. Why does comparing whether each group’s slope is individually significant fail to test directly whether the slopes differ?
  3. If the residual sum of squares were 24 for these 10 observations, what would the pooled \(MSE\) be, using the same four fitted coefficients?
  4. For dose ranges 1–5 mg/day in Group A and 4–8 mg/day in Group B, calculate the shared range and identify where predictions for a between-group comparison would require extrapolation.
  5. State an appropriate contextual interpretation of the estimated slope difference of 1 assay unit per mg/day without making a causal claim.