Tutorials › Causal Inference › Continuous Effect Modifiers and Functional Form

Effect Modification and Subgroup Effects · Tutorial 861 of 972

Continuous Effect Modifiers and Functional Form

Model and compare conditional treatment effects across a continuous covariate using linear, transformed, and spline-based forms.

Advanced 10 min read

What You'll Learn

  • Define a conditional treatment effect for a continuous modifier.
  • Derive the treatment-effect function from a linear interaction model.
  • Use transformations and spline bases to represent nonlinear effect variation.
  • Calculate conditional effects at specified covariate values.
  • Compare functional forms while respecting the observed covariate range.

Why Functional Form Matters

A treatment effect may vary gradually across a continuous characteristic such as age, baseline severity, or a laboratory measurement. The analysis must represent that variation in a way that is interpretable and supported by the data. Treating every value as a separate subgroup discards the ordering and spacing of the covariate; assuming one straight-line trend can also be misleading if the true pattern bends or changes slope.

The functional form is the mathematical shape used to describe how the conditional treatment effect changes with the modifier. A linear interaction gives a straight-line pattern. Transformations can describe curved patterns, while splines allow a curve to change shape across ranges of the modifier. These choices affect the estimated effect at each value, even when the same outcome and treatment data are analyzed.

Definition: Let \(A\) be a binary treatment, \(Y(1)\) and \(Y(0)\) the potential outcomes under treatment and control, and \(W\) a continuous effect modifier. The conditional average treatment effect at \(W=w\) is $$ \tau(w)=E[Y(1)-Y(0)\mid W=w]. $$ It is an average causal contrast among individuals with modifier value \(w\), on the outcome scale used to define \(Y\).

This tutorial focuses on how to model \(\tau(w)\), not on deciding whether any observed variation is statistically significant. The effect scale matters: for example, a difference in mean outcome and a difference in outcome risk are distinct estimands. A model coefficient is not automatically the conditional effect on the scale of interest, especially when the outcome model uses a nonlinear link.

From an Outcome Model to a Treatment-Effect Function

A common starting point is a model for the conditional mean outcome given treatment, modifier, and any adjustment covariates \(Z\). For example, suppose the outcome is continuous and the conditional mean is modeled as

$$ E[Y\mid A,W,Z]=\beta_0+\beta_A A+\beta_W W+\beta_{AW}AW+\gamma^\mathsf{T}Z. $$

Here treatment is coded \(A=1\) for treatment and \(A=0\) for control. Subtracting the model prediction under control from the prediction under treatment at the same values of \(W\) and \(Z\) gives

$$ \widehat{E[Y\mid A=1,W=w,Z]}-\widehat{E[Y\mid A=0,W=w,Z]} =\beta_A+\beta_{AW}w. $$

The main effect \(\beta_W W\) describes how the outcome mean changes with \(W\) in the control group under this model. The product term \(AW\) allows the treatment contrast to change with \(W\). A model containing \(W\) but not \(AW\) does not, by itself, allow treatment effects to vary with \(W\).

Model interpretation: In the linear interaction model, \(\beta_A\) is the modeled treatment contrast at \(W=0\), and \(\beta_{AW}\) is the change in that contrast for a one-unit increase in \(W\). If \(W=0\) is not substantively useful, centering \(W\) makes the treatment main effect refer to the contrast at the centering value.

The model-to-effect calculation is straightforward, but a causal interpretation requires assumptions. Consistency means that the observed outcome equals the potential outcome under the treatment actually received. Conditional exchangeability requires \(Y(a)\) to be independent of treatment assignment given the variables used for adjustment, for each treatment level \(a\). Positivity requires a positive probability of receiving either treatment at covariate values relevant to the target population. In addition, the conditional mean model must adequately represent the outcome means needed for the contrast. In a randomized study, treatment assignment can support exchangeability by design; the functional form and support requirements still matter.

When adjustment covariates are present, the model-based contrast at \(w\) may depend on \(Z\). To estimate a conditional effect for the population with \(W=w\), predict each treatment outcome for those individuals under both treatment values and average the differences over their covariate distribution:

$$ \tau(w)=E_Z\{E[Y\mid A=1,W=w,Z]-E[Y\mid A=0,W=w,Z]\mid W=w\}. $$

This is a conditional version of marginal standardization. It makes clear that the target is a contrast in predicted outcomes on the chosen outcome scale, not necessarily an individual-level effect or a regression coefficient.

Linear, Transformed, and Spline Forms

A linear treatment-effect function is compact and easy to communicate, but it imposes a constant rate of change in the effect over the modeled range. A transformed modifier can represent curvature. For example, defining \(U=(W-c)/s\), where \(c\) is a reference value and \(s\) is a scale factor, a quadratic effect function is

$$ \tau(w)=\beta_A+\theta_1 u+\theta_2 u^2,\qquad u=(w-c)/s. $$

The treatment-effect curve is curved when \(\theta_2\ne 0\). Centering and scaling can make coefficients easier to interpret and can improve numerical stability, but they do not change the fitted predictions if the model is otherwise equivalent.

A spline represents a curve using basis functions that are linear or polynomial pieces joined at selected knots. A simple piecewise-linear treatment-effect function with a knot at \(k\) is

$$ \tau(w)=\beta_A+\theta_1 w+\theta_2(w-k)_+,\qquad (w-k)_+=\max(0,w-k). $$

This curve is continuous at \(k\). Its slope is \(\theta_1\) below the knot and \(\theta_1+\theta_2\) above it. More flexible spline bases can use multiple knots and higher-degree pieces, while constraints ensure the pieces join smoothly. Flexibility comes at a cost: estimates can be less precise in sparse regions, and a complex curve can follow random noise.

Worked Example: A Linear Effect Trend

Suppose a hypothetical randomized study compares a treatment with control for a continuous symptom-improvement outcome measured in points. Baseline severity \(W\) ranges from 0 to 10, and larger values indicate more severe symptoms. A fitted linear interaction model, with severity centered at 5, is

$$ \widehat{E[Y\mid A,W]}=6.0+1.10A+0.30(W-5)-0.08A(W-5). $$

Assume treatment was randomized, both treatment arms include participants across the severity range being interpreted, and the linear conditional-mean model is a reasonable approximation over that range. The modeled treatment effect at severity \(w\) is the treated prediction minus the control prediction:

$$ \widehat{\tau}(w)=1.10-0.08(w-5). $$

At severity 5, the estimated contrast is \(1.10-0.08(5-5)=1.10\) points. At severity 8, it is \(1.10-0.08(8-5)=1.10-0.24=0.860\) points. Thus, under this model, the estimated treatment benefit is 0.240 points smaller at severity 8 than at severity 5. The interaction coefficient is measured in outcome points per one severity point; it is not itself the treatment effect at every severity value.

Worked Example: A Quadratic Effect Pattern

In a second hypothetical randomized study, the outcome is reduction in systolic blood pressure, measured in mmHg, and age is considered as a continuous modifier. Let \(U=(W-50)/10\), so one unit of \(U\) represents ten years of age. Suppose the fitted treatment-effect function is

$$ \widehat{\tau}(w)=2.00+0.40u-0.20u^2,\qquad u=(w-50)/10. $$

Assume the model includes adequate terms for the baseline outcome pattern, participants in both arms cover the ages at which predictions are requested, and randomization supports treatment exchangeability. At age 40, \(u=-1\), giving \(2.00+0.40(-1)-0.20(-1)^2=2.00-0.40-0.20=1.40\) mmHg. At age 50, \(u=0\), giving \(2.00\) mmHg. At age 60, \(u=1\), giving \(2.00+0.40-0.20=2.20\) mmHg. At age 70, \(u=2\), giving \(2.00+0.80-0.80=2.00\) mmHg.

The estimated effect rises and then falls over these ages, unlike a straight-line trend. These calculations describe fitted conditional mean contrasts, not known effects for particular individuals. They also do not establish that the curve is preferable: that judgment requires examining the data support, uncertainty, and the plausibility of the model over the target range.

Worked Example: A Piecewise-Linear Effect With a Knot

Consider a hypothetical randomized study of a treatment intended to increase symptom-free days. The continuous modifier \(W\) is a baseline biomarker measured from 0 to 12 units. Suppose a piecewise-linear model with a knot at 6 units gives

$$ \widehat{\tau}(w)=1.00+0.20w-0.30(w-6)_+. $$

Assume both treatment arms have observations on both sides of the knot, and the outcome model is adequate for estimating the conditional means. At \(w=4\), the positive-part term is zero, so the estimated contrast is \(1.00+0.20(4)=1.80\) symptom-free days. At \(w=6\), it is \(1.00+0.20(6)-0.30(0)=2.20\) days. At \(w=10\), it is \(1.00+0.20(10)-0.30(10-6)=1.00+2.00-1.20=1.80\) days.

Below the knot, the estimated slope of the treatment effect is \(0.20\) days per biomarker unit. Above the knot, the slope is \(0.20-0.30=-0.10\) days per unit. The curve remains continuous at 6, but its slope changes there. This model can describe a rise followed by a decline without forcing the same straight-line trend across the entire biomarker range.

Justification: Why the Interaction Determines the Effect Curve

The treatment-effect expression follows by taking a contrast at the same modifier and adjustment-covariate values. For the linear model, set \(A=1\), then set \(A=0\), and subtract:

$$ \begin{aligned} m(1,w,z)-m(0,w,z) &=(\beta_0+\beta_A+\beta_Ww+\beta_{AW}w+\gamma^\mathsf{T}z)\\ &\quad-(\beta_0+\beta_Ww+\gamma^\mathsf{T}z)\\ &=\beta_A+\beta_{AW}w. \end{aligned} $$

Terms that do not involve treatment cancel. More generally, if the model contains \(A\) multiplied by a set of basis functions \(B_k(W)\), the fitted contrast is

$$ \widehat{\tau}(w)=\widehat{\beta}_A+\sum_{k=1}^{K}\widehat{\theta}_k B_k(w). $$

This is why a flexible baseline outcome curve alone cannot describe treatment-effect variation: only terms whose contribution changes with treatment remain in the contrast. For a nonlinear link, subtraction on the link scale instead gives a contrast on that link scale. To report effects such as a risk difference, calculate predicted outcome risks under each treatment and subtract them on the risk scale, often averaging those predictions over the target covariate distribution.

Choosing and Assessing a Functional Form

Functional-form choices should be guided by the scientific question and the observed covariate distribution, not by an effort to make every possible curve fit. A linear interaction is a useful starting point when a constant rate of change is plausible. A transformation or spline may be appropriate when there is a substantive reason to expect curvature or a change in slope. Knots, transformations, and the range over which effects will be reported should be specified with care.

Compare candidate forms by plotting their estimated conditional effects over the region where data provide support. Include uncertainty when available, inspect whether the curve is driven by a few observations or by extrapolation, and consider whether the implied pattern is clinically plausible. The treatment-effect curve should be assessed separately from the baseline outcome curve: both may need flexible terms, but they answer different modeling questions. A more flexible fit is not automatically more credible, and differences between fitted curves do not alone demonstrate causal heterogeneity.

Common Mistakes

  • Assuming a continuous modifier has a linear effect on treatment benefit. A straight line is an assumption about the effect curve, not a consequence of measuring \(W\) numerically. Consider transformations or splines when justified, and assess support and plausibility.
  • Including a modifier but no treatment-by-modifier terms. A model with only a main effect for \(W\) permits the outcome to vary with \(W\), but it imposes a constant treatment contrast on the model's linear scale.
  • Interpreting a nonlinear-model coefficient as a risk difference. In a model with a link function, first obtain predicted outcomes under both treatment values and calculate the contrast on the target outcome scale.
  • Reporting estimates far outside the observed range. A fitted line or spline can produce numerical predictions where there are few or no comparable treated and control observations. Such extrapolations rely heavily on the assumed form and may not be reliable.
Key takeaway: A continuous effect modifier requires an explicit model for how the treatment contrast changes with its value. Derive the contrast from the fitted outcome model, calculate it on the desired causal scale, and interpret it only where the data and assumptions support it.

Check Your Understanding

Use these questions to check your understanding of continuous modifiers and functional form.

  1. In a linear model with terms \(A\), \(W\), and \(AW\), which terms remain in the modeled treatment contrast, and what does the coefficient of \(AW\) represent?
  2. For a quadratic treatment-effect function, what does the squared modifier term allow the fitted curve to represent that a linear interaction cannot?
  3. In a piecewise-linear spline with one knot, how do the slope and continuity of the treatment-effect curve behave at the knot?
  4. Why is a modifier main effect without treatment-by-modifier terms insufficient for modeling variation in the treatment contrast?
  5. Why should conditional-effect predictions be treated cautiously at modifier values outside the observed data range?
Clinical Biostats