NodeFinding {RNetica} | R Documentation |
A finding is an observed variable in a Bayesian network. The
expression NodeFinding(node) <- value
indicates that the
observed value of node should be set to value. The
function NodeFinding(node)
returns the current value.
NodeFinding(node) NodeFinding(node) <- value
node |
An active |
value |
A character or integer scalar indicating the value which was
observed or hypothesized. If a character, it should be one of the
values in |
Setting NodeFinding(node) <- value
essentially asserts that
Pr(node=value) = 1. The value may be either expressed as a
character name of one of the states, or an integer giving the index
into the state table.
Note that setting NodeFinding(node) <- value
clears
any previous findings (including virtual findings set through
NodeLikelihood()
or
EnterNegativeFinding()
), that may have been set. The
function RetractNodeFinding(node)
will clear the current
finding without setting it to a new value.
The function NodeFinding(node)
returns the currently set
finding, if there is one. It can also return one of the three special
values:
"@NEGATIVE FINDINGS"
— Negative findings have been
entered using EnterNegativeFinding()
.
"@LIKELIHOOD"
— Uncertain evidence which provides a
likelihood of various states of the node were entered using
NodeLikelihood(node)
"@NO FINDING"
— No findings, including negative
findings or likelihood findings were entered.
The expression NodeFinding(node)<-value
returns the
modified node invisibly.
The function NodeFinding(node)
returns a string which is
either the currently set finding or one of the special values
"@NO FINDING"
, "@LIKELIHOOD"
, or
"@NEGATIVE FINDINGS"
.
If SetNetworkAutoUpdate()
has been set to TRUE
,
then this function could take some time as each finding is
individually propagated. Consider wrapping multiple calls setting
NodeFinding()
in WithoutAutoUpdate(net, ...)
.
Unlike the Netica function EnterFinding_bn()
the function
"NodFinding<-"
internally calls RetractFindings
. So
there is no need to do this manually.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNodeFinding_bn(), EnterFinding_bn()
NeticaBN
, NodeBeliefs()
,
EnterNegativeFinding()
, EnterFindings()
,
RetractNodeFinding()
, NodeLikelihood()
,
EnterGaussianFinding()
, EnterIntervalFinding()
,
JointProbability()
,NodeValue()
,
MostProbableConfig()
,
FindingsProbability()
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="_")) 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]]) <- 2 ## Wrong stopifnot( !IsBeliefUpdated(irt5.x[[5]]), NodeFinding(irt5.x[[2]]) == "Wrong" ) 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. ) ## Negative finding EnterNegativeFinding(irt5.theta,c("neg1","neg2")) ## Rule out negatives. stopifnot( NodeFinding(irt5.theta) == "@NEGATIVE FINDINGS" ) ## Clearing Findings RetractNodeFinding(irt5.theta) stopifnot( NodeFinding(irt5.theta) == "@NO FINDING" ) ##Virtual findings for X3. Assume judge has said right, but judge has ## 80% accuracy rate. NodeLikelihood(irt5.x[[3]]) <- c(.8,.2) stopifnot( NodeFinding(irt5.x[[3]]) == "@LIKELIHOOD" ) DeleteNetwork(irt5) stopSession(sess)