Wraps dagitty::adjustmentSets() and returns the adjustment set as a
plain character vector — or NULL if the effect is not identifiable.
Arguments
- dag
A
dagittyDAG object.- exposure
Character, name of the exposure variable.
- outcome
Character, name of the outcome variable.
- type
One of
"minimal","canonical","all"; forwarded todagitty::adjustmentSets().- effect
One of
"direct"or"total"; forwarded todagitty::adjustmentSets().
Examples
if (requireNamespace("dagitty", quietly = TRUE)) {
dag <- causal_clorpt_dag()
# `effect` decides WHICH estimand you are adjusting for, and the
# default is "direct". That distinction is not cosmetic.
#
# Climate is exogenous in this DAG -- it has no parents at all --
# so the TOTAL effect of Climate on SOC is not confounded by
# anything, and the adjustment set is empty:
dagitty::parents(dag, "Climate")
causal_adjustment_set(dag, "Climate", "SOC", effect = "total")
# The default asks a different question. Climate reaches SOC both
# directly and through Organisms, so isolating the DIRECT effect
# means blocking the indirect path:
causal_adjustment_set(dag, "Climate", "SOC") # effect = "direct"
# Organisms is a CHILD of Climate, not a common cause of both.
dagitty::children(dag, "Climate")
# So do not read a non-empty adjustment set as "these are the
# confounders". Conditioning on a mediator does not remove bias --
# it changes the estimand from total to direct, and conditioning
# on one when you wanted the total effect introduces bias rather
# than removing it.
}
#> [1] "Organisms" "SOC" "Weathering"
