| gfci | R Documentation |
Run the Greedy Fast Causal Inference algorithm for causal discovery using one of several engines.
gfci(engine = "tetrad", score, test, alpha = 0.05, ...)
engine |
Character; which engine to use. Must be one of:
|
score |
Character; name of the scoring function to use. |
test |
Character; name of the conditional‐independence test. |
alpha |
Numeric; significance level for the CI tests. |
... |
Additional arguments passed to the chosen engine (e.g. score and algorithm parameters). |
For specific details on the supported scores, and parameters for each engine, see:
TetradSearch for Tetrad.
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.
A function that takes a single argument data (a data frame). When called,
this function returns a list containing:
knowledge A Knowledge object with the background knowledge
used in the causal discovery algorithm. See knowledge() for how to construct it.
caugi A caugi::caugi object representing the learned causal graph.
This graph is a PAG (Partial Ancestral Graph), but since PAGs are not yet
natively supported in caugi, it is currently stored with class UNKNOWN.
Ogarrio, J. M., Spirtes, P., and Ramsey, J. (2016). A hybrid causal search algorithm for latent variable models. In Conference on probabilistic graphical models, pages 368–379. PMLR.
Other causal discovery algorithms:
boss(),
boss_fci(),
fci(),
ges(),
grasp(),
grasp_fci(),
gs(),
iamb-family,
pc(),
sp_fci(),
tfci(),
tges(),
tpc()
data(num_data)
# Requires Tetrad to be installed
if (verify_tetrad()$installed && verify_tetrad()$java_ok) {
# Recommended path using disco()
gfci_tetrad <- gfci(
engine = "tetrad",
score = "sem_bic",
test = "fisher_z"
)
disco(tpc_example, gfci_tetrad)
# or using gfci_tetrad directly
gfci_tetrad(tpc_example)
}
#### With tier knowledge ####
if (verify_tetrad()$installed && verify_tetrad()$java_ok) {
kn <- knowledge(
tpc_example,
tier(
child ~ tidyselect::starts_with("child"),
youth ~ tidyselect::starts_with("youth"),
oldage ~ tidyselect::starts_with("oldage")
)
)
# Recommended path using disco()
gfci_tetrad <- gfci(
engine = "tetrad",
score = "sem_bic",
test = "fisher_z"
)
disco(tpc_example, gfci_tetrad, knowledge = kn)
# or using gfci_tetrad directly
gfci_tetrad <- gfci_tetrad |> set_knowledge(kn)
gfci_tetrad(tpc_example)
}
# With all algorithm arguments specified
if (verify_tetrad()$installed && verify_tetrad()$java_ok) {
gfci_tetrad <- gfci(
engine = "tetrad",
score = "poisson_prior",
test = "rank_independence",
depth = 3,
max_degree = 2,
max_disc_path_length = 5,
use_heuristic = FALSE,
complete_rule_set_used = FALSE,
guarantee_pag = TRUE,
start_complete = TRUE,
num_threads = 2,
verbose = TRUE
)
disco(num_data, gfci_tetrad)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.