Tutorials › Marginal Structural Models › Baseline Versus Time-Varying Confounding

Causal Diagrams for Longitudinal Data · Tutorial 74 of 501

Baseline Versus Time-Varying Confounding

Learn to distinguish baseline confounding from time-varying confounding affected by prior treatment, and to see why the distinction changes what covariate adjustment can estimate.

Intermediate 11 min read

What You'll Learn

  • Identify the open backdoor path created by a baseline common cause of treatment and outcome.
  • State the assumptions and positivity condition for baseline standardization.
  • Recognize a later covariate that confounds subsequent treatment and is itself affected by earlier treatment.
  • Calculate how crude and covariate-adjusted contrasts can differ from causal regime effects.
  • Explain why ordinary adjustment for a post-treatment covariate may block part of a total effect.
  • Diagnose when baseline-only adjustment is insufficient and when overlap is absent.

Why the Timing of a Confounder Matters

A covariate measured before treatment and one measured between treatment occasions can both be associated with treatment and outcome, but they do not play interchangeable roles. A baseline common cause can create an open backdoor path from treatment to outcome. A later covariate can create such a path for a subsequent treatment while also being caused by an earlier treatment. In that second structure, adjusting for the covariate may address confounding of the later treatment but also block part of the earlier treatment's effect.

Use \(B\) for baseline covariates, \(A_0\) for an earlier treatment, \(L_1\) for a covariate measured after \(A_0\) and before a later treatment, \(A_1\) for that later treatment, and \(Y\) for the outcome. The subscripts indicate time order, not repeated measurements of one undifferentiated variable.

Definition: A confounder for a specified treatment-outcome relation is an observed covariate whose causal role creates an open noncausal path between that treatment and outcome, so that a valid adjustment set must block the path without opening other paths. A variable's mere presence on a noncausal path does not make it a confounder: for example, conditioning on a collider can open a path. A baseline confounder is measured before the treatment of interest. A time-varying confounder affected by prior treatment is measured after an earlier treatment and before a later one, confounds the later treatment-outcome relation, and is causally affected by that earlier treatment.

Baseline Confounding and Standardization

The basic baseline pattern is \(A_0 \leftarrow B \rightarrow Y\), possibly alongside a causal arrow \(A_0 \rightarrow Y\). The path through \(B\) is a backdoor path: treatment groups can differ in prognosis because they differ in \(B\). If, conditional on \(B\), there are no remaining open noncausal paths from \(A_0\) to \(Y\), adjusting for \(B\) can identify the mean outcome under a specified treatment value.

Result (baseline standardization): Let \(Y(a)\) be the potential outcome under treatment \(a\). Suppose consistency holds, \(Y=Y(A_0)\); conditional exchangeability holds, \(Y(a)\perp A_0\mid B\); and \(Y(a)\) is integrable. Also suppose \(P(A_0=a\mid B)>0\) almost surely under the target distribution of \(B\). Then $$ E[Y(a)] = E\{E[Y\mid A_0=a,B]\}. $$ For discrete \(B\), this is \(\sum_b E[Y\mid A_0=a,B=b]P(B=b)\). For continuous or mixed \(B\), the outer expectation is taken over its target distribution.

The positivity condition is deliberately stated almost surely, not only for values with positive point mass. That distinction matters for continuous \(B\): a continuous covariate typically has no individual value with positive point mass, yet treatment probabilities must still be positive almost everywhere in the covariate distribution being averaged over.

1
Replace the potential-outcome mean by a conditional mean.
By exchangeability, \(E[Y(a)\mid B]=E[Y(a)\mid A_0=a,B]\) wherever the conditional treatment probability is positive.
2
Use consistency.
Among units with \(A_0=a\), consistency gives \(Y=Y(a)\). Thus \(E[Y(a)\mid A_0=a,B]=E[Y\mid A_0=a,B]\).
3
Average over the target covariate distribution.
The law of iterated expectations gives \(E[Y(a)]=E\{E[Y\mid A_0=a,B]\}\). Positivity ensures that this conditional outcome mean is identified almost surely on the distribution over which it is averaged.

Together, these equalities prove the result under the stated conditions. In a DAG, the baseline-common-cause pattern can support the exchangeability condition when the measured \(B\) blocks all relevant backdoor paths and the graph's causal assumptions are correct. A diagram alone does not establish that the covariates were measured correctly or that the assumed causal structure is true. \(\square\)

Worked Example: Standardizing Over a Baseline Prognostic Factor

Let \(B\) be binary with \(P(B=1)=0.5\). Treatment is more common for \(B=1\): \(P(A_0=1\mid B=1)=0.8\) and \(P(A_0=1\mid B=0)=0.2\). Suppose the conditional outcome risks under treatment \(a\) are \(E[Y(a)\mid B=b]=0.1+0.4a+0.2b\). These risks are \(0.1,0.3,0.5,0.7\) for \((a,b)=(0,0),(0,1),(1,0),(1,1)\), respectively.

Standardize the treated risk over the baseline population: \(E[Y(1)]=0.5(0.5)+0.5(0.7)=0.60\). The untreated risk is \(E[Y(0)]=0.5(0.1)+0.5(0.3)=0.20\). The standardized risk difference is \(0.60-0.20=0.40\).

The crude contrast is different. The treatment prevalence is \(P(A_0=1)=0.5(0.8)+0.5(0.2)=0.5\), so \(P(B=1\mid A_0=1)=0.4/0.5=0.8\). Similarly, \(P(B=1\mid A_0=0)=0.1/0.5=0.2\). Assuming consistency and conditional exchangeability, \(Y(a)\perp A_0\mid B\), the observed risks are therefore \(E[Y\mid A_0=1]=0.1+0.4+0.2(0.8)=0.66\) and \(E[Y\mid A_0=0]=0.1+0.2(0.2)=0.14\). The crude difference, \(0.52\), is not the standardized causal difference. Both treatment probabilities, \(0.2\) and \(0.8\), are positive in each baseline stratum, so there is no exact positivity failure in this example.

When Earlier Treatment Changes a Later Confounder

A longitudinal pattern can include \(A_0\rightarrow L_1\), \(L_1\rightarrow A_1\), and \(L_1\rightarrow Y\), as well as \(A_0\rightarrow A_1\), \(A_0\rightarrow Y\), and \(A_1\rightarrow Y\). Here \(L_1\) is a common cause of later treatment and outcome, but its distribution has already been affected by earlier treatment. For the \(A_1\)-outcome relation, a path such as \(A_1\leftarrow L_1\rightarrow Y\) is noncausal. Yet adjusting for \(L_1\) in an analysis of \(A_0\) can block the causal path \(A_0\rightarrow L_1\rightarrow Y\).

This creates two distinct questions. To estimate the effect of \(A_1\), one must address confounding by the history available before \(A_1\), including \(L_1\). To estimate the total effect of \(A_0\), one must retain causal pathways through \(L_1\) and possibly through later treatment decisions. A single ordinary regression adjustment does not automatically answer both questions. The structure is the reason longitudinal g-methods, including the g-formula and marginal structural models, are used; their estimation procedures are beyond this comparison.

Worked Example: A Covariate That Confounds Later Treatment

Consider this binary data-generating structure. \(A_0\) is randomized with probability \(0.5\). Conditional on \(A_0=0\), \(P(L_1=1)=0.2\); conditional on \(A_0=1\), \(P(L_1=1)=0.8\). Given \(L_1\), \(P(A_1=1\mid L_1=1)=0.8\) and \(P(A_1=1\mid L_1=0)=0.2\). The outcome risk is \(E[Y\mid A_0,L_1,A_1]=0.1+0.2A_0+0.3L_1+0.3A_1\). All possible risks lie between \(0.1\) and \(0.9\).

First calculate the crude association between \(A_1\) and \(Y\). The joint probability \(P(A_0=1,L_1=1,A_1=1)\) is \(0.5(0.8)(0.8)=0.32\), and \(P(A_0=1,L_1=0,A_1=1)=0.5(0.2)(0.2)=0.02\). Hence \(P(A_0=1\mid A_1=1)=(0.32+0.02)/0.5=0.68\). Also \(P(L_1=1\mid A_1=1)=0.4/0.5=0.8\). Thus \(E[Y\mid A_1=1]=0.1+0.2(0.68)+0.3(0.8)+0.3=0.776\).

For \(A_1=0\), the corresponding joint probabilities with \(A_0=1,L_1=1\) and \(A_0=1,L_1=0\) are \(0.5(0.8)(0.2)=0.08\) and \(0.5(0.2)(0.8)=0.08\). Therefore \(P(A_0=1\mid A_1=0)=0.16/0.5=0.32\), and \(P(L_1=1\mid A_1=0)=0.1/0.5=0.2\). It follows that \(E[Y\mid A_1=0]=0.1+0.2(0.32)+0.3(0.2)=0.224\). The crude difference is \(0.776-0.224=0.552\).

Under intervention to set \(A_1=1\) rather than \(A_1=0\), while leaving the distribution of prior history as generated, the risk increases by exactly \(0.3\) at every value of \((A_0,L_1)\). The causal risk difference is therefore \(0.3\), not \(0.492\). The difference arises because the observed \(A_1\) groups have different distributions of \(L_1\) and \(A_0\). In this specified model, conditioning on both \(A_0\) and \(L_1\) makes the conditional \(A_1\) risk difference \(0.3\), since the outcome formula has an \(A_1\) coefficient of \(0.3\). This conditional comparison concerns the later treatment; it does not mean that conditioning on \(L_1\) is appropriate for every earlier-treatment estimand.

Why Adjustment Can Change the Earlier-Treatment Effect

The contrast is particularly clear in an additive model. Suppose \(A\) is an earlier treatment, \(L\) is a later covariate, and structural equations are \(L=\alpha_0+\alpha_A A+u\) and \(Y=\beta_0+\beta_A A+\beta_L L+\varepsilon\). Assume \(E[u\mid A]=0\), \(E[\varepsilon\mid A,L]=0\), finite expectations, and that these equations remain valid under interventions on \(A\). Assume also no treatment-by-\(L\) interaction in the outcome equation.

Result (total and conditional effects in the additive model): Under the assumptions above, the total mean effect of setting \(A\) from 0 to 1 is \(\beta_A+\beta_L\alpha_A\). The conditional mean contrast at a fixed value of \(L\) is \(\beta_A\). Thus ordinary adjustment for \(L\) need not estimate the total effect.

To derive the total effect, under intervention \(A=a\), the first equation gives \(E[L\mid do(A=a)]=\alpha_0+\alpha_Aa\), because \(E[u\mid A]=0\) and the intervention leaves the structural error distribution unchanged. Substitution into the outcome equation and use of \(E[\varepsilon\mid A,L]=0\) yield \(E[Y\mid do(A=a)]=\beta_0+\beta_Aa+\beta_L(\alpha_0+\alpha_Aa)\). Subtracting the value at \(a=0\) from the value at \(a=1\) gives \(\beta_A+\beta_L\alpha_A\). At a fixed \(L=l\), the conditional mean is \(\beta_0+\beta_Aa+\beta_Ll\), so its contrast between \(a=1\) and \(a=0\) is \(\beta_A\). The term \(\beta_L\alpha_A\), which represents the path through \(L\) in this model, is absent from that fixed-\(L\) contrast. \(\square\)

Worked Example: The Effect Removed by Conditioning

Let \(L=0.2+0.6A+u\) and \(Y=0.1+0.2A+0.4L+\varepsilon\), with the zero-conditional-mean errors specified above. The total mean effect is \(\beta_A+\beta_L\alpha_A=0.2+(0.4)(0.6)=0.44\). Directly, under \(A=1\), the mean of \(L\) is \(0.8\) and the mean outcome is \(0.1+0.2+0.4(0.8)=0.62\). Under \(A=0\), the mean of \(L\) is \(0.2\) and the mean outcome is \(0.1+0.4(0.2)=0.18\). Their difference is \(0.62-0.18=0.44\). Holding \(L\) fixed instead gives a contrast of \(0.2\), the direct coefficient \(\beta_A\); the difference \(0.24\) is the contribution through \(L\) in this model.

Diagnostics, Alternatives, and Limits

Before adjustment, write down when each covariate is measured and which treatment it could precede. Then inspect the DAG for the relevant backdoor paths. A baseline-only adjustment set is inadequate if a later treatment still has an open path through \(L_1\). Conversely, adding every measured covariate is not a safe rule: conditioning on a collider can open a path, and conditioning on a mediator can remove part of a total effect. These are causal-structure questions, not decisions that can be settled by a regression fit statistic.

Check support separately at each treatment time. For baseline standardization, the conditional probability of the treatment value must be positive almost surely over the baseline distribution being targeted. In a longitudinal setting, histories must likewise have support for the treatment decisions under comparison. Empty or nearly empty history-treatment groups signal exact or near positivity problems; estimates then depend on extrapolation or become unstable. Observed data cannot by themselves verify exchangeability or prove that the DAG includes every relevant cause.

Structure and targetWhat adjustment must addressKey caution
Baseline common cause; effect of \(A_0\)Block relevant baseline backdoor paths, for example by valid standardization over \(B\)Require conditional exchangeability and positivity on the target support
\(L_1\) confounds the effect of \(A_1\)Account for the pre-\(A_1\) history, including \(L_1\)\(L_1\) may itself have been caused by \(A_0\)
Total effect of \(A_0\) with \(A_0\rightarrow L_1\)Retain pathways through \(L_1\) and subsequent treatmentOrdinary adjustment for \(L_1\) can block causal pathways

Baseline standardization is a suitable alternative when measured baseline covariates suffice for exchangeability and positivity holds. A randomized treatment assignment provides a reference case in which assignment is independent of baseline prognosis by design, though adherence and later treatment decisions can still require separate analysis. When a time-varying confounder is affected by prior treatment, longitudinal g-methods are alternatives designed for this feedback structure; no method repairs unmeasured confounding, misspecified causal structure, or absent support automatically.

Common Mistake

Wrong reasoning: “\(L_1\) predicts both \(A_1\) and \(Y\), so I should include it in every treatment-outcome regression; that adjustment removes bias without changing the target.” The first clause can be true for the \(A_1\)-outcome relation, but the conclusion does not follow. If \(A_0\rightarrow L_1\rightarrow Y\), conditioning on \(L_1\) blocks a causal path for the total effect of \(A_0\). Moreover, merely appearing on a noncausal path does not make a variable a confounder: a collider can be made problematic by conditioning on it. Specify the treatment, outcome, estimand, and path before choosing an adjustment set.

Key takeaway: A baseline confounder can often be handled by standardizing over a valid baseline adjustment set. A time-varying covariate affected by earlier treatment can be both a confounder for later treatment and part of the earlier treatment's causal pathway. Its role depends on which treatment effect is being estimated.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. In the graph \(A_0\leftarrow B\rightarrow Y\), why can comparing treated and untreated outcomes without accounting for \(B\) be misleading?
  2. State the positivity condition needed to standardize over a continuous baseline covariate.
  3. Suppose \(A_0\rightarrow L_1\), \(L_1\rightarrow A_1\), and \(L_1\rightarrow Y\). Which treatment-outcome relation does \(L_1\) confound, and which earlier-treatment path can adjustment for \(L_1\) block?
  4. In the additive model, let \(\alpha_A=0.5\), \(\beta_A=0.3\), and \(\beta_L=0.4\). Calculate the total effect and the fixed-\(L\) contrast.
  5. Why is “adjust for every variable on a noncausal path” not a valid general rule?

Solutions. (1) \(B\) is a common cause, so the treatment groups can differ in baseline prognosis; the path \(A_0\leftarrow B\rightarrow Y\) remains open unless validly blocked. (2) Require \(P(A_0=a\mid B)>0\) almost surely under the target distribution of \(B\). (3) \(L_1\) confounds the \(A_1\)-to-\(Y\) relation; adjustment can block the earlier causal path \(A_0\rightarrow L_1\rightarrow Y\). (4) The total effect is \(0.3+(0.4)(0.5)=0.5\); the fixed-\(L\) contrast is \(0.3\). (5) A variable on a path may be a collider, and conditioning on it can open rather than block a noncausal path. The adjustment set must be chosen for the specified estimand and DAG.

Clinical Biostats