Learn R Programming

causalDisco (version 1.0.1)

as_bnlearn_knowledge: Convert Knowledge to bnlearn Knowledge

Description

Converts a Knowledge object to a list of two data frames, namely whitelist and blacklist, which can be used as arguments for bnlearn algorithms. The whitelist contains all required edges, and the blacklist contains all forbidden edges. Tiers will be made into forbidden edges before running the conversion.

Usage

as_bnlearn_knowledge(kn)

Value

A list with two elements, whitelist and blacklist, each a data frame containing the edges in a from, to format.

Arguments

kn

A knowledge object. Must have no tier information.

See Also

Other knowledge functions: +.Knowledge(), add_exogenous(), add_tier(), add_to_tier(), add_vars(), as_pcalg_constraints(), as_tetrad_knowledge(), convert_tiers_to_forbidden(), deparse_knowledge(), forbid_edge(), get_tiers(), knowledge(), knowledge_to_caugi(), remove_edge(), remove_tiers(), remove_vars(), reorder_tiers(), reposition_tier(), require_edge(), seq_tiers(), unfreeze()

Examples

Run this code
# produce whitelist/blacklist data frame for bnlearn
data(tpc_example)

kn <- knowledge(
  tpc_example,
  tier(
    child ~ starts_with("child"),
    youth ~ starts_with("youth"),
    oldage ~ starts_with("old")
  ),
  child_x1 %-->% youth_x3
)

bnlearn_kn <- as_bnlearn_knowledge(kn)
print(bnlearn_kn)

Run the code above in your browser using DataLab