Learn R Programming

abn (version 1.3)

plotabn: Plot an ABN graphic

Description

Plot an ABN DAG using formula statement or a matrix in using Rgraphviz through the graphAM class.

Usage

plotabn(dag.m = NULL, data.dists = NULL, markov.blanket.node =
                 NULL, fitted.values.abn = NULL, fitted.values.abn.mle
                 = NULL, digit.precision = 2, arc.strength = NULL,
                 edgemode = "directed", edgedir = "pc", node.fillcolor
                 = "lightblue", edge.color = "black", edge.arrowwise =
                 0.5, fontsize.node = 10, fontsize.edge = 5, plot =
                 TRUE, node.fillcolor.list = NULL)

Arguments

dag.m

a matrix or a formula statement (see details for format) defining the network structure, a Directed Acyclic Graph (DAG). Note that rownames must be set or given in data.dists.

data.dists

a named list giving the distribution for each node in the network, see details.

markov.blanket.node

name of variables to display his Markov Blanket.

fitted.values.abn

modes outputted from fitabn.

fitted.values.abn.mle

regression coefficients outputted from fitabn.mle.

digit.precision

number of digits of the output from fitabn or fitabn.mle.

arc.strength

a named matrix containing evaluations of arcs strength which will change the arcs width (could be Mutual information, p-values, number of bootstrap retrieve samples or the outcome of the link.strength).

edgemode

a "character" vector specifying whether the graph is "directed" or "undirected".

edgedir

character giving the direction in which arcs should be plotted, pc (parent to child) or cp (child to parent).

node.fillcolor

the colour of the node.

edge.color

the colour of the edge.

edge.arrowwise

the thickness of the arrows. Not relevant if arc.strength is provided.

fontsize.node

the font size of the nodes names.

fontsize.edge

the font size of the arcs fitted values.

plot

logical variable, if set to TRUE return a plot of the DAG, if set to FALSE return the adjacency matrix of the given DAG.

node.fillcolor.list

the list of node that should be coloured.

Value

A matrix giving the DAG definition of the most probable posterior structure.

Details

By default binomial nodes are squares, multinoial nodes are empty, Gaussian nodes are circles and poison nodes are ellipses.

The dag.m can be provided using a formula statement (similar to glm). A typical formula is ~ node1|parent1:parent2 + node2:node3|parent3. The formula statement have to start with ~. In this example, node1 has two parents (parent1 and parent2). node2 and node3 have the same parent3. The parents names have to exactly match those given in name. : is the separator between either children or parents, | separates children (left side) and parents (right side), + separates terms, . replaces all the variables in name.

References

Further information about abn can be found at: http://www.r-bayesian-networks.org

Examples

Run this code
# NOT RUN {
#Define distribution list
dist<-list(a="gaussian",b="gaussian",c="gaussian",d="gaussian", e="binomial", f="binomial")

#Define a matrix formulation
arc.strength <- matrix(data = c(0,0.5,0.5,0.7,0.1,0,
                              0,0,0.3,0.1,0,0.8,
                              0,0,0,0.35,0.66,0,
                              0,0,0,0,0.9,0,
                              0,0,0,0,0,0.8,
                              0,0,0,0,0,0),nrow = 6L,ncol = 6L,byrow = TRUE)

#Naming of the matrix
colnames(arc.strength)<-rownames(arc.strength)<-names(dist)
colnames(arc.strength)<-rownames(arc.strength)<-names(dist)

#Plot from a formula
plotabn(dag.m = ~a|b:c:e+b|c:d:f+e|f,data.dist = dist)

#Plot form a matrix
plotabn(dag.m = arc.strength,data.dist = dist)

#Creating adjency matrix
plotabn(dag.m = ~a|b:c:e+b|c:d:f+e|f,data.dist = dist,plot = FALSE)

#Arc strength
plotabn(dag.m = ~a|b:c:e+b|c:d:f+e|f,data.dist = dist,arc.strength = arc.strength)

#Markov blanket
plotabn(dag.m = ~a|b:c:e+b|c:d:f+e|f,data.dists = dist,markov.blanket.node = "e")
# }

Run the code above in your browser using DataLab