| tfci_run | R Documentation |
Use a modification of the FCI algorithm that makes use of background knowledge in the format of a partial ordering. This may, for instance, come about when variables can be assigned to distinct tiers or periods (i.e., a temporal ordering).
tfci_run(
data = NULL,
knowledge = NULL,
alpha = 0.05,
test = reg_test,
suff_stat = NULL,
method = "stable.fast",
na_method = "none",
orientation_method = "conservative",
directed_as_undirected = FALSE,
varnames = NULL,
num_cores = 1,
...
)
data |
A data frame with the observed variables. |
knowledge |
A |
alpha |
The alpha level used as the per-test significance threshold for conditional independence testing. |
test |
A conditional independence test. The default |
suff_stat |
A sufficient statistic. If supplied, it is passed directly
to the test and no statistics are computed from |
method |
Skeleton construction method, one of |
na_method |
Handling of missing values, one of |
orientation_method |
Method for handling conflicting separating sets when orienting
edges; must be one of |
directed_as_undirected |
Logical; if |
varnames |
Character vector of variable names. Only needed when
|
num_cores |
Integer number of CPU cores to use for parallel skeleton learning. |
... |
Additional arguments passed to
|
The temporal/tiered background information enters several places in the TFCI
algorithm: (1) In the skeleton construction phase, when looking for separating
sets Z between two variables X and Y, Z is not allowed to
contain variables that are strictly after both X and Y in the temporal
order (as specified by the knowledge tiers). (2) This also applies to the
subsequent phase where the algorithm searches for possible D-SEP sets. (3) Prior
to other orientation steps, any cross-tier edges get an arrowhead placed at their
latest node.
After this, the usual FCI orientation rules are applied; see pcalg::udag2pag()
for details.
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.
data(tpc_example)
kn <- knowledge(
tpc_example,
tier(
child ~ tidyselect::starts_with("child"),
youth ~ tidyselect::starts_with("youth"),
oldage ~ tidyselect::starts_with("oldage")
)
)
# Recommended path using disco()
my_tfci <- tfci(engine = "causalDisco", test = "fisher_z", alpha = 0.05)
disco(tpc_example, my_tfci, knowledge = kn)
# or using my_tfci directly
my_tfci <- my_tfci |> set_knowledge(kn)
my_tfci(tpc_example)
# Also possible: using tfci_run()
tfci_run(tpc_example, test = cor_test, knowledge = kn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.