Biology Reference
In-Depth Information
2.3.2 Creating and Manipulating Network Structures
Consider a data set consisting of the exam scores of 88 students across five different
topics, namely, mechanics, vectors, algebra, analysis, and statistics. The scores
are bounded in the interval
[
,
]
. This data set was originally investigated by
Mardia et al. ( 1979 ) and subsequently in classic topics on graphical models such as
Whittaker ( 1990 )and Edwards ( 2000 ). A copy of the data is included in bnlearn
under the name marks .
0
100
> library(bnlearn)
> data(marks)
> str(marks)
'data.frame': 88 obs. of 5 variables:
$ MECH: num 77 63 75 55 63 53 51 59 62 64 ...
$ VECT: num 82 78 73 72 63 61 67 70 60 72 ...
$ ALG : num 67 80 71 63 65 72 65 68 58 60 ...
$ ANL : num 67 70 66 70 70 64 65 62 62 62 ...
$ STAT: num 81 81 81 68 63 73 68 56 70 45 ...
Upon loading the data, we can create an empty network with the nodes correspond-
ingtothevariablesin marks using the empty.graph function.
> ug = empty.graph(names(marks))
We can then add the arcs present in the original network from Whittaker ( 1990 )
by assigning a two-column matrix containing the labels of their end-nodes. Undi-
rected arcs are represented as their two possible orientations. For instance, the arc
MECH VECT is represented by the pair
{ MECH VECT , VECT MECH }
.
> arcs(ug, ignore.cycles = TRUE) = matrix(
+ c("MECH", "VECT", "MECH", "ALG", "VECT", "MECH",
+ "VECT", "ALG", "ALG", "MECH", "ALG", "VECT",
+ "ALG", "ANL", "ALG", "STAT", "ANL", "ALG",
+ "ANL", "STAT", "STAT", "ALG", "STAT", "ANL"),
+ ncol = 2, byrow = TRUE,
+ dimnames = list(c(), c("from", "to")))
The resulting ug object belongs to the class bn , which is the S3 class used by the
bnlearn package to manage network structures. It contains the following informa-
tion (the element name is reported in parenthesis):
learning : a list containing some information about the results of the structure
learning algorithm and its tuning parameters, including the conditional indepen-
dence tests and network scores used in the analysis. It has never changed after
the object is created.
nodes : a list containing one element per node. Each element contains the
Markov blanket, the neighborhood, the parents, and the children of that particular
node.
Search WWH ::




Custom Search