Tutorials › Marginal Structural Models › Treatment-By-Time Interactions in Marginal Structural Models

Inverse Probability of Treatment Weights · Tutorial 92 of 501

Treatment-By-Time Interactions in Marginal Structural Models

Learn to specify, interpret, compare, and diagnose time-varying covariate effects in pooled logistic models for inverse probability of treatment weights.

Advanced 12 min read

What You'll Learn

  • Write a pooled logistic treatment model with time-specific intercepts and predictor-by-time interactions.
  • Interpret each time-specific covariate odds ratio and compare it across follow-up times.
  • Recover interaction coefficients from time-specific treatment probabilities.
  • Calculate how fitted interaction models change treatment probabilities and weights.
  • Compare common-slope, interacted, and separate-time treatment models.
  • Diagnose poor fit and recognize when interactions cannot solve positivity problems.

Why Let Predictor Associations Change Over Time?

In a pooled logistic treatment model, one row represents one person at one treatment decision time. A time-specific intercept allows the overall treatment probability to differ across follow-up. It does not, by itself, allow a covariate’s association with treatment to change. For example, a prior health measure might strongly predict treatment early in follow-up but be weakly associated with treatment later. A model that forces one common covariate slope can miss that pattern.

This tutorial concerns interactions between time and predictors in the treatment-assignment model used to estimate inverse probability of treatment weights. These are not interactions between treatment and time in an outcome model: they describe how predictors are associated with the probability of receiving treatment at different times. The introductory material on pooled logistic models supplies the basic long-format setup; here the focus is how to represent and interpret changing predictor associations.

Model and Interpretation

Let \(A_{it}\) be the binary treatment for person \(i\) at decision time \(t\), where \(t=0,\ldots,K\). Let \(R_{it}\) be a \(q\)-dimensional vector of predictors measured before that decision. It may contain baseline covariates and appropriately timed past covariate or treatment history. Write \(p_{it}=P(A_{it}=1\mid R_{it},\text{other included past information})\). A time-factor model with time-specific intercepts and predictor-by-time interactions is

$$ \operatorname{logit}(p_{it}) = \alpha_t+\beta^{T}R_{it} +\sum_{s=1}^{K}I(t=s)\,\delta_s^{T}R_{it}. $$

Here \(t=0\) is the reference time, \(I(t=s)\) equals one when \(t=s\) and zero otherwise, and \(\delta_s\) is a vector of interaction coefficients. For a predictor component \(R_{it,j}\), its log-odds coefficient at time zero is \(\beta_j\); at time \(s>0\), it is \(\beta_j+\delta_{s,j}\). Thus the interaction coefficient is the change in that predictor’s log-odds association from the reference time to time \(s\).

Definition: A predictor-by-time interaction in a pooled logistic treatment model allows the coefficient of a treatment predictor to differ by follow-up time. With categorical time and time zero as reference, \(\delta_{s,j}\) is the difference between the log-odds coefficient for predictor \(j\) at time \(s\) and its coefficient at time zero. The corresponding odds ratio at time \(s\) is \(\exp(\beta_j+\delta_{s,j})\), holding the other included predictors fixed.

The model’s time-specific intercept \(\alpha_t\) is the log odds of treatment at time \(t\) when all components of \(R_{it}\) are zero. The zero value must be meaningful or created by centering for that interpretation to be useful. The interactions do not change the meaning of the time-specific intercept under this reference coding, because the interaction terms vanish at \(R_{it}=0\).

Worked Example: Interpreting a Changing Odds Ratio

Suppose \(X_i\) is a binary baseline predictor and treatment is modeled at two times, \(t=0,1\):

$$ \operatorname{logit}(p_{it}) = \alpha_t+0.8X_i-1.1I(t=1)X_i, \qquad \alpha_0=-1,\quad \alpha_1=-0.5. $$

At time zero, the coefficient of \(X_i\) is \(0.8\). The odds ratio comparing \(X_i=1\) with \(X_i=0\) is \(\exp(0.8)\approx2.226\). At time one, the coefficient is \(0.8-1.1=-0.3\), so the corresponding odds ratio is \(\exp(-0.3)\approx0.741\). The interaction is negative because the association weakens and changes direction on the log-odds scale.

The treatment probabilities make the distinction clear. At time zero, the logits for \(X=0\) and \(X=1\) are \(-1\) and \(-1+0.8=-0.2\), giving probabilities \(0.269\) and \(0.450\). At time one, the logits are \(-0.5\) and \(-0.5-0.3=-0.8\), giving probabilities \(0.378\) and \(0.310\). The odds ratios are comparisons within each time; they are not differences in probability, which also depend on the intercept and baseline probability.

Deriving the Time-Specific Effect

The odds-ratio interpretation follows directly from the model. Consider two predictor vectors that differ only by one unit in component \(j\). At time \(t\), their linear predictors differ by \(\beta_j\) if \(t=0\), and by \(\beta_j+\delta_{t,j}\) if \(t>0\). Since logistic regression defines the log odds as the linear predictor, exponentiating this difference gives the odds ratio.

Result: Under the stated model, the odds ratio for a one-unit increase in predictor \(j\), at time \(t\) holding other predictors fixed, is \(\exp(\beta_j)\) for \(t=0\) and \(\exp(\beta_j+\delta_{t,j})\) for \(t>0\). The ratio of the time-\(t\) odds ratio to the time-zero odds ratio is \(\exp(\delta_{t,j})\).

To verify the final comparison, divide the time-\(t\) odds ratio by the time-zero odds ratio:

$$ \frac{\exp(\beta_j+\delta_{t,j})}{\exp(\beta_j)} = \exp(\delta_{t,j}). $$

This derivation assumes the specified logistic model and the same predictor contrast at each time. It does not claim that the probability difference is constant over time. A zero interaction means equal conditional odds ratios across the two times, not equal probabilities or equal risk differences. For several times, the common-slope restriction is \(H_0:\delta_1=\cdots=\delta_K=0\). A joint test of this restriction evaluates whether the included predictors need time-varying log-odds coefficients under the chosen model.

Worked Example: Recovering an Interaction From Probabilities

Suppose time-specific treatment probabilities for a binary predictor \(X\) are as follows:

Time\(P(A=1\mid X=0)\)\(P(A=1\mid X=1)\)
00.200.50
10.400.40

At time zero, the odds for \(X=0\) are \(0.20/0.80=0.25\), and the odds for \(X=1\) are \(0.50/0.50=1\). The odds ratio is \(1/0.25=4\), so the time-zero coefficient is \(\beta=\log(4)\approx1.3863\). The time-zero intercept is \(\alpha_0=\operatorname{logit}(0.20)=\log(0.20/0.80)\approx-1.3863\).

At time one, the odds are \(0.40/0.60=2/3\) for both predictor values. The time-one odds ratio is therefore \(1\), and its log coefficient is zero. In the interaction model, that coefficient is \(\beta+\delta_1\), so \(\delta_1=0-\log(4)\approx-1.3863\). The time-one intercept is \(\alpha_1=\operatorname{logit}(0.40)=\log(2/3)\approx-0.4055\). Thus the fitted form is \(\operatorname{logit}(p)=\alpha_t+\log(4)X-\log(4)I(t=1)X\). Substitution gives the four stated probabilities.

Likelihood and Estimation in Long Format

For independent people, the pooled model is fit using the Bernoulli likelihood for each observed treatment decision, conditional on the included pre-decision information. Dependence between a person’s repeated decisions is represented by conditioning on the relevant past; it is not necessary to assume that the decisions within a person are marginally independent.

Result: If people are independent and each row uses a correctly specified conditional Bernoulli model with probability \(p_{it}\), the conditional likelihood for the observed treatment records is the product of their sequential conditional probabilities. Its log-likelihood is the sum of the usual Bernoulli logistic log-likelihood contributions.

For one person, the chain rule for conditional probabilities gives the probability of the observed treatment sequence as the product over decision times of the probability of each observed \(A_{it}\), conditional on the information available at that time. The Bernoulli contribution is \(p_{it}^{A_{it}}(1-p_{it})^{1-A_{it}}\). Multiplying across times and then across independent people gives

$$ L = \prod_{i=1}^{n}\prod_{t=0}^{K} p_{it}^{A_{it}}(1-p_{it})^{1-A_{it}}, \qquad \ell = \sum_{i=1}^{n}\sum_{t=0}^{K} \left\{A_{it}\log(p_{it})+(1-A_{it})\log(1-p_{it})\right\}. $$

Substituting the interaction model’s linear predictor into \(p_{it}\) gives the pooled logistic likelihood to maximize. The rows are not treated as if each person were a new independent person: the likelihood contribution for a person is the product of sequential conditional contributions. If uncertainty estimates require accounting for within-person dependence beyond this correctly specified sequential likelihood, the variance method must reflect the study’s sampling and model structure.

Worked Example: Calculating a Treatment-Weight Contribution

Use the model from the first example for a person with \(X=1\) at both times and observed treatments \(A_0=1\), \(A_1=0\). At time zero the fitted probability is \(\operatorname{expit}(-0.2)\approx0.450166\). At time one it is \(\operatorname{expit}(-0.8)\approx0.310026\), so the probability of the observed untreated decision at time one is \(1-0.310026=0.689974\).

The denominator-model probability of this observed treatment sequence is

$$ 0.450166\times0.689974\approx0.310603. $$

The unstabilized inverse probability contribution is therefore \(1/0.310603\approx3.2196\). For illustration, suppose a numerator model assigns treatment probabilities \(0.30\) at time zero and \(0.60\) at time one, without conditioning on \(X\). The numerator probability of the observed sequence is \(0.30(1-0.60)=0.12\), so the stabilized contribution is \(0.12/0.310603\approx0.3863\). The interaction changes the denominator probabilities through the time-specific association with \(X\); it does not change the definition of the weight. This calculation presumes the specified numerator scheme and is not a recommendation to use these particular probabilities.

Choosing and Checking the Interaction Structure

With categorical time, including all predictor-by-time terms allows each included predictor to have a separate log-odds coefficient at each time. A common-slope model omits these terms and imposes \(\delta_t=0\). Fitting separate logistic regressions at each time can give the same time-specific coefficients as a fully interacted pooled model when the same observations and predictors are used and each time-specific model is fit independently. The pooled parameterization is convenient for expressing restrictions and comparing models; it does not create information where a time-specific predictor pattern is unsupported.

A numeric-time interaction, such as a predictor multiplied by \(t\), is a different restriction: it assumes the predictor coefficient follows a specified trend with time. That can be more parsimonious, but it is not equivalent to allowing an unrestricted coefficient at every time. The time coding should match the scientific and data-supported pattern. The next step beyond this tutorial’s scope is to model nonlinear covariate effects; adding time interactions does not itself address nonlinear functional forms.

Useful diagnostics include comparing observed treatment proportions with fitted probabilities across time and across important predictor strata, checking whether the fitted covariate associations vary in the expected direction, and inspecting the resulting weights for extreme values. A model may fit overall while badly underpredicting treatment in a small but important stratum. Such discrepancies can indicate omitted interactions, an unsuitable time specification, incorrect covariate timing, or sparse data. Interaction estimates with large standard errors or very large weights are warnings that the data may not support the requested complexity.

The main limitation is that additional interactions use additional parameters. With many predictors and follow-up times, a fully interacted model can be unstable, especially when treatment is rare in some strata. Conversely, omitting interactions can misrepresent treatment probabilities if associations truly change. Neither choice repairs a structural positivity failure: if some histories have no chance of one treatment option, a more flexible logistic model cannot manufacture the missing support. For a causal interpretation of weighted analyses, the usual consistency, sequential exchangeability, and positivity conditions are also needed; good fit of the treatment model alone does not establish them.

Common Mistakes

  • Confusing time intercepts with time-varying slopes. Separate intercepts let treatment prevalence change by time, but the predictor associations remain common unless interactions are included.
  • Reading an interaction as a probability difference. In this logistic model, an interaction changes a log-odds coefficient. The probability change depends on the other predictors and the time-specific intercept.
  • Interpreting \(\delta_t\) as the full time-\(t\) effect. With reference-time coding, the time-\(t\) coefficient is \(\beta+\delta_t\), not \(\delta_t\) alone.
  • Assuming extra flexibility guarantees good weights. Interactions can improve conditional probability modeling, but they can also make estimates unstable and cannot resolve a lack of treatment overlap.
Key takeaway: Add predictor-by-time terms when the conditional association between a pre-decision predictor and treatment plausibly changes over follow-up. Interpret the sum of the main and interaction coefficients at each time, then assess fit, support, and weight behavior rather than treating a more flexible model as automatically adequate.

Check Your Understanding

Answer each question, then check the worked solutions below.

  1. In a two-time model, what is the coefficient of \(X\) at time one if its main coefficient is \(0.5\) and its time-one interaction is \(-0.2\)? What is the corresponding odds ratio?
  2. If a time-one interaction coefficient is zero, what equality does that impose, and what does it not imply about treatment probabilities?
  3. Why do time-specific intercepts alone not allow the association of a covariate with treatment to vary over time?
  4. Name two diagnostics that can reveal problems in an interacted treatment model, and one problem that adding interactions cannot solve.

Solutions. (1) The time-one coefficient is \(0.5-0.2=0.3\), and the odds ratio is \(\exp(0.3)\approx1.350\). (2) It makes the time-one and reference-time log-odds coefficients equal, so their conditional odds ratios are equal. It does not make probabilities equal, because intercepts and other predictors can differ. (3) Intercepts change the linear predictor’s value at the reference predictor vector, while the common coefficient of the covariate remains unchanged; a slope interaction is needed to change that association. (4) Examples include comparing observed and fitted treatment frequencies by time and predictor strata, and inspecting estimated weights for extreme values. Interactions cannot solve structural positivity failure, such as a treatment option never occurring for a relevant history.

Clinical Biostats