Tutorials › Marginal Structural Models › Classifying Time-Varying Variables by Their Graphical Roles

Causal Diagrams for Longitudinal Data · Tutorial 68 of 501

Classifying Time-Varying Variables by Their Graphical Roles

Use a variable’s parents, children, and directed paths—together with its timing—to identify its role for a particular treatment-outcome question.

Intermediate 11 min read

What You'll Learn

  • Identify parents, children, and directed paths in a longitudinal DAG.
  • Distinguish a common-cause confounder pattern from an outcome-predicting arrow alone.
  • Recognize when a time-varying variable mediates an earlier treatment effect.
  • Identify collider structure without treating role labels as mutually exclusive.
  • Use temporal order to rule out impossible classifications for a specified treatment.
  • Check role assignments against explicit longitudinal models and probabilities.

Why a Variable’s Role Depends on the Question

A time-varying variable does not have one permanent graphical role. The same \(L_t\) may lie downstream of an earlier treatment, help determine a later treatment, and predict the outcome. Its classification therefore depends on which treatment and outcome are under discussion, as well as on the arrows in the DAG. This matters in longitudinal studies because a variable’s role for one treatment time can differ from its role for another.

Here \(A_t\) denotes treatment at time \(t\), \(L_t\) a time-varying covariate, and \(Y\) the outcome. Assume the graph is a directed acyclic graph (DAG) whose arrows respect the study timeline: a cause precedes its effect, and there are no directed cycles. The classification below is graphical. A role label alone does not establish that adjustment for a variable is appropriate or sufficient; formal path and adjustment criteria are a separate question.

Definition: A parent of a node \(X\) is a node with an arrow directly into \(X\); \(X\) is its child. An ancestor of \(X\) has a directed path to \(X\), and a descendant is reached from \(X\) by a directed path. For a specified treatment \(A_t\) and outcome \(Y\), a candidate confounder is a common cause of treatment and outcome, often represented by \(L_t\to A_t\) and \(L_t\to Y\). A mediator lies on a directed path from the treatment of interest to \(Y\). A collider is a node with two or more arrows pointing into it, such as \(A_t\to C\leftarrow U\). An outcome predictor has an arrow into \(Y\); that fact alone does not make it a confounder or mediator.

Reading the Arrows Before Applying a Label

Begin by naming the treatment time and outcome of interest. Then inspect the immediate arrows around each covariate and trace any relevant directed paths. Ask three distinct questions: does the variable help cause the specified treatment, does it lie downstream of that treatment on a path to the outcome, and does it receive arrows from multiple causes? These questions can have more than one “yes” answer for the same node.

Graphical role for a specified questionArrow or path pattern to look forWhat the pattern tells you
Candidate confounder\(L_t\to A_t\) and \(L_t\to Y\), or a broader common-cause pattern\(L_t\) is a cause of both the treatment and outcome under study.
MediatorA directed path \(A_s\to\cdots\to L_t\to\cdots\to Y\)Some effect of the specified earlier treatment can be transmitted through \(L_t\).
Collider\(X\to L_t\leftarrow Z\)\(L_t\) receives arrows from two causes. This classification concerns its incoming arrows.
Outcome predictor\(L_t\to Y\)\(L_t\) is a direct graphical cause of the outcome, whether or not it also has another role.

The table gives patterns, not an exhaustive test for whether an analysis is identified. In particular, “common cause” describes causal structure, not merely an observed association. Also, an outcome predictor can be a confounder if it also causes the treatment; it can be a mediator if it is downstream of the treatment being studied.

Worked Example: One Covariate, Two Treatment Times

Consider the arrows \(A_0\to L_1\), \(L_1\to A_1\), \(L_1\to Y\), \(A_0\to Y\), and \(A_1\to Y\). To make the structure concrete, let \(A_0\) be Bernoulli with probability \(0.5\), and specify

$$ P(L_1=1\mid A_0=1)=0.8,\qquad P(L_1=1\mid A_0=0)=0.2, $$

with \(P(A_1=1\mid L_1=1)=0.7\), \(P(A_1=1\mid L_1=0)=0.3\), and

$$ P(Y=1\mid A_0,L_1,A_1)=0.10+0.15A_0+0.20L_1+0.25A_1. $$

Every displayed outcome probability is between \(0.10\) and \(0.70\), so this is a valid binary-outcome model. The covariate distribution also checks the first arrow: \(L_1\) is more likely to equal one after \(A_0=1\) than after \(A_0=0\), with a difference \(0.8-0.2=0.6\). The assignment probabilities check \(L_1\to A_1\): they differ by \(0.7-0.3=0.4\). The positive coefficient \(0.20\) makes \(L_1\) an outcome predictor in this model.

For the contrast of \(A_1\) with \(Y\), \(L_1\) is a candidate confounder: \(L_1\to A_1\) and \(L_1\to Y\). For the contrast of \(A_0\) with \(Y\), it is a mediator on \(A_0\to L_1\to Y\). The same \(L_1\) therefore has two roles because the treatment under consideration changed. This is the graphical pattern behind treatment-confounder feedback: an earlier treatment affects a later covariate that, in turn, helps determine later treatment and outcome.

For a numerical check of the distribution, \(P(L_1=1)=0.5(0.8)+0.5(0.2)=0.5\). The model consequently gives \(P(A_1=1)=0.5(0.7)+0.5(0.3)=0.5\). These marginal probabilities do not remove the conditional differences that identify the arrows.

Two Consequences of Temporal Order

The timeline constrains which role a node can play. The following results use only the DAG’s temporal ordering and the definitions above; they do not provide a general criterion for which variables to adjust for.

Proposition: In a DAG that respects time, a covariate measured before \(A_t\) cannot be a mediator of the effect of \(A_t\) on \(Y\).

Proof. A mediator of \(A_t\) must lie on a directed path starting at \(A_t\) and ending at \(Y\). Every arrow along such a path points forward in the study timeline. A covariate measured before \(A_t\) cannot be reached by a path that starts at \(A_t\), because reaching it would require an arrow or a sequence of arrows pointing back to an earlier time. That contradicts the assumption that arrows respect the timeline. Thus the covariate cannot be a mediator of \(A_t\), although it could have another role, such as being a common cause of \(A_t\) and \(Y\). \(\square\)

Proposition: If \(A_{t-1}\to L_t\), \(L_t\to A_t\), and \(L_t\to Y\), then \(L_t\) is both a mediator for the \(A_{t-1}\)-to-\(Y\) question and a candidate confounder for the \(A_t\)-to-\(Y\) question.

Proof. For the earlier treatment, the arrows \(A_{t-1}\to L_t\) and \(L_t\to Y\) form the directed path \(A_{t-1}\to L_t\to Y\); by definition, \(L_t\) is a mediator on this path. For the later treatment, \(L_t\to A_t\) and \(L_t\to Y\) make \(L_t\) a common cause of \(A_t\) and \(Y\), matching the candidate-confounder pattern. The classifications use different treatment times, so neither contradicts the other. \(\square\)

Worked Example: Deriving a Mediated Component

Let \(A\) be randomized with \(P(A=1)=0.5\). A binary intermediate variable \(M\) satisfies \(P(M=1\mid A=1)=0.8\) and \(P(M=1\mid A=0)=0.2\). Suppose the outcome model is

$$ P(Y=1\mid A,M)=0.10+0.10A+0.40M. $$

The largest possible risk is \(0.10+0.10+0.40=0.60\), so the model gives valid probabilities. Its arrows are \(A\to M\), \(M\to Y\), and \(A\to Y\). Thus \(M\) is a mediator, and \(A\) also has a direct arrow to the outcome.

Under \(A=1\), average the outcome probability over the distribution of \(M\):

$$ P(Y=1\mid A=1) =0.8(0.10+0.10+0.40)+0.2(0.10+0.10) =0.8(0.60)+0.2(0.20)=0.52. $$

Under \(A=0\), the corresponding risk is

$$ P(Y=1\mid A=0) =0.2(0.10+0.40)+0.8(0.10) =0.2(0.50)+0.8(0.10)=0.18. $$

The total risk difference is \(0.52-0.18=0.34\). In this additive model, changing the distribution of \(M\) contributes \(0.40(0.8-0.2)=0.24\); the direct treatment term contributes \(0.10\), and \(0.24+0.10=0.34\). This calculation illustrates why “mediator” means a position on a directed causal path. It does not, by itself, prescribe an adjustment strategy.

Collider Structure and Outcome Prediction

A collider is recognized by arrows pointing into the node, not by whether the node predicts the outcome. For example, \(A_t\to C\leftarrow U\) makes \(C\) a collider even if \(C\to Y\) is also present. A covariate can therefore be both a collider and an outcome predictor. The incoming-arrow pattern distinguishes it from the common-cause pattern \(L_t\to A_t\) and \(L_t\to Y\).

Worked Example: Checking a Collider with Numbers

Let \(A\) and \(U\) be independent Bernoulli variables with probability \(0.5\) each. Suppose the collider \(C\) satisfies \(P(C=1\mid A,U)=0.10+0.30A+0.30U\). The four probabilities are \(0.10, 0.40, 0.40,\) and \(0.70\), all valid. The model has arrows \(A\to C\leftarrow U\).

The marginal probability of \(C=1\) is

$$ P(C=1)=\frac{0.10+0.40+0.40+0.70}{4}=0.40. $$

Also \(P(A=1,C=1)=0.5\{0.5(0.40)+0.5(0.70)\}=0.275\), so \(P(A=1\mid C=1)=0.275/0.40=0.6875\). By symmetry, \(P(U=1\mid C=1)=0.6875\). Their joint conditional probability is \(P(A=1,U=1\mid C=1)=0.25(0.70)/0.40=0.4375\). The product of the conditional marginals is \(0.6875^2=0.47265625\), which is not the joint probability. This verifies that conditioning on \(C\) changes the relationship between its causes in this example. The key classification remains structural: \(C\) is a collider because both arrows point into it. The broader consequences of conditioning on colliders require separate analysis.

Diagnostics, Alternatives, and Limits

When a classification seems unclear, audit the graph rather than relying on a variable’s name or measurement schedule. Write down the treatment time and outcome, check each direct parent and child, and trace only arrows that point forward in time. Then ask whether the node is a common cause, lies on a directed treatment-to-outcome path, receives multiple arrows, or simply has an arrow into the outcome. If the proposed role requires an arrow from a later node to an earlier one, the graph violates its stated temporal ordering.

A useful alternative is to classify by question rather than by variable. For each treatment time, make a separate record of the relevant arrows. This prevents the common mistake of calling a covariate “the confounder” without specifying which treatment it confounds. A timeline is useful for checking temporal order, while a DAG is needed to display the proposed causal relations; neither can establish the truth of an arrow from observational data alone.

These labels have limits. A drawn arrow represents a causal assumption, not a fact proved by the data. A variable can have several roles, and an “outcome predictor” label is especially broad: it says only that the graph includes an arrow into \(Y\). Nor does identifying a candidate confounder prove that measuring or adjusting for it resolves confounding. Determining which paths are open or blocked, and the consequences of conditioning on particular nodes, requires additional graphical criteria.

  • Wrong: “\(L_t\) is after baseline, so it must be a mediator.” Correction: It is a mediator only for a treatment that has a directed path through \(L_t\) to \(Y\); its role depends on the treatment time.
  • Wrong: “Every variable with an arrow into \(Y\) is a confounder.” Correction: An outcome arrow alone makes it an outcome predictor. A confounder pattern also requires a causal relation to the specified treatment.
  • Wrong: “A variable cannot be both mediator and confounder.” Correction: \(L_t\) can mediate an earlier treatment’s effect and be a candidate confounder for a later treatment.
  • Wrong: “A collider is just a variable associated with two other variables.” Correction: The defining feature is two or more arrows pointing into the node.

Check Your Understanding

Use the arrows and the specified treatment time to answer each question.

  1. In \(A_0\to L_1\to Y\), is \(L_1\) a mediator for the effect of \(A_0\) on \(Y\)?
  2. In \(L_1\to A_1\) and \(L_1\to Y\), what is \(L_1\)’s candidate role for the \(A_1\)-to-\(Y\) question?
  3. In \(A_1\to C\leftarrow U\), what arrow feature defines \(C\) as a collider?
  4. If \(L_1\to Y\) but there is no arrow or common-cause relation linking \(L_1\) to \(A_1\), what role is established by the displayed arrow alone?

Solutions. (1) Yes. \(L_1\) lies on the directed path \(A_0\to L_1\to Y\). (2) It is a candidate confounder because it is a common cause of \(A_1\) and \(Y\). (3) Both \(A_1\) and \(U\) have arrows pointing into \(C\). (4) \(L_1\) is an outcome predictor; the arrow alone does not establish that it is a confounder or mediator.

Clinical Biostats