Run the Temporal Peter-Clark algorithm for causal discovery using one of several engines.
Usage
tpc(engine = c("causalDisco"), test, alpha = 0.05, ...)Details
For specific details on the supported tests, see CausalDiscoSearch. For additional parameters
passed via ..., see tpc_run().
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
Petersen AH, Osler M, and Ekstrøm CT. Data-Driven Model Building for Life-Course Epidemiology. American Journal of Epidemiology 2021 Mar; 190:1898–907, doi:10.1093/aje/kwab087.
See also
Other causal discovery algorithms:
boss(),
boss_fci(),
fci(),
ges(),
gfci(),
grasp(),
grasp_fci(),
gs(),
iamb-family,
pc(),
rfci(),
sp_fci(),
tfci(),
tges()
Examples
# 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)
#> <Disco MPDAG: 6 nodes | 6 edges | Knowledge: 3 tiers>
#> Learned graph:
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x2-->oldage_x5, child_x2-->youth_x4
#> oldage_x5-->oldage_x6, youth_x3-->oldage_x5, youth_x4-->oldage_x6
#> Knowledge:
#> tier(child): child_x1, child_x2
#> tier(youth): youth_x3, youth_x4
#> tier(old): oldage_x5, oldage_x6
# or using my_tpc directly
my_tpc <- my_tpc |> set_knowledge(kn)
my_tpc(tpc_example)
#> <Disco UNKNOWN: 6 nodes | 6 edges | Knowledge: 3 tiers>
#> Learned graph:
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x2-->oldage_x5, child_x2-->youth_x4
#> oldage_x5-->oldage_x6, youth_x3-->oldage_x5, youth_x4-->oldage_x6
#> Knowledge:
#> tier(child): child_x1, child_x2
#> tier(youth): youth_x3, youth_x4
#> tier(old): oldage_x5, oldage_x6
# Using tpc_run() directly
tpc_run(tpc_example, knowledge = kn, alpha = 0.01)
#> <Disco UNKNOWN: 6 nodes | 6 edges | Knowledge: 3 tiers>
#> Learned graph:
#> nodes: child_x2, child_x1, youth_x4, youth_x3, oldage_x6, oldage_x5
#> edges: child_x1---child_x2, child_x2-->oldage_x5, child_x2-->youth_x4
#> oldage_x5-->oldage_x6, youth_x3-->oldage_x5, youth_x4-->oldage_x6
#> Knowledge:
#> tier(child): child_x1, child_x2
#> tier(youth): youth_x3, youth_x4
#> tier(old): oldage_x5, oldage_x6
