Adjusting for the right variables

Jump to the first figure ↓

To estimate the effect of one variable on another from observational data, you regress the outcome on the exposure and on some other variables. Which others? Adjusting for a common cause removes bias; adjusting for a consequence of the exposure, or for a common effect, adds it. In a linear causal graph the answer is exact: the graph fixes the covariance of everything, and from it the coefficient any adjustment gives, which can be set against the true effect.

1 The adjustment playground

Each variable is a weighted sum of its causes, the numbers on the arrows, plus noise of its own. The causal effect of the exposure on the outcome is the sum, over the directed paths between them, of the products of their coefficients. An adjustment set gives that number exactly when it blocks every non-causal path and contains nothing the exposure affects on the way to the outcome. Choose a graph, its numbers and what to adjust for; click a node in the graph to adjust for it.

Graph

    Adjust for

    Coefficients

    Paths from the exposure to the outcome

      Every adjustment set

      The criterion is the adjustment criterion of Shpitser, VanderWeele and Robins, checked by d-separation. Choose a row to adjust for that set.

      A simulated sample

        Points drawn from the graph (seeded Monte Carlo), with the adjustment set regressed out of both the exposure and the outcome. By the Frisch–Waugh theorem the slope of this cloud is the adjusted regression coefficient.

        2 Adjusting for many colliders

        Let Y and U be independent, and let each of p measured variables X₁ … Xp be caused by both. Each X has correlation r with Y; of the room left, a share comes from U, so the X's correlate with each other through both. Regress Y on all of them: they explain part of Y, and once they are held fixed, Y and U are no longer independent. With many weak colliders the induced correlation of Y and U nears −1 while the X's explain little of Y.

        Share of Y's variance the colliders explain (R²), for 1 to 1,024 colliders.
        The partial correlation of Y and U given all the colliders, which is 0 without adjustment. The line marked ● is your number of colliders; the dot is your share.

        Cor(Xi, U)² is this share of 1 − r², and Cor(Xi, Xj) = r² + Cor(X, U)².

        How it works

        From a graph to a coefficient

        In a linear graph each variable is Σ b × parent + noise, so the covariance of all of them is (I − B)−T Ω (I − B)−1, with B the coefficients and Ω the noise variances. The coefficient of the exposure in a regression on the exposure and an adjustment set is the corresponding entry of ΣSS−1ΣSY, the population value a large sample converges to. Nothing here is estimated except the optional sample. Standardized noise sets each node's own variance so that every variable has variance 1, which makes the coefficients path coefficients, as in dagitty's impliedCovarianceMatrix; it is impossible when a node's coefficients would explain all of its variance.

        Which sets work

        A set is valid for every choice of coefficients exactly when it meets the adjustment criterion: it contains no descendant of a variable on a causal path from the exposure to the outcome, and it blocks every non-causal path between them. A path is blocked by an adjusted variable that is not a collider on it, or by a collider on it that neither it nor any of its descendants is adjusted for. An edge with coefficient 0 counts as absent. A set that fails the criterion can still give the right number when two biases cancel; the table marks that case.

        The presets

        The front-door preset uses smoking, tar and cancer: the genotype that confounds smoking and cancer is unobserved, so no adjustment works, yet the effect equals the effect of smoking on tar times the effect of tar on cancer given smoking. The income and happiness graph is an illustrative model inspired by Bjälkebring and Peters, "Money matters (especially if you are good at math): Numeracy, verbal intelligence, education, and income in satisfaction judgments" (PLOS ONE 16(11): e0259331, 2021). In this model, illness lowers income and satisfaction, numeracy raises income, and income raises satisfaction; numeracy has no direct effect, and the simulation has no numeracy-by-income interaction. The coefficients are illustrative simulation values, not estimates from the paper's data. In that graph, adjusting for income makes numeracy look harmful (−2) although its effect, all through income, is +4.

        Many colliders

        With exchangeable colliders the conditional covariance of Y and U has a closed form: with d = 1 + (p − 1) Cor(Xi, Xj), the colliders explain pr²/d of Y, and the partial correlation is −p r Cor(X, U) / √((1 − Cor(Xi, Xj) + p Cor(X, U)²)(1 − Cor(Xi, Xj) + pr²)). Scripts and agents can run every computation on this page through the API, including graphs of their own.