Tutorials › Marginal Structural Models › Treatment-Covariate Interactions In Q Models

Dynamic Treatment Regimes · Tutorial 412 of 501

Treatment-Covariate Interactions In Q Models

Learn how to specify treatment-covariate interactions in a Q-model, interpret their fitted values, and translate them into decisions that depend on observed history.

Advanced 12 min read

What You'll Learn

  • Write Q-models that allow treatment effects to vary with covariates in the observed history.
  • Interpret interaction coefficients through fitted Q-values rather than in isolation.
  • Derive treatment choices at particular histories by comparing predicted Q-values.
  • Understand how centering and coding change coefficients without changing fitted decisions.
  • Check the assumptions and diagnostics that support causal interpretation of interaction-based decisions.

Why Interactions Matter in a Q-Model

A treatment that improves average outcomes can still be a poor choice for some histories and a good choice for others. A Q-model can represent this heterogeneity by allowing the predicted outcome under treatment to depend on covariates measured before treatment. The central task is not merely to include a treatment indicator, but to let the treatment contrast change with history when the scientific setting supports it.

Focus on a terminal treatment decision. Let \(H\) denote the observed history just before treatment \(A\), and let \(Y\) be the subsequent outcome, with larger values preferred. The terminal-stage Q-function is the conditional mean outcome given history and treatment. Treatment-covariate interactions extend its model so that two histories can have different predicted advantages for treatment.

Definition: A treatment-covariate interaction in a Q-model is a model term that combines treatment \(A\) with a function of pre-treatment history \(H\), such as \(A X\). It allows the fitted conditional mean \(Q(h,a)\) to vary with \(a\) differently at different histories \(h\). A treatment main effect alone imposes a constant treatment contrast on the model’s chosen scale.

For causal interpretation, assume consistency, conditional exchangeability \(Y^a \perp A \mid H\), and positivity: each treatment being compared has positive probability at histories in the target population. Under these conditions, \(E[Y^a\mid H=h]=E[Y\mid A=a,H=h]\) for histories where the conditional quantities are defined. A correctly specified Q-model for the observed conditional mean can therefore represent history-specific causal means. These assumptions do not follow from adding interaction terms; they are needed to interpret the fitted comparisons causally.

Binary Covariate: What the Interaction Coefficient Encodes

Suppose \(A\) and a covariate \(X\) are binary, coded as 0 and 1. The model below includes a treatment main effect and a treatment-by-covariate interaction:

$$ Q(x,a)=\beta_0+\beta_x x+\beta_a a+\beta_{ax}ax. $$

The interaction lets the treatment contrast differ between \(X=0\) and \(X=1\). The coefficient \(\beta_a\) is the contrast at the reference value \(X=0\), while \(\beta_{ax}\) is how much that contrast changes when \(X\) changes from 0 to 1. The interaction coefficient alone is not the treatment effect in either subgroup unless the other relevant terms are accounted for.

Derived result: In this model, the four fitted cell means are \(Q(0,0)=\beta_0\), \(Q(1,0)=\beta_0+\beta_x\), \(Q(0,1)=\beta_0+\beta_a\), and \(Q(1,1)=\beta_0+\beta_x+\beta_a+\beta_{ax}\). Thus the fitted treatment contrasts are \(\beta_a\) at \(X=0\) and \(\beta_a+\beta_{ax}\) at \(X=1\).

To verify the result, substitute each of the four possible \((x,a)\) pairs into the model. At \(X=0\), subtract the fitted value for \(A=0\) from that for \(A=1\): \((\beta_0+\beta_a)-\beta_0=\beta_a\). At \(X=1\), the same subtraction is \((\beta_0+\beta_x+\beta_a+\beta_{ax})-(\beta_0+\beta_x)=\beta_a+\beta_{ax}\). This also shows how a fully interacted model for binary \(A\) and \(X\) represents four cell means: its four coefficients can be recovered from those means by subtraction. The treatment contrast changes sign or magnitude across the two histories only if the corresponding fitted cell means support that conclusion. \(\square\)

Worked Example: Opposite Decisions in Two History Groups

Suppose the fitted Q-model is \(\hat Q(x,a)=10+2x+a-4ax\), where higher outcomes are preferred. Compute the fitted values and decisions for each value of \(X\).

For \(X=0\), the fitted values are \(\hat Q(0,0)=10\) and \(\hat Q(0,1)=10+1=11\). Treatment has the higher fitted outcome, so choose \(A=1\) for this history.

For \(X=1\), the fitted values are \(\hat Q(1,0)=10+2=12\) and \(\hat Q(1,1)=10+2+1-4=9\). The higher fitted outcome is now under \(A=0\), so choose \(A=0\) for this history.

The coefficients give the same check: at \(X=0\), the contrast is \(\hat\beta_a=1\); at \(X=1\), it is \(\hat\beta_a+\hat\beta_{ax}=1-4=-3\). The decisions differ because the interaction permits different fitted contrasts, not because the model makes a separate decision from each coefficient.

Continuous Covariates, Centering, and Decisions

For a continuous covariate \(Z\), a linear interaction model might be \(\hat Q(z,a)=\hat\beta_0+\hat\beta_z z+\hat\beta_a a+\hat\beta_{az}az\). The fitted treatment contrast then varies linearly with \(z\). This is a modeling assumption: it says the contrast changes at a constant rate on the scale of the conditional mean. It may be useful over a restricted range, but it should not be treated as a universal feature of the data.

Worked Example: A History Threshold From a Fitted Interaction

Consider \(\hat Q(z,a)=40-2z+4a+3az\), with higher outcomes preferred and \(A\in\{0,1\}\). At \(z=-2\), the predictions are \(\hat Q(-2,0)=40+4=44\) and \(\hat Q(-2,1)=40+4+4-6=42\); choose \(A=0\). At \(z=0\), the predictions are 40 and 44; choose \(A=1\).

To locate where the preferred action changes, compare the two predictions: \(\hat Q(z,1)-\hat Q(z,0)=4+3z\). They are equal when \(4+3z=0\), or \(z=-4/3\). For \(z>-4/3\), the difference is positive and the fitted model favors \(A=1\); for \(z<-4/3\), it favors \(A=0\). At exactly \(z=-4/3\), the fitted values tie. This threshold is a feature of this particular fitted model, not a general clinical cut-off.

Centering can make a main effect easier to interpret without changing fitted predictions. If \(W=Z-c\), then \(Z=W+c\). Substitution into the model gives

$$ \beta_0+\beta_z Z+\beta_a A+\beta_{az}AZ =(\beta_0+c\beta_z)+\beta_z W+(\beta_a+c\beta_{az})A+\beta_{az}AW. $$

The coefficients on the intercept and treatment term change, but the fitted value for every \((Z,A)\) stays the same because the equation is an identity. In the centered model, the treatment coefficient is the fitted contrast at \(Z=c\); in the original model, it is the contrast at \(Z=0\). Thus, interpreting a main effect without checking the covariate coding and reference value can be misleading.

Worked Example: Centering Changes Coefficients, Not Predictions

Write the previous model using \(W=Z-2\), so \(Z=W+2\). Substitution gives

$$ 40-2(W+2)+4A+3A(W+2)=36-2W+10A+3AW. $$

At \(Z=0\), \(W=-2\). The centered expression predicts \(36-2(-2)=40\) when \(A=0\), and \(36+4+10-6=44\) when \(A=1\), matching the original model. The treatment coefficient is now 10, the contrast at \(Z=2\); it is not the contrast at \(Z=0\). At \(Z=0\), the interaction contributes \(3(-2)=-6\), giving the same contrast \(10-6=4\) as before. The decision rule and predictions have not changed.

From Fitted Q-Values to a History-Specific Rule

For a terminal decision with two available actions, a fitted rule can be defined by choosing the action with the larger fitted Q-value at the observed history. The rule must be measurable in \(H\), so that it specifies an action from information available before treatment. More importantly, its optimality claim requires the fitted Q-function to represent the relevant conditional means; a convenient interaction model alone does not establish this.

Derived result: Suppose the action set is \(\{0,1\}\), the causal conditional means \(Q(h,a)=E[Y^a\mid H=h]\) are identified, and \(E[|Y^a|]\) is finite for both actions. Define \(d^*(h)\) to choose an action maximizing \(Q(h,a)\), with a fixed tie rule. Then \(d^*\) has value at least as large as any other measurable rule \(d\) in this action set.

To prove this, write the value of any rule \(d\) as \(V(d)=E[Y^{d(H)}]\). By consistency and conditional exchangeability, conditioning on \(H\) identifies the conditional mean outcome under the rule as \(Q(H,d(H))\); hence the law of iterated expectations gives \(V(d)=E[Q(H,d(H))]\). By definition of \(d^*\), for every history where the conditional means are defined, \(Q(H,d^*(H))\geq Q(H,d(H))\). Integrability permits taking expectations of both sides, yielding \(V(d^*)\geq V(d)\). The argument compares the true Q-values; when estimated Q-values are used, the resulting decision is a plug-in rule and need not be optimal if the model or estimates are inaccurate. \(\square\)

This result explains why interactions matter for decisions: a model that forces a constant contrast may choose the same action at every history, even when the true conditional means favor different actions. It does not imply that every fitted interaction is useful or causal. A decision based on a noisy, misspecified, or confounded fit can be worse than a simpler rule.

More Than Two History Groups

Interactions can also be constructed for a categorical history variable with several levels. For example, use indicator variables for the non-reference levels and interact each indicator with treatment. The resulting fitted treatment comparisons are allowed to differ across levels, while the reference group’s comparison is represented by the treatment main effect.

Worked Example: Three Categorical History Groups

Let \(X\) have levels 0, 1, and 2. Suppose the fitted model is \(\hat Q(x,a)=5+2I(x=1)-I(x=2)+a[-1+4I(x=1)+2I(x=2)]\), where \(I(\cdot)\) is 1 when its condition holds and 0 otherwise.

For \(X=0\), the control prediction is 5 and the treatment prediction is \(5-1=4\); choose \(A=0\). For \(X=1\), the control prediction is \(5+2=7\) and the treatment prediction is \(7-1+4=10\); choose \(A=1\). For \(X=2\), the control prediction is \(5-1=4\) and the treatment prediction is \(4-1+2=5\); choose \(A=1\). Each decision follows by comparing the two predicted values within that history group.

Diagnostics, Alternatives, and Limitations

A no-interaction model is a simpler alternative: it assumes that treatment has the same conditional mean contrast at every history on the modeled scale. A fully stratified approach estimates separate conditional means in each history group and can avoid imposing a linear interaction pattern, but may use information less efficiently and become unstable in small groups. A regression model with interactions shares information across histories according to its chosen functional form. These are modeling choices, not guarantees of causal validity.

Before using an interaction-based rule, check that treatment and covariate coding match the intended reference groups, and calculate fitted Q-values for plausible histories rather than interpreting coefficients in isolation. Examine whether the model’s predicted outcomes are plausible across the observed covariate range, whether important history groups have sparse treatment data, and whether the fitted contrast changes in a way supported by the data. Extrapolated thresholds, extreme predictions, and large changes driven by a few observations are warnings. Lack of treatment overlap at some histories undermines the comparison there; adding an interaction cannot create information where a treatment is absent.

The rule is also limited by the chosen outcome scale, functional form, and available history variables. Linear interactions impose a specific pattern of change, and omitted effect modifiers or nonlinear relationships may not be represented. As in the introductory material on Q-functions and optimal actions, the decision is defined by comparing conditional values; here the important extra caution is that those values depend on a fitted model. Estimating a flexible model does not remove the need for identification assumptions, adequate data, and careful assessment of predictions.

Common pitfall: It is incorrect to read \(\hat\beta_a\) as the treatment contrast for every patient when the model includes \(A\)-by-covariate interactions. In the binary-\(X\) model, it is the contrast at \(X=0\); at \(X=1\), the contrast is \(\hat\beta_a+\hat\beta_{ax}\). The correction is to compute and compare the fitted Q-values at the history of interest, using the actual coding and all relevant model terms.

Check Your Understanding

Answer each question by calculating the relevant fitted values or contrast.

  1. For \(\hat Q(x,a)=7+3x-2a+5ax\), calculate the treatment contrast at \(x=0\) and \(x=1\), and state the preferred action at each history.
  2. In a model with \(Z\) centered at \(c\), what history-specific contrast does the treatment main-effect coefficient represent?
  3. Give one reason why an interaction model may yield unreliable decisions even when its fitted values can be calculated.
  4. For \(\hat Q(z,a)=12+z+a(2-z)\), compare fitted outcomes at \(z=0\) and \(z=3\), and state the preferred action at each.

Solutions. 1. At \(x=0\), the contrast is \(-2\), so choose \(A=0\). At \(x=1\), it is \(-2+5=3\), so choose \(A=1\). 2. It is the fitted treatment contrast at \(Z=c\), because the centered covariate equals zero there. 3. For example, treatment overlap may be poor in a history group, so its treatment comparison is weakly supported; alternatively, the interaction form may be misspecified. 4. At \(z=0\), the predictions are 12 for \(A=0\) and 14 for \(A=1\), so choose \(A=1\). At \(z=3\), they are 15 for \(A=0\) and \(15+(2-3)=14\) for \(A=1\), so choose \(A=0\).

Clinical Biostats