Learn R Programming

bnlearn (version 0.3)

choose.direction: 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 variables in the model.
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.

Examples

Run this code
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.041687e-44 .
# > testing F -> E with conditioning set '  '.
#   > p-value is 4.598853e-08 .
# @ removing F -> E .
plot(res, highlight = c("E", "F"))

Run the code above in your browser using DataLab