Tutorials › Regression Analysis (Undergraduate) › Plotting Treatment Effects Across Baseline Values

Regression in Randomized Studies · Tutorial 911 of 991

Plotting Treatment Effects Across Baseline Values

Build an interaction-model plot that shows fitted treatment outcomes, uncertainty in their contrasts, and where the data do not support a comparison.

Intermediate 10 min read

What You'll Learn

  • Write fitted outcome equations for treatment and control from a treatment-by-baseline interaction model.
  • Calculate the fitted treatment contrast at a specified baseline value.
  • Use the coefficient covariance matrix to find a contrast standard error and confidence interval.
  • Plot fitted outcomes and pointwise contrast intervals without confusing them with intervals for each outcome.
  • Identify predictions outside the observed baseline range for one or both treatment groups.

Why Plot Treatment Effects Across Baseline Values?

A single treatment-effect estimate summarizes a trial, but it can hide how the estimated treatment contrast varies with a participant’s baseline value. A plot makes that pattern visible: it can show fitted outcomes for each treatment, the estimated contrast at different baseline values, and how uncertain those contrasts are. It can also reveal where a model is being asked to predict for baseline values poorly represented in one treatment group.

The plot is based on a regression model, not on separate estimates calculated within many small baseline subgroups. The model describes fitted mean outcomes as functions of baseline and treatment. If the model includes a treatment-by-baseline interaction, its estimated treatment contrast can change with baseline; it changes when the estimated interaction coefficient is nonzero. If that coefficient is zero, the fitted contrast is constant across baseline values.

Model and Assumptions

Let \(Y_i\) be the outcome for participant \(i\), \(T_i=1\) indicate assignment to treatment, and \(T_i=0\) indicate assignment to control. Let \(X_i\) be the participant’s baseline measurement, with a reference value \(x_{\text{ref}}\), and define \(Z_i=X_i-x_{\text{ref}}\). A linear interaction model is

$$ Y_i=\beta_0+\beta_1 Z_i+\beta_2 T_i+\beta_3(T_i Z_i)+\varepsilon_i. $$

Here \(\beta_0\) is the fitted control mean at the reference baseline, \(\beta_1\) is the control-group baseline slope, \(\beta_2\) is the treatment contrast at the reference baseline, and \(\beta_3\) is the difference between the treatment and control baseline slopes. The fitted model uses estimates \(\hat{\beta}_0,\hat{\beta}_1,\hat{\beta}_2,\hat{\beta}_3\).

Definition: At baseline value \(x\), the fitted control outcome is \(\hat{Y}_0(x)=\hat{\beta}_0+\hat{\beta}_1(x-x_{\text{ref}})\). The fitted treatment outcome is \(\hat{Y}_1(x)=\hat{\beta}_0+\hat{\beta}_1(x-x_{\text{ref}})+\hat{\beta}_2+\hat{\beta}_3(x-x_{\text{ref}})\). Their fitted treatment contrast is \(\hat{\Delta}(x)=\hat{Y}_1(x)-\hat{Y}_0(x)=\hat{\beta}_2+\hat{\beta}_3(x-x_{\text{ref}})\).

Before using the model for intervals, its assumptions and scope need to be clear. The conditional mean must be represented adequately by the chosen baseline terms and interaction over the range being interpreted. The errors are assumed independent across participants, with mean zero and a common variance; normal errors give the usual exact \(t\)-based inference in this linear model. Baseline must be measured before treatment assignment, and treatment assignment should be analyzed as randomized. Randomization supports a causal interpretation of assignment contrasts in the trial, but it does not ensure that the chosen regression mean function is adequate or that predictions outside the data are reliable.

A plot should therefore show where the baseline data actually lie in each treatment group. A fitted value can be computed by extending a line beyond observed values, but that arithmetic does not make the prediction data-supported. In particular, a treatment contrast at a baseline value requires fitted outcomes for both groups. When one group has little or no baseline data there, that contrast relies substantially on extrapolation.

From the Model to the Plot

The two fitted outcome lines are useful for displaying the model, but the vertical difference between them is the treatment contrast of interest. A clear graph has baseline value on the horizontal axis and outcome on the vertical axis, with separate fitted lines for treatment and control. A second display, or a lower panel with its own vertical axis, can show the contrast \(\hat{\Delta}(x)\) and its pointwise confidence interval. This avoids relying on the visual overlap of separate outcome intervals to judge the uncertainty of their difference.

At a baseline value \(x\), the estimated contrast is a linear combination of two estimated coefficients. Its standard error depends on their variances and their covariance:

$$ SE\{\hat{\Delta}(x)\} = \sqrt{\operatorname{Var}(\hat{\beta}_2) +(x-x_{\text{ref}})^2\operatorname{Var}(\hat{\beta}_3) +2(x-x_{\text{ref}})\operatorname{Cov}(\hat{\beta}_2,\hat{\beta}_3)}. $$

Under the stated model assumptions, a pointwise \(100(1-\alpha)\%\) confidence interval is

$$ \hat{\Delta}(x)\ \pm\ t_{1-\alpha/2,df}\,SE\{\hat{\Delta}(x)\}. $$

Here \(df\) is the residual degrees of freedom and \(t_{1-\alpha/2,df}\) is the corresponding \(t\) critical value. “Pointwise” means that the interval is constructed for the contrast at that specified baseline value. A collection of such intervals across many baseline values is not automatically a simultaneous confidence band for the entire contrast curve.

Worked Example: Plotting the Two Fitted Outcome Lines

Suppose a hypothetical randomized trial measures a follow-up score in points and a baseline score in points. The model is centered at \(x_{\text{ref}}=50\) baseline points. Assume the fitted coefficients are \(\hat{\beta}_0=24\), \(\hat{\beta}_1=0.40\), \(\hat{\beta}_2=3.0\), and \(\hat{\beta}_3=-0.12\). For illustration, suppose baseline scores are observed from 40 to 60 points in both groups, and the linear interaction model is considered reasonable over that range.

The fitted control line is \(\hat{Y}_0(x)=24+0.40(x-50)\), and the fitted treatment line is \(\hat{Y}_1(x)=24+0.40(x-50)+3.0-0.12(x-50)\). The contrast is \(\hat{\Delta}(x)=3.0-0.12(x-50)\), in follow-up score points.

At a baseline score of 40, \(x-50=-10\). The fitted control outcome is \(24+0.40(-10)=20\) points. The fitted treatment outcome is \(24+0.40(-10)+3.0-0.12(-10)=24.2\) points. Their difference is \(24.2-20=4.2\) points, which also equals \(3.0-0.12(-10)=4.2\).

At 50 baseline points, the fitted control outcome is 24 points and the treatment outcome is \(24+3.0=27\) points; the contrast is 3.0 points. At 60 baseline points, the fitted control outcome is \(24+0.40(10)=28\) points and treatment outcome is \(28+3.0-1.2=29.8\) points; the contrast is 1.8 points. Thus, over these example values, the fitted contrast declines as baseline increases because \(\hat{\beta}_3=-0.12\) points of contrast per baseline point. A graph would show the two fitted lines and the corresponding contrast line or contrast panel across the observed range.

Calculating and Displaying Contrast Uncertainty

The formula for the standard error follows from the variance rule for a linear combination. Write \(z=x-x_{\text{ref}}\). The estimated contrast is \(\hat{\beta}_2+z\hat{\beta}_3\). For any two random quantities \(A\) and \(B\), \(\operatorname{Var}(A+B)=\operatorname{Var}(A)+\operatorname{Var}(B)+2\operatorname{Cov}(A,B)\). Since \(z\) is fixed at the baseline value being plotted, \(\operatorname{Var}(z\hat{\beta}_3)=z^2\operatorname{Var}(\hat{\beta}_3)\) and \(\operatorname{Cov}(\hat{\beta}_2,z\hat{\beta}_3)=z\operatorname{Cov}(\hat{\beta}_2,\hat{\beta}_3)\). Substitution gives the variance formula above; taking its square root gives the standard error. The covariance term matters because coefficient estimates from the same fitted model are generally not independent.

Worked Example: A Pointwise Interval for the Treatment Contrast

Continue with the fitted coefficients in the previous example. Suppose the estimated coefficient variances and covariance are \(\operatorname{Var}(\hat{\beta}_2)=1.44\), \(\operatorname{Var}(\hat{\beta}_3)=0.0064\), and \(\operatorname{Cov}(\hat{\beta}_2,\hat{\beta}_3)=-0.040\). Suppose also that \(df=36\), so the 95% critical value is approximately \(t_{0.975,36}=2.028\). These are hypothetical model results, and the pointwise intervals use the model assumptions stated earlier.

At \(x=60\), \(z=10\), and the estimated contrast is \(3.0-0.12(10)=1.8\) points. Its variance is

$$ 1.44+10^2(0.0064)+2(10)(-0.040) =1.44+0.64-0.80=1.28. $$

Thus, its standard error is \(\sqrt{1.28}=1.131\) points. The 95% interval is \(1.8\pm2.028(1.131)=1.8\pm2.294\), or approximately \((-0.494,\ 4.094)\) points. In context, this is a pointwise 95% confidence interval for the mean follow-up score contrast between assignment to treatment and assignment to control at a baseline score of 60. It includes zero; the data and model do not rule out either a small negative contrast or a positive one at this baseline value.

At the reference baseline of 50, \(z=0\), so the contrast is 3.0 points and its standard error is \(\sqrt{1.44}=1.20\) points. The interval is \(3.0\pm2.028(1.20)=3.0\pm2.434\), or approximately \((0.566,\ 5.434)\) points. This interval is wider than a point estimate alone suggests, and it is different from the interval at 60 because the contrast estimate and its uncertainty depend on baseline.

Showing Where Predictions Are Supported

A plot can display model predictions at any baseline value, but the observed baseline distributions determine where those predictions are well supported by data. It is useful to mark the observed range for each treatment group, for example with a rug of baseline observations along the horizontal axis or with labeled ranges. The shared range is especially important for a treatment contrast: both fitted group means contribute to the contrast, so a comparison outside one group’s observed range requires extending that group’s fitted relationship.

The shared range is not a guarantee of strong information at every point. A few observations near an endpoint, a large gap in the data, or substantial imbalance in local density can still make a fitted contrast uncertain or model-dependent. Show the pointwise intervals and describe sparse regions rather than suggesting that a range boundary alone establishes adequate support.

Worked Example: Marking an Unsupported Part of the Plot

Suppose the hypothetical trial above has control baseline scores from 42 to 68 points and treatment baseline scores from 48 to 72 points. The full observed range is 42 to 72, while the shared observed range is 48 to 68. Assume observations are sparse near the endpoints. The fitted model can still calculate both lines from 42 through 72, but that does not mean both lines are equally supported throughout.

At 42 points, only the control group has observed baseline values in this range. The model can calculate a treatment fitted outcome there, but it extends the treatment-group relationship below its observed minimum of 48. Consequently, the fitted contrast at 42 relies on extrapolating the treatment line. At 72 points, the reverse applies: the control prediction extends beyond its observed maximum of 68, so the contrast again relies on extrapolation.

A careful graph could show fitted outcomes from 42 to 72 while using a different line style or shaded background outside 48 to 68, and clearly label those portions as outside the shared observed range. The contrast panel should likewise distinguish the 48–68 shared range from 42–48 and 68–72, where at least one group’s fitted outcome is extrapolated. The intervals do not remove this limitation: an interval summarizes model-based sampling uncertainty under the specified model, but cannot make unsupported extrapolation empirically supported.

Practical Plotting Steps

1
Specify the fitted model.
State the baseline terms, treatment coding, reference baseline, and treatment-by-baseline interaction. Confirm that the baseline values being plotted are within the range for which the model is intended.
2
Calculate fitted outcomes.
For each chosen baseline value, substitute \(T=0\) and \(T=1\) into the fitted equation to obtain the control and treatment fitted means.
3
Calculate the contrast and interval.
Subtract the fitted control mean from the fitted treatment mean, then use the coefficient covariance matrix to calculate the contrast standard error and pointwise interval.
4
Show the observed support.
Mark each group’s baseline data or range. Identify regions where either fitted outcome, and therefore the contrast, relies on extrapolation or sparse observations.
5
Label the display in context.
Name the outcome and its units, the baseline measure and units, the treatment contrast direction, and whether intervals are pointwise confidence intervals.

Common Plotting Mistakes

  • Assuming any interaction makes the fitted contrast change. An interaction allows the contrast to depend on baseline, but the estimated contrast changes only if \(\hat{\beta}_3\ne0\). If \(\hat{\beta}_3=0\), the fitted lines are parallel and the fitted contrast is constant.
  • Using overlap of separate outcome intervals as the contrast interval. The uncertainty in a difference depends on the covariance between fitted quantities. Calculate the contrast standard error directly from the coefficient covariance matrix.
  • Calling a calculated prediction “supported” because it appears on the graph. A model can produce predictions beyond a group’s observed baseline range. Mark such extrapolation rather than presenting it as if that group supplied data there.
  • Interpreting a collection of pointwise intervals as a 95% band for the entire curve. Each interval has its stated pointwise coverage at one baseline value; simultaneous coverage across a curve requires a different procedure.
  • Describing the fitted contrast as the effect for every individual. It is a model-based contrast in mean outcomes at a specified baseline value, not a prediction of an individual participant’s treatment response.
Key takeaway: Plot fitted outcomes by treatment, but calculate and display uncertainty for their contrast directly. Make the observed baseline support visible, because a precise-looking fitted line cannot compensate for a comparison that depends on extrapolation.

Check Your Understanding

Use the model definitions and plotting principles above to answer these questions.

  1. In the interaction model, what is the fitted treatment contrast at baseline \(x\), and which coefficient determines whether that contrast changes with \(x\)?
  2. Why does the standard error of a treatment contrast include the covariance between \(\hat{\beta}_2\) and \(\hat{\beta}_3\)?
  3. What does a pointwise 95% confidence interval describe, and why is a set of such intervals not automatically a 95% confidence band for the whole curve?
  4. If treatment participants have baseline values from 48 to 72 and control participants from 42 to 68, which baseline interval is shared by both groups? What is the concern about contrasts outside it?
  5. Why is it incorrect to conclude that the estimated contrast must change with baseline merely because the fitted model contains an interaction term?