Learn R Programming

causalDisco (version 1.0.1)

tpc: TPC Algorithm for Causal Discovery

Description

Run the temporal PC algorithm for causal discovery using causalDisco.

Usage

tpc(engine = c("causalDisco"), test, alpha = 0.05, ...)

Value

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.

Arguments

engine

Character; which engine to use. Must be one of:

"causalDisco"

causalDisco library.

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. test or algorithm parameters).

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.

Details

For specific details on the supported tests, see CausalDiscoSearch. For additional parameters passed via ..., see tpc_run().

See Also

Other causal discovery algorithms: boss(), boss_fci(), fci(), ges(), gfci(), grasp(), grasp_fci(), gs(), iamb-family, pc(), sp_fci(), tfci(), tges()

Examples

Run this code
# 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)

Run the code above in your browser using DataLab