choose.direction {bnlearn}R Documentation

Try to infer the direction of an undirected arc

Description

Check both possible directed arcs for existence, and choose the one with the lowest p-value.

Usage


  choose.direction(x, arc, data, debug = FALSE)

Arguments

x an object of class "bn".
arc a character string array of length 2, the labels of two nodes of the graph.
data a data frame, containing the data the Bayesian network was learned from.
debug a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Value

choose.direction returns invisibly an updated copy of x.

Author(s)

Marco Scutari

Examples


data(learning.test)

res = gs(learning.test)
# the arc between E and F has no direction
plot(res)
res = choose.direction(res, c("E", "F"), learning.test, debug = TRUE)
# * testing E - F for direction.
#   > testing E -> F with conditioning set '  '.
#     > p-value is 2.174867e-197 .
#   > testing F -> E with conditioning set ' B '.
#     > p-value is 3.935648e-245 .
#   @ removing E -> F .
plot(res, highlight = c("E", "F"))


[Package bnlearn version 0.4 Index]