NodeProbs {RNetica} | R Documentation |
A complete Bayesian networks defines a conditional probability distribution for a node given its parents. If all the nodes are discrete, this comes in the form of a conditional probability table a multidimensional array whose first several dimensions follow the parent variable and whose last dimension follows the child variable.
NodeProbs(node) NodeProbs(node) <- value
node |
An active, discrete |
value |
The new conditional probability table. See details for the expected dimensions. |
Let node
be the node of interest and parent1
,
parent2
, ..., parentp
, where p is
the number of parents. Let pdim =
sapply(NodeParents(node),
NodeNumStates)
be a vector with the number of states for each parent.
A parent configuration is defined by assigning each of the parent
values to one of its possible states. Each parent configuration
defines a (conditional) probability distribution over the possible
states of node.
The result of NodeProbs(node)
will be an array with dimensions
c(pdim, NodeNumStates(node))
. The first p
dimensions will be named according to the
NodeInputNames(node)
or the
NodeName(parent)
if the input names are not set. The
last dimension will be named according to the node itself. The
dimnames
for the resulting array will correspond to the state
names.
The setter form expects an array of the same dimensions as an argument, although it does not need to have the dimnames set.
A conditional probability array of class
c("CPA","array")
. See details.
Note that the expression node[...]
also accesses the partial or
complete node conditional probability table. See
Extract.NeticaNode
.
All of this assumes that these are discrete nodes, that is
is.discrete(node)
will return true for both node
and all of the parents. It is unknown what Netica does is this is not
right.
This doc file is still pretty lame. Probably need to redo output as a CPT class.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNodeProbs_bn(), SetNodeProbs_bn()
Extract.NeticaNode
,
NeticaNode
, NodeParents()
,
NodeInputNames()
, NodeStates()
,
CPA
, CPF
, normalize()
sess <- NeticaSession() startSession(sess) abc <- CreateNetwork("ABC", session=sess) A <- NewDiscreteNode(abc,"A",c("A1","A2","A3","A4")) B <- NewDiscreteNode(abc,"B",c("B1","B2","B3")) C <- NewDiscreteNode(abc,"C",c("C1","C2")) AddLink(A,B) AddLink(A,C) AddLink(B,C) NodeProbs(A)<-c(.1,.2,.3,.4) NodeProbs(B) <- normalize(matrix(1:12,4,3)) NodeProbs(C) <- normalize(array(1:24,c(4,3,2))) Aprobs <- NodeProbs(A) Bprobs <- NodeProbs(B) Cprobs <- NodeProbs(C) stopifnot( is.CPA(Aprobs), is.CPA(Bprobs), is.CPA(Cprobs) ) DeleteNetwork(abc) stopSession(sess)