HasNodeTable {RNetica} | R Documentation |
This function tests to see if a conditional probability table has been
assigned to node
. The function returns two values, the first
tests for existence of the table, the second tests for a complete
table (no NAs).
HasNodeTable(node)
node |
An active |
This function returns two values. The first is true or false
according to whether the conditional probability table has been
established, that is has NodeProbs()
been set. The
second value tests to see whether the conditional probability table is
complete, that is, does it have any NA
s associated with it.
In many cases, it is the second value that is of interest, so
all(HasNodeTable(node))
is often a useful idiom.
A logical vector with two elements. The first states whether or not the node has any of its conditional probabilities set. The second tests whether or not the table has been completely specified.
Generating incomplete tables is pretty hard to do in RNetica, a row
must be deliberately set to NA
. However, a network read in
from a file might have incomplete tables.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: HasNodeTable_bn()
NeticaNode
, NodeParents()
,
NodeInputNames()
, DeleteNodeTable()
sess <- NeticaSession() startSession(sess) ab1 <- CreateNetwork("AB1", session=sess) A <- NewDiscreteNode(ab1,"A",c("A1","A2","A3")) B <- NewDiscreteNode(ab1,"B",c("B1","B2")) AddLink(A,B) ##Nodes start undefined. stopifnot( HasNodeTable(A)==c(FALSE,FALSE) ) NodeProbs(A) <- c(0,1,0) stopifnot( HasNodeTable(A)==c(TRUE,TRUE) ) for (node in NetworkAllNodes(ab1)) { if (!all(HasNodeTable(node))) { cat("Node ", toString(node), " still needs a conditional probability table.\n") } } DeleteNetwork(ab1) stopSession(sess)