HasNodeTable {RNetica}R Documentation

Tests to see if a Netica node has a conditional probability table.

Description

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).

Usage

HasNodeTable(node)

Arguments

node

An active NeticaNode whose conditional probability table is to be tested.

Details

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 NAs associated with it.

In many cases, it is the second value that is of interest, so all(HasNodeTable(node)) is often a useful idiom.

Value

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.

Note

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.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: HasNodeTable_bn()

See Also

NeticaNode, NodeParents(), NodeInputNames(), DeleteNodeTable()

Examples

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)


[Package RNetica version 0.8-4 Index]