is.NodeRelated {RNetica} | R Documentation |
Netica
network.
The function is.NodeRelated()
tests to see if relation
holds between node1
and node2
. The function
GetRelatedNodes
creates a list of all nodes that satisfy the
relation
with any node in nodelist
.
is.NodeRelated(node1, node2, relation = "connected") GetRelatedNodes(nodelist, relation = "connected")
node1 |
An active |
node2 |
Another active |
relation |
A character scalar which should be one of the values: "parents", "children", "ancestors", "descendents" [sic], "connected", "markov_blanket", or "d_connected". Singular forms and modifiers are also allowed, see details. |
nodelist |
A list of active |
These functions are useful for testing the topology of a network.
Each of the functions offers a measure related to the network. The
is.NodeRelated()
form tests the relationship between
node1
and node2
. The function GetRelatedNodes()
returns a list of any nodes for which the relationship holds with any
of the elements of nodelist
. The plural and singular forms of
the relationships can be used with both functions.
"parent"
, "parents"
. True if node1
is a parent
of node2
, or returns a list of parents of the nodes in
nodelist
.
"ancestor"
, "ancestors"
. True if there is a directed
(parent to child) path from node1
to node2
, or returns a
list of ancestors of the nodes in nodelist
.
"child"
, "children"
. True if node1
is a child
of node2
, or returns a list of children of the nodes in
nodelist
.
"descendent"
, "descedents"
[This is the spelling used by
Netica]. True if there is a directed
(parent to child) path from node2
to node1
, or returns a
list of descedants of the nodes in nodelist
.
"connected"
. True if there is a chain (unordered path) from
node1
to node2
, or returns a list of all nodes connected
to any of the nodes in nodelist
.
"markov_blanket"
. The Markov blanket of nodeset
is the
a set of nodes that renders the nodes in nodeset
conditionally
independent of the remaining nodes given the ones in the blanket. The
simple form returns true if node2
is in the Markov blanket of
node1
.
"d_connected"
. The rules for d-connection are somewhat complex
(see Pearl, 1988), but basically node1
and node2
are
d-connected if they are not independent given the current findings.
The function returns true if node1
and node2
are
d-connected or a list of all nodes that are d-connected to the nodes
in nodelist
.
In addition, the relation can be modified in the
GetRelatedNodes()
form by adding one or more modifiers to the
main relation separated by commas. The two that are useful in RNetica
are:
"include_evidence_nodes"
. For the "markov_boundary"
and
"d_connected"
relations indicates whether nodes with findings
should be included in the result (they would normally not be
included in the result).
"exclude_self"
. For the "ancestors"
,
"descendents"
, "connected"
, and "d_connected"
relations, the elements of nodelist
are not initially added to
the result.
For is.NodeRelated()
TRUE
or FALSE
, or NA
if one of the input nodes was not active.
For GetNodeRelated()
a list of NeticaNode
objects which
have the target relationship with one of the nodes in
nodelist
. There may be duplicates in this list.
GetRelatedNodes()
uses GetRelatedNodesMult_bn()
, not
GetRelatedNode_bn()
, but that should not present any serious
issues. Also, it always passes an empty list for the
related_nodes
arguments. Consequently, the "append"
,
"union"
, "intersection"
, and "subtract"
options
don't make much sense. This is only a minor limitation as R provides
similar functions.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: IsNodeRelated_bn(), GetRelatedNodes_bn(), GetRelatedNodesMult_bn()
Pearl, J. (1988). Probabilistic Reasoning in Intelligent Systems. Morgan–Kaufmann.
NeticaNode
, NodeParents()
,
NodeChildren()
, AddLink()
sess <- NeticaSession() startSession(sess) testnet <- CreateNetwork("ABCDEFG", session=sess) ### A D ### \ / \ ### C F - G ### / \ / ### B E A <- NewDiscreteNode(testnet,"A") B <- NewDiscreteNode(testnet,"B") C <- NewDiscreteNode(testnet,"C") D <- NewDiscreteNode(testnet,"D") E <- NewDiscreteNode(testnet,"E") F <- NewDiscreteNode(testnet,"F") G <- NewDiscreteNode(testnet,"G") AddLink(A,C) AddLink(B,C) AddLink(C,D) AddLink(C,E) AddLink(D,F) AddLink(E,F) AddLink(F,G) stopifnot( is.NodeRelated(A,C,"parent"), is.NodeRelated(D,C,"child"), is.NodeRelated(C,G,"ancestor"), is.NodeRelated(E,C,"descendent"), is.NodeRelated(A,B), ## Same as connected is.NodeRelated(D,E,"markov_blanket"), !is.NodeRelated(A,B,"d_connected"), ## No common ancestor is.NodeRelated(D,E,"d_connected") ## Common ancestor ) stopifnot( setequal(GetRelatedNodes(F,"parents"),list(D,E)), setequal(GetRelatedNodes(C,"children"),list(D,E)), setequal(GetRelatedNodes(D,"descendents"),list(D,F,G)), setequal(GetRelatedNodes(E,"ancestors"),list(E,C,A,B)), setequal(GetRelatedNodes(E,"ancestors,exclude_self"), GetRelatedNodes(D,"ancestors,exclude_self")), setequal(GetRelatedNodes(A),list(A,B,C,D,E,F,G)), ##All nodes connected setequal(GetRelatedNodes(D,"markov_blanket"),list(C,E,F)), setequal(GetRelatedNodes(A,"d_connected"),list(A,C,D,E,F,G)) ) DeleteNetwork(testnet) stopSession(sess)