NodeBeliefs {RNetica} | R Documentation |
After a network is compiled, marginal probabilities are available at each of the nodes. Entering findings changes these to probabilities associated with the conditions represented by the findings. This function returns the marginal probabilities for the variable node conditioned on the findings.
The function IsBeliefUpdated(node)
checks to see whether
the value of findings have been propagated to node yet.
NodeBeliefs(node) IsBeliefUpdated(node)
node |
An active |
The function NodeBeliefs()
is not available until the network
has been compiled (CompileNetwork()
). Asking for
the marginal values before the network is compiled will throw an
error.
When findings are entered, the marginal probabilities (or beliefs)
associated with node will change. The process of propagating
the findings from an evidence node to a query node is known as
updating. Depending on the size and topology of the network, the
updating process might take some time. To speed up operations, the
AutoUpdate flag on the network can be cleared using
SetNetworkAutoUpdate()
.
If the AutoUpdate flag is not set for the network, then calling
NodeBeliefs(node)
could trigger an update cycle and hence take
some time. The function IsBeliefUpdated(code)
tests to see
whether the marginal probability for node currently
incorporates all of the findings. It returns true if it does and
false if not.
The function NodeBeliefs(node)
returns a vector of
probabilities of length NodeNumStates(node)
. The names
of the result are the state names.
The function IsBeliefUpdated(node)
returns TRUE
if
calling NodeBeliefs(node)
will not result in probabilities
being updated.
I tend to avoid the term "belief" because I've spent so much time writing about Dempster–Shafer models (belief functions). Netica uses it to mean the marginal probability for a node given all of the entered evidence and conditional probability tables of all of the nodes.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNodeBeliefs_bn(), IsBeliefUpdated_bn()
NeticaNode
, NeticaBN
,
NodeProbs()
,
NodeFinding()
, JointProbability()
,
MostProbableConfig()
, FindingsProbability()
NodeExpectedValue()
, NodeValue()
,
CalcNodeValue()
,
sess <- NeticaSession() startSession(sess) irt5 <- ReadNetworks(file.path(library(help="RNetica")$path, "sampleNets","IRT5.dne"), session=sess) irt5.theta <- NetworkFindNode(irt5,"Theta") irt5.x <- NetworkFindNode(irt5,paste("Item",1:5,sep="_")) ## Not run: NodeBeliefs(irt5.theta) ## This call will produce an errors because irt5 ## is not compiled ## End(Not run) stopifnot( !IsBeliefUpdated(irt5.theta) ) CompileNetwork(irt5) ## Ready to enter findings stopifnot ( ## irt5 is parent node, so marginal beliefs and conditional ## probability table should be the same. sum(abs(NodeBeliefs(irt5.theta) - NodeProbs(irt5.theta))) < 1e-6 ) ## Marginal probability for Node 5 irt5.x5.init <- NodeBeliefs(irt5.x[[5]]) SetNetworkAutoUpdate(irt5,TRUE) ## Automatic updating NodeFinding(irt5.x[[1]]) <- "Right" stopifnot( IsBeliefUpdated(irt5.x[[5]]) ) irt5.x5.time1 <- NodeBeliefs(irt5.x[[5]]) stopifnot ( sum(abs(irt5.x5.init-irt5.x5.time1)) > 1e-6 ) SetNetworkAutoUpdate(irt5,FALSE) ## Automatic updating NodeFinding(irt5.x[[2]]) <- "Right" stopifnot( !IsBeliefUpdated(irt5.x[[5]]) ) irt5.x5.time2 <- NodeBeliefs(irt5.x[[5]]) stopifnot ( sum(abs(irt5.x5.time2-irt5.x5.time1)) > 1e-6, IsBeliefUpdated(irt5.x[[5]]) ## Now we have updated it. ) DeleteNetwork(irt5) stopSession(sess)