Why a Variable’s Causal Role Matters
When an exposure and an outcome are associated, the association may reflect a causal effect, a shared cause, or the way the data were selected or analyzed. A causal diagram helps make these possibilities visible. In particular, it helps distinguish a variable that should be considered as a potential confounder from one that carries part of an exposure’s effect, or one that can create bias when conditioned on.
The same variable name does not have the same role in every analysis. Roles are defined relative to a particular exposure, outcome, and causal structure. A variable may be a mediator for one question and a confounder for another. The arrows in the diagram, and the question being asked, determine its role; the fact that a variable predicts the outcome does not.
A directed arrow represents a proposed causal direction. For example, \(C \to X\) means that \(C\) is a cause of \(X\) in the diagram. These roles are structural descriptions, not labels assigned by a statistical test. In particular, observing that a variable is associated with both exposure and outcome is not, by itself, enough to establish that it is a confounder.
Recognizing the Three Roles in a Diagram
The basic patterns below show how to classify a variable. The direction of the arrows is essential: the middle variable in a chain has a different role from the middle variable in a fork or a collider.
| Role | Basic diagram | What the pattern means |
|---|---|---|
| Confounder \(C\) | \(X \leftarrow C \to Y\) | \(C\) is a shared cause of exposure and outcome. |
| Mediator \(M\) | \(X \to M \to Y\) | Part of the effect of \(X\) on \(Y\) passes through \(M\). |
| Collider \(K\) | \(X \to K \leftarrow U \to Y\) | \(K\) is a shared effect of \(X\) and \(U\); conditioning on \(K\) can connect \(X\) and \(U\). |
A confounder can leave an open noncausal route between \(X\) and \(Y\). A mediator, by contrast, is on a causal route from \(X\) to \(Y\). Adjusting for it can remove part of the effect one may want to estimate. A collider has the opposite default behavior from a confounder: the path through a collider is blocked unless the analysis conditions on the collider or selects on it.
“Adjusting for” a variable means comparing exposure groups at the same value of that variable, or otherwise controlling for it in an analysis. The earlier material on backdoor adjustment sets explains how adjustment can block noncausal paths. The key point here is that adding more variables to an adjustment set is not automatically safer: controlling for a mediator or collider can cause a problem even when controlling for a confounder is appropriate.
Worked Example: A Common Cause Produces an Unadjusted Association
Suppose a hypothetical diagram concerns an exposure \(X\), an outcome \(Y\), and a pre-exposure characteristic \(C\), with \(C \to X\) and \(C \to Y\). Let \(C\) be binary, with \(P(C=1)=0.5\). Suppose \(P(X=1\mid C=1)=0.8\) and \(P(X=1\mid C=0)=0.2\). The outcome is \(Y=10+5C\), with no causal effect of \(X\) in this example. What exposure-outcome difference appears before and after comparing within levels of \(C\)?
First calculate the proportion with \(C=1\) among the exposed. By Bayes’ rule,
For the unexposed,
The expected outcome is \(10\) when \(C=0\) and \(15\) when \(C=1\). Therefore the unadjusted means are
The unadjusted difference is \(14-11=3\) outcome units, even though \(X\) has no causal effect in the specified outcome equation. Within either level of \(C\), the outcome is the same for \(X=1\) and \(X=0\); the within-\(C\) difference is zero. Here \(C\) is a confounder because it causes both exposure and outcome, and the imbalance in \(C\) accounts for the crude association. Both exposure values occur at each level of \(C\), so these within-level comparisons are represented in the hypothetical data-generating setup.
Adjusting for a Mediator Changes the Effect Being Described
Suppose the causal question concerns the total effect of changing \(X\) on \(Y\). If some of that effect travels through a mediator \(M\), holding \(M\) fixed removes that part of the pathway from the comparison. An adjusted exposure coefficient may then describe a different quantity from the total effect.
Worked Example: Separating Direct and Mediated Effects
Consider a hypothetical linear structural model in which \(X\) is an exposure, \(M\) is a mediator, and \(Y\) is an outcome:
Assume \(X\) is a binary exposure, the errors have mean zero at each exposure level, and there are no common causes of \(X\) and \(M\), \(X\) and \(Y\), or \(M\) and \(Y\). Also assume the displayed linear relationships correctly describe the hypothetical process. The coefficient 2 means that changing \(X\) from 0 to 1 changes the mean of \(M\) by 2 mediator units. The coefficient 4 means that a one-unit increase in \(M\) changes the mean of \(Y\) by 4 outcome units, holding \(X\) fixed.
Substitute the equation for \(M\) into the equation for \(Y\):
Because the errors have mean zero at each exposure level, the total difference in mean outcome when \(X\) changes from 0 to 1 is \(11\) outcome units. The pathway through \(M\) contributes \(2(4)=8\) of those units, and the direct pathway represented by the coefficient of \(X\) contributes \(3\). Thus \(3+8=11\).
In a model that holds \(M\) fixed, the coefficient of \(X\) in the specified outcome equation is 3, not 11. Under the assumptions in this example, that is the direct effect not passing through \(M\); it is not the total effect. Adjusting for \(M\) has not necessarily made the analysis mathematically wrong. It has changed which causal effect the coefficient represents. If the target is the total effect, controlling for this mediator omits the mediated contribution.
Conditioning on a Collider Can Create an Association
A collider is a common effect, with arrows pointing into it from two variables. In the pattern \(X \to K \leftarrow U \to Y\), the path between \(X\) and \(Y\) is blocked at \(K\) when no conditioning or selection on \(K\) occurs. Conditioning on \(K\) can make information about one cause informative about the other: among people with the same collider value, one cause can help explain why the collider took that value. This can induce an association along a path that was otherwise blocked.
Worked Example: Selection on a Collider Creates a Spurious Difference
Imagine a hypothetical setting with two independent binary variables, \(X\) and \(U\), each having probability \(0.5\) of being 1. Let \(K=1\) whenever at least one of \(X\) and \(U\) is 1, and let \(Y=U\). The diagram is \(X \to K \leftarrow U \to Y\). There is no causal effect of \(X\) on \(Y\), and \(X\) and \(U\) are independent before conditioning.
Without conditioning on \(K\), \(Y=U\) has mean \(0.5\) in both exposure groups, because \(X\) and \(U\) are independent:
Now consider only individuals with \(K=1\). If \(X=0\), the rule defining \(K\) requires \(U=1\), so \(Y=1\). If \(X=1\), \(K=1\) regardless of \(U\), so \(U\) remains equally likely to be 0 or 1 and the mean of \(Y\) is \(0.5\). Therefore, within the selected group,
Among those with \(K=1\), the exposed group has a mean outcome 0.5 units lower, despite the absence of any causal effect of \(X\) on \(Y\). Conditioning on the common effect \(K\) has induced an association between \(X\) and \(U\), which is a cause of \(Y\). The result is a spurious exposure-outcome association in the selected group. This example illustrates the direction and mechanism of collider bias; it does not claim that every collider adjustment produces a difference of this size or direction.
A Short Justification: Follow the Path
The patterns can be understood by asking whether the middle node receives or sends arrows along a path. In the confounder fork \(X \leftarrow C \to Y\), the shared cause can vary across exposure groups and also predict the outcome. In the mediator chain \(X \to M \to Y\), changing \(X\) can change \(M\), which can then change \(Y\). In the collider pattern \(X \to K \leftarrow U \to Y\), knowing that \(K\) occurred can make the two incoming causes statistically dependent.
The collider example gives a direct numerical justification for the last claim. Before conditioning, independence gives \(P(U=1\mid X=1)=P(U=1\mid X=0)=0.5\). But after selecting \(K=1\), the defining rule forces \(U=1\) when \(X=0\), while it imposes no restriction on \(U\) when \(X=1\). Thus:
Conditioning has changed the distribution of \(U\) across exposure groups. Since \(Y=U\), the outcome distributions differ as well. This is the induced association that makes collider adjustment hazardous.
Classify Before Deciding Whether to Adjust
A practical reading of a diagram begins with the exposure and outcome of interest, then traces each variable’s arrows. Use the role as a warning about what adjustment might do, not as an automatic instruction to include or exclude a variable. The appropriate choice depends on the causal question and the full diagram.
A variable cannot be called a confounder or mediator in the abstract; first specify the \(X\)-to-\(Y\) question.
A common cause suggests confounding; a variable downstream of \(X\) on a path to \(Y\) is a mediator; a common effect with arrows pointing into it is a collider.
Controlling for a confounder may block a noncausal path. Controlling for a mediator can remove part of a total effect. Conditioning on a collider can open a noncausal path.
State whether the target is a total effect or another effect, and justify the adjustment using the assumed causal structure rather than predictive strength alone.
These classifications do not establish that an effect is identified from observational data. A diagram is a representation of causal assumptions, and a useful adjustment choice still depends on whether the relevant causes have been measured and whether the assumptions represented by the diagram are credible.
Common Mistakes and Why They Matter
- Adjusting for every available variable. More adjustment is not always better. A mediator may remove part of a total effect, and a collider may create a noncausal association.
- Calling every predictor a confounder. A variable’s ability to predict exposure or outcome does not establish that it is a common cause of both.
- Confusing a mediator with a confounder. A mediator is downstream of the exposure on a causal pathway; a confounder is a common cause that precedes the exposure in the relevant pattern.
- Assuming conditioning on a collider is harmless because it improves comparability. In the collider example, selection made the exposure groups differ in \(U\), which caused the outcome.
- Calling an adjusted estimate “the effect” without naming the target. In the mediation example, the total effect was 11 units, while the coefficient conditional on the mediator was 3 units under the stated model and assumptions.
Check Your Understanding
For each question, identify the relevant arrow pattern and explain what conditioning on the named variable could do.
- A pre-exposure factor \(C\) causes both \(X\) and \(Y\). What role does \(C\) play for the \(X\)-to-\(Y\) question?
- In the diagram \(X \to M \to Y\), what part of the causal pathway may be removed by adjusting for \(M\) when the target is the total effect?
- In \(X \to K \leftarrow U \to Y\), what role does \(K\) play, and why can conditioning on it induce an association between \(X\) and \(Y\)?
- Why is the fact that a variable predicts both exposure and outcome not sufficient to classify it as a confounder?
- In the mediator example, the total effect is 11 outcome units and the conditional coefficient is 3. Which pathway contributes the remaining 8 units?