These functions test various properties of nodes in a DAG:
is_exogenous()
tests whether a variable is exogenous (has no parents)is_instrumental()
tests whether a variable is instrumentalis_exposure()
,is_outcome()
,is_latent()
test variable status
Usage
is_exogenous(.dag, .var)
is_instrumental(.dag, .var, exposure = NULL, outcome = NULL)
is_exposure(.dag, .var)
is_outcome(.dag, .var)
is_latent(.dag, .var)
Arguments
- .dag
A
tidy_dagitty
ordagitty
object- .var
A character string specifying the variable to test
- exposure
A character vector, the exposure variable. Default is
NULL
, in which case it will be determined from the DAG.- outcome
A character vector, the outcome variable. Default is
NULL
, in which case it will be determined from the DAG.
Examples
dag <- dagify(
y ~ x + z,
x ~ z,
exposure = "x",
outcome = "y",
latent = "z"
)
is_exogenous(dag, "z")
#> [1] TRUE
is_exposure(dag, "x")
#> [1] TRUE
is_outcome(dag, "y")
#> [1] TRUE
is_latent(dag, "z")
#> [1] TRUE