Plot a Bayesian network and format its arcs according to the strength of the dependencies they represent. Requires the Rgraphviz package.
strength.plot(x, strength, threshold, cutpoints, highlight = NULL, groups,
layout = "dot", shape = "circle", main = NULL, sub = NULL, render = TRUE,
debug = FALSE)
an object of class bn
.
an object of class bn.strength
computed from the object
of class bn
corresponding to the x
argument.
a numeric value. See below.
an array of numeric values. See below.
a list, see graphviz.plot
for details.
a list of character vectors, representing groups of node labels of nodes that should be plotted close to each other.
a character string, the layout argument that will be passed to
Rgraphviz. Possible values are dots
, neato
,
twopi
, circo
and fdp
. See Rgraphviz documentation
for details.
a character string, the shape of the nodes. Can be circle
,
ellipse
or rectangle
.
a character string, the main title of the graph. It's plotted at the top of the graph.
a character string, a subtitle which is plotted at the bottom of the graph.
a boolean value. If TRUE
a lot of debugging output is
printed; otherwise the function is completely silent.
a logical value. If TRUE
, strength.plot()
actually
draws the figure in addition to returning the corresponding graph
object. If FALSE
, no figure is produced.
graphviz.plot()
returns invisibly the graph
object produced by
Rgraphviz. It can be further modified using the commands present in the
graph and Rgraphviz packages, and it contains the arc strengths
in the edge weight attribute.
The threshold
argument is used to determine which arcs are supported
strongly enough by the data to be deemed significant:
if arc strengths have been computed using conditional independence tests, any strength coefficient (which is the p-value of the test) lesser than or equal to the threshold is considered significant.
if arc strengths have been computed using network scores, any strength coefficient (which is the increase/decrease of the network score caused by the removal of the arc) lesser than the threshold is considered significant.
if arc strengths have been computed using bootstrap or using Bayes factors, any strength coefficient (which can be interpreted as a probability for inclusion) greater or equal than the threshold is considered significant.
The default value is the value of the strength
attribute of the
bn.strength
object passed via the strength
argument.
Non-significant arcs are plotted as dashed lines.
The cutpoints
argument is an array of numeric values used to divide
the range of the strength coefficients into intervals. The interval each
strength coefficient falls into determines the line width of the corresponding
arc in the plot. The default intervals are delimited by
unique(c(0, threshold/c(10, 5, 2, 1.5, 1), 1))
if the coefficients are computed from conditional independence tests, by
unique(c(0, (1 - threshold)/c(10, 5, 2, 1.5, 1), 1))
for bootstrap estimates or by the quantiles
quantile(s[s < threshold], 1 - c(0.50, 0.75, 0.90, 0.95, 1))
of the significant differences if network scores are used.
# NOT RUN {
# plot the network learned by gs().
res = set.arc(gs(learning.test), "A", "B")
strength = arc.strength(res, learning.test, criterion = "x2")
\dontrun{strength.plot(res, strength)}
# add another (non-significant) arc and plot the network again.
res = set.arc(res, "A", "C")
strength = arc.strength(res, learning.test, criterion = "x2")
\dontrun{strength.plot(res, strength)}
# }
Run the code above in your browser using DataLab