dag <- cgraph(
C %-->% X, X %-->% F + D, A %-->% X + K, K %-->% Y,
D %-->% Y + G, Y %-->% H
)
sort(adjustment_set(dag, "X", "Y", type = "parents"))
#> [1] "A" "C"
adjustment_set(dag, "X", "Y", type = "backdoor")
#> [1] "A"
adjustment_set(dag, "X", "Y", type = "optimal") # default
#> [1] "K"
pdag <- cgraph(A %-->% X, X %-->% Y, A %-->% Y, class = "PDAG")
adjustment_set(pdag, "X", "Y") # A
#> [1] "A"
is_valid_adjustment(pdag, "X", "Y", "A")
#> [1] TRUE
mag <- cgraph(A %<->% X, A %-->% Y, X %-->% Y, class = "MAG")
adjustment_set(mag, "X", "Y") # A; type is ignored
#> NULL
# Only some nodes are observed
dag <- cgraph(A %-->% B %-->% X + Y, A %-->% Y, X %-->% Y)
adjustment_set(dag, "X", "Y", type = "backdoor", restrict = c("A", "B"))
#> [1] "B"

Find an adjustment set
Source: R/identification.R
Description
Computes a valid adjustment set for the total causal effect of x on y.
Usage
adjustment_set(
cg,
x,
y,
type = c("optimal", "parents", "backdoor"),
include = character(),
restrict = NULL
)Arguments
cg
|
A DAG, ADMG, PDAG-family (PDAG, CPDAG, MPDAG), AG-family (AG, MAG), or PAG graph created with cgraph().
|
x, y
|
Exposure and outcome node name, or character vector of node names (to identify the effect of a set of exposures on a set of outcomes). |
type
|
Adjustment set type: "optimal" (default), "parents", or "backdoor". Ignored for ADMG, MAG-family, and PAG graphs; "backdoor" is not supported for PDAG-family graphs.
|
include
|
Character vector of nodes forced into the set. |
restrict
|
Character vector of candidate nodes the set is drawn from. NULL (default) allows every node except x and y. include and restrict need type = "backdoor" for a DAG, and are not supported for PDAG-family graphs.
|
Details
The supported adjustment set types depend on the graph class:
- DAG
- All three types are supported.
- PDAG-family (PDAG, CPDAG, MPDAG)
-
Only
"parents"and"optimal"are supported;"backdoor"raises an error. - ADMG, MAG-family (AG, MAG), PAG
-
typeis ignored. The smallest valid adjustment set is returned by searching sets of increasing size.
The available adjustment set types are:
-
"parents" -
The parents of
x, excludingxandy. -
"backdoor" -
An inclusion-minimal set satisfying Pearl’s backdoor criterion: a minimal separator of
xandyamongx’s non-descendants, after removingx’s outgoing edges (falls back to the parents ofxif no such separator is found). -
"optimal" -
The O-set: the parents of causal nodes on a possibly causal path from
xtoy, excludingxand those causal nodes themselves.
Candidate adjustment sets can be validated with is_valid_adjustment().
Value
Character vector with a valid adjustment set, or NULL if none exists.
References
Henckel L, Perković E, Maathuis MH (2022). “Graphical Criteria for Efficient Total Effect Estimation Via Adjustment in Causal Linear Models.” Journal of the Royal Statistical Society: Series B, 84, 579–599. ("optimal")
Pearl J (2009). Causality: Models, Reasoning, and Inference, 2nd edition. Cambridge University Press. ("parents" and "backdoor")