| tpc_run | R Documentation |
Run a tier-aware variant of the PC algorithm that respects background
knowledge about a partial temporal order. Supply the temporal order via a
Knowledge object.
tpc_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 = lifecycle::deprecated(),
varnames = NULL,
num_cores = 1,
...
)
Any independence test implemented in pcalg may be used; see
pcalg::pc(). When na_method = "twd", test-wise deletion is
performed: for cor_test(), each pairwise correlation uses complete cases;
for reg_test(), each conditional test performs its own deletion. If you
supply a user-defined test, you must also provide suff_stat.
Temporal or tiered knowledge enters in two places:
during skeleton estimation, candidate conditioning sets are pruned so they do not contain variables that are strictly after both endpoints;
during orientation, any cross-tier edge is restricted to point forward in time.
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 (of class PDAG) representing the learned causal graph
from the causal discovery algorithm.
# Load data
data(tpc_example)
# Build knowledge
kn <- knowledge(
tpc_example,
tier(
child ~ tidyselect::starts_with("child"),
youth ~ tidyselect::starts_with("youth"),
old ~ tidyselect::starts_with("old")
)
)
# Recommended route using disco
my_tpc <- tpc(engine = "causalDisco", test = "fisher_z", alpha = 0.05)
disco(tpc_example, my_tpc, knowledge = kn)
# or using my_tpc directly
my_tpc <- my_tpc |> set_knowledge(kn)
my_tpc(tpc_example)
# Using tpc_run() directly
tpc_run(tpc_example, knowledge = kn, alpha = 0.01)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.