Tutorials › Regression Analysis (Undergraduate) › Calculating Conditional Treatment Effects

Regression in Randomized Studies · Tutorial 907 of 991

Calculating Conditional Treatment Effects

Use the treatment coefficient and the interaction coefficient together to calculate and interpret fitted treatment contrasts at specific baseline values.

Intermediate 9 min read

What You'll Learn

  • Identify the treatment and treatment-by-baseline terms in an interaction model.
  • Derive the fitted treatment contrast at a fixed baseline value.
  • Substitute baseline values into the contrast formula and check the arithmetic.
  • Interpret the contrast’s direction and size in the outcome’s units.
  • Recognize why a conditional fitted contrast is not, by itself, evidence of a treatment effect in a subgroup.

Why Calculate a Contrast at a Particular Baseline Value?

When the fitted relationship between a baseline outcome and a follow-up outcome differs by assigned treatment, a single treatment coefficient does not describe the fitted treatment contrast at every baseline value. The product term in an interaction model makes the contrast depend on the baseline value. To answer a question such as “What contrast does the model fit for participants whose baseline score is 20 points?”, we must combine the treatment coefficient with the product-term coefficient.

This calculation describes a comparison between the fitted outcomes under treatment and control for the same baseline value. It is a model-based conditional contrast; it is not an individual participant’s treatment effect. The assignment of treatment in a randomized study gives the comparison its study context, but the calculation itself is an algebraic consequence of the specified model.

The Interaction Model and Its Conditional Contrast

Let \(D\) denote randomized treatment assignment, coded \(D=1\) for treatment and \(D=0\) for control. Let \(X\) be a baseline variable measured before assignment, and let \(Y\) be the outcome. Consider the fitted linear interaction model

$$ \widehat{Y}=\hat{\beta}_0+\hat{\beta}_1D+\hat{\beta}_2X+\hat{\beta}_3(DX). $$

Here, \(\widehat{Y}\) is the fitted outcome, \(\hat{\beta}_0\) is the fitted intercept, \(\hat{\beta}_2\) is the baseline slope in the control group, and \(\hat{\beta}_3\) is the change in that slope for the treatment group relative to control. The treatment coefficient \(\hat{\beta}_1\) is the fitted treatment-versus-control contrast specifically when \(X=0\).

Definition: At baseline value \(x\), the fitted conditional treatment contrast is the fitted outcome for \(D=1\) minus the fitted outcome for \(D=0\), with \(X\) held at \(x\). In this interaction model, it equals \(\hat{\beta}_1+\hat{\beta}_3x\).

To calculate the contrast, substitute \(D=1\) and \(D=0\) into the model separately, using the same baseline value \(x\). Subtract the control fitted outcome from the treatment fitted outcome:

$$ \begin{aligned} \widehat{Y}(D=1,X=x)&=\hat{\beta}_0+\hat{\beta}_1+\hat{\beta}_2x+\hat{\beta}_3x,\\ \widehat{Y}(D=0,X=x)&=\hat{\beta}_0+\hat{\beta}_2x,\\ \widehat{\Delta}(x) &=\widehat{Y}(D=1,X=x)-\widehat{Y}(D=0,X=x)\\ &=\hat{\beta}_1+\hat{\beta}_3x. \end{aligned} $$

The intercept and the baseline main-effect term cancel because both fitted outcomes are evaluated at the same \(x\). The treatment main effect does not cancel: it is present for \(D=1\) and absent for \(D=0\). The product term also contributes for treatment, since \(D X=x\) when \(D=1\), but is zero under control.

What the Calculation Requires

Before using the formula, check that the model and the comparison match the question. The fitted contrast above applies when treatment is coded 1 and control 0, the baseline value is \(x\), and the model includes both the treatment main effect and the treatment-by-baseline product term. Changing the coding or omitting a term changes the calculation.

For the result to be a useful description of fitted conditional means, the model should represent the mean outcome reasonably well over the baseline values being considered. In particular, this model specifies a linear change in the treatment contrast with \(X\). The baseline variable must be measured before treatment assignment for it to serve as a baseline value in this randomized-study comparison. There should also be observations from both assigned groups across the baseline region of interest; a calculated contrast far beyond the observed baseline values may be an extrapolation rather than a well-supported comparison.

These conditions concern the meaning and support of the fitted contrast. They do not make the calculation an inferential test: the formula gives a point estimate from fitted coefficients. Assessing uncertainty or testing whether the contrast differs from zero requires additional calculations.

Worked Example: A Contrast at a Baseline Score of 20

Suppose a hypothetical randomized study records a follow-up score \(Y\) in points and a baseline score \(X\) in points. The fitted model is

$$ \widehat{Y}=18-3D+0.60X+0.05(DX). $$

Both terms involving treatment are included: the treatment main effect is \(-3D\), and the product term is \(0.05(DX)\). Calculate the fitted treatment-versus-control contrast at \(X=20\).

Using the contrast formula. The treatment coefficient is \(\hat{\beta}_1=-3\), the product-term coefficient is \(\hat{\beta}_3=0.05\), and \(x=20\). Therefore,

$$ \widehat{\Delta}(20)=-3+0.05(20)=-3+1=-2\text{ points}. $$

Checking with the fitted outcomes. For control, \(D=0\), so

$$ \widehat{Y}(0,20)=18-3(0)+0.60(20)+0.05(0)(20)=30\text{ points}. $$

For treatment, \(D=1\), so

$$ \widehat{Y}(1,20)=18-3(1)+0.60(20)+0.05(1)(20)=18-3+12+1=28\text{ points}. $$

Subtracting gives \(28-30=-2\) points, in agreement with the formula. At a baseline score of 20, the model fits an outcome 2 points lower under treatment than under control. This is a comparison of fitted outcomes at that baseline value, not a claim about every individual with that score.

Reading the Contrast Across Baseline Values

The contrast formula can be applied separately at any selected baseline values. If \(\hat{\beta}_3\) is positive, the fitted treatment contrast increases as \(X\) increases; if it is negative, the contrast decreases as \(X\) increases. This describes the direction of change in the model’s fitted contrast. The value of the contrast at a particular \(x\) still depends on both \(\hat{\beta}_1\) and \(\hat{\beta}_3\).

Worked Example: Contrasts at Two Baseline Values

In a hypothetical randomized study, the outcome and baseline score are both measured in points. The fitted model is

$$ \widehat{Y}=5+4D+0.30X-0.08(DX). $$

Calculate the fitted treatment contrast when \(X=20\) and when \(X=40\). The model has a treatment coefficient of 4 points at \(X=0\), and a product-term coefficient of \(-0.08\) points per baseline point.

At \(X=20\), the conditional contrast is

$$ \widehat{\Delta}(20)=4-0.08(20)=4-1.6=2.4\text{ points}. $$

For a direct check, the fitted control outcome is \(5+0.30(20)=11\) points. The fitted treatment outcome is \(5+4+0.30(20)-0.08(20)=13.4\) points. Their difference is \(13.4-11=2.4\) points.

At \(X=40\), the contrast is

$$ \widehat{\Delta}(40)=4-0.08(40)=4-3.2=0.8\text{ points}. $$

The fitted control outcome is \(5+0.30(40)=17\) points, while the fitted treatment outcome is \(5+4+0.30(40)-0.08(40)=17.8\) points. Their difference is \(17.8-17=0.8\) points. The smaller contrast at \(X=40\) follows from the negative product-term coefficient; it does not mean the treatment coefficient itself changed.

The units provide a useful check. If \(Y\) is measured in points and \(X\) is measured in baseline points, then \(\hat{\beta}_1\) is in outcome points and \(\hat{\beta}_3\) is in outcome points per baseline point. Multiplying \(\hat{\beta}_3\) by \(x\) gives outcome points, so it can be added to \(\hat{\beta}_1\). A contrast should be reported in the units of \(Y\), not in the units of \(X\).

Worked Example: Interpreting the Sign of a Contrast

Suppose a hypothetical randomized study measures a symptom score, with lower scores indicating fewer symptoms. Its fitted model is

$$ \widehat{Y}=40-1.2D+0.20X+0.03(DX), $$

where both the baseline score \(X\) and the follow-up outcome \(Y\) are measured in symptom-score points. Find and interpret the fitted treatment contrast at baseline scores of 10 and 30.

At \(X=10\),

$$ \widehat{\Delta}(10)=-1.2+0.03(10)=-1.2+0.3=-0.9\text{ points}. $$

The fitted control outcome is \(40+0.20(10)=42\) points. The fitted treatment outcome is \(40-1.2+0.20(10)+0.03(10)=41.1\) points. Their difference is \(41.1-42=-0.9\) points. Thus, at a baseline score of 10, the fitted symptom score is 0.9 points lower under treatment than under control.

At \(X=30\),

$$ \widehat{\Delta}(30)=-1.2+0.03(30)=-1.2+0.9=-0.3\text{ points}. $$

The fitted control outcome is \(40+0.20(30)=46\) points, and the fitted treatment outcome is \(40-1.2+0.20(30)+0.03(30)=45.7\) points. Again, \(45.7-46=-0.3\) points. At this baseline value, the fitted outcome is 0.3 points lower under treatment. Because lower symptom scores are better in this example, both fitted contrasts favor treatment, but the contrast is closer to zero at \(X=30\). This calculation alone does not establish whether either contrast is distinguishable from zero with statistical uncertainty.

Common Mistake: Losing the Treatment Main Effect

A frequent error is to confuse a constant in the written model with the treatment coefficient. For instance, a model written as

$$ \widehat{Y}=18-3+0.60X+0.05(DX) $$

does not contain a treatment main-effect term. The \(-3\) is part of the intercept, not a term that switches on when \(D=1\). Since the only treatment-dependent term shown is \(0.05(DX)\), its treatment contrast at \(X=20\) is \(0.05(20)=1\) point, not \(-2\) points.

To represent a treatment coefficient of \(-3\), the model must include \(-3D\), as in \(\widehat{Y}=18-3D+0.60X+0.05(DX)\). Then the contrast at \(X=20\) is \(-3+0.05(20)=-2\) points. A reliable check is to substitute \(D=1\) and \(D=0\) into the entire model and subtract the fitted outcomes. This catches missing terms and sign errors.

Key takeaway: For a treatment indicator coded 0 for control and 1 for treatment, the fitted contrast at baseline value \(x\) is \(\hat{\beta}_1+\hat{\beta}_3x\). Keep the treatment main effect, multiply the product-term coefficient by the selected baseline value, and interpret the resulting difference in outcome units.

Check Your Understanding

For each question, use the treatment-minus-control contrast and show enough work to verify the result.

  1. A fitted model is \(\widehat{Y}=12+2D+0.5X-0.1(DX)\). What is the fitted treatment contrast at \(X=10\), in outcome units?
  2. For the same model, calculate the fitted control and treatment outcomes at \(X=10\). Do their difference and the contrast formula agree?
  3. If \(\hat{\beta}_1=-2\) and \(\hat{\beta}_3=0.04\), calculate the fitted contrast at \(X=25\). State what its sign means for treatment versus control.
  4. In the model \(\widehat{Y}=7-1.5D+0.2X+0.03(DX)\), identify the treatment coefficient and product-term coefficient. What is the fitted contrast at \(X=20\)?
  5. Explain why a calculated fitted contrast at a baseline value far beyond those observed in either randomized group may be unreliable, even when the arithmetic is correct.