Skip to main content

Causal Identification

Source: vignettes/articles/causal-identification.qmd

This guide expands on the Getting Started guide with more advanced identification techniques.

Adjustment strategies

adjustment_set() supports three different strategies for finding adjustment sets. Let’s build a DAG with multiple confounders and mediators, Figure 6.5 of Peters et al. (2017):

dag <- cgraph(
  C %-->% X,
  A %-->% X + K,
  X %-->% F + D,
  K %-->% Y,
  D %-->% Y + G,
  Y %-->% H
)
plot(dag)

Parents strategy: Adjusts for all parents of X. Simple but often includes unnecessary variables:

adjustment_set(dag, "X", "Y", type = "parents")
#> [1] "A" "C"

Backdoor strategy: Applies Pearl’s backdoor criterion to find valid adjustment sets that block all confounding paths:

adjustment_set(dag, "X", "Y", type = "backdoor")
#> [1] "A"

Optimal strategy (default): Computes the O-set, which minimizes the asymptotic variance of the causal effect estimator:

adjustment_set(dag, "X", "Y", type = "optimal")
#> [1] "K"

Minimal separator

Sometimes we need the smallest set of variables that d-separates two nodes. minimal_separator() finds one:

minimal_separator(dag, "X", "Y")
#> [1] "A" "D"

The restrict argument limits the search to a specific pool of variables:

minimal_separator(dag, "X", "Y", restrict = c("D", "K"))
#> [1] "D" "K"

The include argument forces certain variables to always be in the result:

minimal_separator(dag, "X", "Y", include = "K")
#> [1] "D" "K"

Frontdoor adjustment

When confounders are unobserved, the backdoor criterion doesn’t apply. Consider a graph where an unobserved confounder U affects both the treatment X and outcome Y:

dag2 <- cgraph(U %-->% X + Y, X %-->% M %-->% Y)
plot(dag2)

The mediator M is a descendant of X, so adjusting for it violates the backdoor criterion:

is_valid_backdoor(dag2, "X", "Y", "M")
#> [1] FALSE

However, M intercepts every causal path from X to Y and is itself unconfounded; this is exactly the frontdoor criterion:

is_valid_frontdoor(dag2, "X", "Y", "M")
#> [1] TRUE
frontdoor_set(dag2, "X", "Y")
#> [1] "M"

Instrumental variables

When hidden confounders block backdoor adjustment and no suitable mediator exists for the frontdoor criterion, an instrumental variable (IV) can still identify the causal effect. An instrument Z must satisfy two conditions: it must be associated with the treatment X (relevance), and it can only affect the outcome Y through X (exclusion restriction).

Consider a graph where U is an unobserved confounder and Z is an available instrument, but there is no mediator on the path from X to Y:

dag3 <- cgraph(U %-->% X + Y, Z %-->% X %-->% Y)
plot(dag3)

Without a mediator, the frontdoor criterion cannot apply here:

is_valid_frontdoor(dag3, "X", "Y", "Z")
#> [1] FALSE

However, Z is a valid instrument since it is d-connected to X, and d-separated from Y once the causal edge X --> Y is removed, so it can only affect Y through X:

is_valid_iv(dag3, "X", "Y", "Z")
#> [1] TRUE

An instrument may also only be valid conditionally on a set of variables. Here W confounds Z and Y, so Z is an instrument only once we condition on W:

dag5 <- cgraph(W %-->% Z + Y, Z %-->% X %-->% Y, U %-->% X + Y)
is_valid_iv(dag5, "X", "Y", "Z")
#> [1] FALSE
is_valid_iv(dag5, "X", "Y", "Z", given = "W")
#> [1] TRUE

iv_set() searches for an instrument together with a conditioning set that makes it valid, and restrict limits both to the observed variables:

iv_set(dag5, "X", "Y")
#> $z
#> [1] "Z"
#> 
#> $given
#> [1] "W"
is.null(iv_set(dag5, "X", "Y", restrict = c("Z", "X", "Y")))
#> [1] TRUE

ADMG adjustment

In an ADMG (acyclic directed mixed graph), bidirected edges <-> represent hidden common causes directly, without explicitly keeping the unobserved nodes in the graph. An ADMG arises naturally by projecting unobserved variables out of a DAG with latent_project(). Let’s project U out of dag3:

admg <- latent_project(dag3, "U")
admg
#> ADMG with 3 nodes and 3 edges:
#>   nodes: X, Y, Z
#>   edges:
#>     X --> Y, X <-> Y, Z --> X

Removing U introduces X <-> Y, which captures its confounding effect. The functions discussed above also work on ADMGs, e.g.:

is_valid_iv(admg, "X", "Y", "Z")
#> [1] TRUE

General identification

The methods discussed above are each sufficient, not necessary. CausalStructures also implements the ID algorithm of Shpitser and Pearl (2008), which returns the estimand as a formula.

On a graph with an observed confounder, it recovers the familiar g-formula:

dag4 <- cgraph(Z %-->% X + Y, X %-->% Y)
id(dag4, "X", "Y")
#> [1] "Σ_{Z} P(Y | X, Z) P(Z)"

Unlike the criteria above, id() also works when no adjustment set exists at all. Recall the front-door graph from before, where U is an unobserved confounder of X and Y, and M mediates the effect of X on Y. Projecting U out gives an ADMG with no valid adjustment set, yet id() still identifies the effect through the mediator:

admg2 <- latent_project(dag2, "U")
id(admg2, "X", "Y")
#> [1] "Σ_{M} P(M | X) (Σ_{X'} P(X') P(Y | M, X'))"

which is the standard front-door adjustment formula. The primed X' is a summation index distinct from the intervened value of X, following the usual convention.

id() can also detect non-identifiability. In the instrument graph from before, with U projected out, the causal effect cannot be identified:

is.null(id(admg, "X", "Y"))
#> [1] TRUE

idc() extends id() to conditional effects \(P(y \mid do(x), z)\):

idc(admg2, "X", "Y", given = "M")
#> [1] "Σ_{X'} P(X') P(Y | M, X')"

References

Peters, Jonas Martin, Dominik Janzing, and Bernhard Schölkopf. 2017. Elements of Causal Inference: Foundations and Learning Algorithms: Foundations and Learning Algorithms. Adaptive Computation and Machine Learning Series. MIT Press.
Shpitser, Ilya, and Judea Pearl. 2008. “Complete Identification Methods for the Causal Hierarchy.” Journal of Machine Learning Research 9: 1941–79.