Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot-abn

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, data.dists=NULL, markov.blanket.node=NULL, fitted.values=NULL,
        digits=2, edge.strength=NULL, edge.direction="pc", edge.color="black",
        edge.arrowsize=0.5, edge.fontsize=5, node.fontsize=10,
        node.fillcolor=c("lightblue","brown3","chartreuse3"), node.fillcolor.list=NULL,
        node.shape=c("circle","box","ellipse","diamond"), plot=TRUE , ...)

Arguments

dag

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 its Markov blanket.

fitted.values

modes or coefficents outputted from fitAbn.

digits

number of digits to display the fitted.values.

edge.strength

a named matrix containing evaluations of edge 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).

edge.direction

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

node.fillcolor

the colour of the node. Second and third element is used for the Markov blanket and node of the Markov blanket.

node.shape

the shape of the nodes according the Gaussian, binomial, Poisson and multinomial distributions.

edge.color

the colour of the edge.

edge.arrowsize

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

node.fontsize

the font size of the nodes names.

edge.fontsize

the font size of the arcs fitted values.

plot

logical variable, if set to TRUE then the graph is plotted.

node.fillcolor.list

the list of node that should be coloured.

...

arguments passed to the plotting function.

Details

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

The dag 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.

Value

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

Author(s)

Gilles Kratzer

References

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

Examples

#Define distribution list
dist <- list(a="gaussian", b="gaussian", c="gaussian", d="gaussian", e="binomial", f="binomial")

#Define a matrix formulation
arc.strength <- matrix(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)

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

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

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

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

abn

Modelling Multivariate Data with Additive Bayesian Networks

v2.5-0
GPL (>= 2)
Authors
Gilles Kratzer [aut, cre] (<https://orcid.org/0000-0002-5929-8935>), Fraser Iain Lewis [aut] (<https://orcid.org/0000-0003-4580-2712>), Reinhard Furrer [ctb] (<https://orcid.org/0000-0002-6319-2332>), Marta Pittavino [ctb] (<https://orcid.org/0000-0002-1232-1034>)
Initial release
2021-04-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.