Run the Grow-Shrink algorithm for causal discovery using one of several engines.
Usage
gs(engine = c("bnlearn"), test, alpha = 0.05, ...)Details
For specific details on the supported tests and parameters for each engine, see:
BnlearnSearch for bnlearn.
Recommendation
While it is possible to call the function returned directly with a data frame,
we recommend using disco(). This provides a consistent interface and handles knowledge
integration.
Value
A function that takes a single argument data (a data frame). When called,
this function returns a list containing:
knowledgeAKnowledgeobject with the background knowledge used in the causal discovery algorithm. Seeknowledge()for how to construct it.caugiAcaugi::caugiobject (of classPDAG) representing the learned causal graph from the causal discovery algorithm.
References
Margaritis, D., Thrun, S.: Bayesian network induction via local neighborhoods. Tech. rep., DTIC Document (2000).
See also
Other causal discovery algorithms:
boss(),
boss_fci(),
fci(),
ges(),
gfci(),
grasp(),
grasp_fci(),
iamb-family,
pc(),
rfci(),
sp_fci(),
tfci(),
tges(),
tpc()
Examples
data(tpc_example)
kn <- knowledge(
tpc_example,
starts_with("child") %-->% starts_with("youth")
)
# Recommended path using disco()
gs_bnlearn <- gs(
engine = "bnlearn",
test = "fisher_z",
alpha = 0.05
)
disco(tpc_example, gs_bnlearn, knowledge = kn)
#> <Disco MPDAG: 6 nodes | 9 edges | Knowledge: 4 required>
#> Learned graph:
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x1-->youth_x3, child_x1-->youth_x4
#> child_x2-->oldage_x5, child_x2-->youth_x3, child_x2-->youth_x4
#> oldage_x5-->oldage_x6, youth_x3-->oldage_x5, youth_x4-->oldage_x6
#> Knowledge:
#> vars: child_x1, child_x2, oldage_x5, oldage_x6, youth_x3, youth_x4
#> required:
#> child_x1-->youth_x3 + youth_x4
#> child_x2-->youth_x3 + youth_x4
# or using gs_bnlearn directly
gs_bnlearn <- gs_bnlearn |> set_knowledge(kn)
gs_bnlearn(tpc_example)
#> <Disco PDAG: 6 nodes | 9 edges>
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x1-->youth_x3, child_x1-->youth_x4
#> child_x2-->oldage_x5, child_x2-->youth_x3, child_x2-->youth_x4
#> oldage_x5-->oldage_x6, youth_x3-->oldage_x5, youth_x4-->oldage_x6
# With all algorithm arguments specified
gs_bnlearn <- gs(
engine = "bnlearn",
test = "fisher_z",
alpha = 0.05,
max.sx = 2,
debug = FALSE,
undirected = TRUE
)
disco(tpc_example, gs_bnlearn)
#> <Disco CPDAG: 6 nodes | 5 edges>
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x2---oldage_x6, child_x2---youth_x4
#> oldage_x6---youth_x3, oldage_x6---youth_x4
