NodeLikelihood {RNetica} | R Documentation |
The findings associated with a node can be expressed as the probability of the evidence occurring in each of the states of the node. This is the likelihood associated with the node. This function retrieves or sets the likelihood.
NodeLikelihood(node) NodeLikelihood(node) <- value
node |
An active |
value |
A numeric vector of length |
This function retrieves or sets virtual evidence associated with each node. Suppose that some set of evidence e is observed. The each of the values in the likelihood represents the conditional probability Pr(e|node==state). Note that the likelihood can be thought of as the message that a new node child which was a child of node with no other parents would pass to node if its value was set.
As the likelihood values are conditional probabilities, they do not need to add to 1, although they are still restricted to the range [0,1]. Also, at least one value must be non-zero (this represents an impossible case) or Netica will generpate an error.
Entering findings through NodeFinding(node) <-
state
sets a special likelihood. In this case, the likelihood value
corresponding to state will be one, and all others will be zero.
Similarly, the expression
EnterNegativeFinding(node,statelist)
sets a
special likelihood with 0's corresponding to the states in
statelist and 1's elsewhere.
Setting the likelihood calls RetractNodeFinding()
,
clearing any previous finding, negative finding or likelihood.
The function NodeLikelihood(node)
returns a vector of
likelihoods of length NodeNumStates(node)
. The names
of the result are the state names.
The expression NodeLikelihood(node)<-value
returns
the modified node invisibly.
The documentation for the Netica function MostProbableConfig_bn()
states that likelihood findings are not
properly taken into account in MostProbableConfig()
.
Some quick tests indicate that it is doing something sensible, but
more extensive testing and/or clarification is needed.
The documentation for the Netica function
FindingsProbability_bn() also provides a warning about likelihood
evidence. The function FindingsProbability(net)
still
gives a result, but it is the normalization constant for the network,
and not necessarily a probability.
If SetNetworkAutoUpdate()
has been set to TRUE
,
then setting the likelihood could take some time as each finding is
individually propagated. Consider wrapping multiple calls setting
NodeLikelihood()
in WithoutAutoUpdate(net, ...)
.
Unlike the Netica function EnterNodeLikelihood_bn()
the function
"NodeLikelihood<-"
internally calls RetractFindings
. So
there is no need to do this manually.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNodeLikelihood_bn(), EnterNodeLikelihood_bn()
NeticaBN
, NodeBeliefs()
,
EnterNegativeFinding()
,
RetractNodeFinding()
, NodeFinding()
JointProbability()
,
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 ## Simple finding NodeFinding(irt5.x[[1]])<-"Wrong" stopifnot( NodeLikelihood(irt5.x[[1]]) == c(0,1) ) ## Negative finding EnterNegativeFinding(irt5.theta,c("neg1","neg2")) ## Rule out negatives. stopifnot( NodeLikelihood(irt5.x[[1]]) == c(0,1), NodeLikelihood(irt5.theta) == c(1,1,1,0,0), NodeFinding(irt5.theta) == "@NEGATIVE FINDINGS" ) ## Clearing Findings RetractNodeFinding(irt5.theta) stopifnot( NodeLikelihood(irt5.theta) == c(1,1,1,1,1) ) ##Virtual findings for X3. Assume judge has said right, but judge has ## 80% accuracy rate. NodeLikelihood(irt5.x[[3]]) <- c(.8,.2) stopifnot( sum(abs(NodeLikelihood(irt5.x[[3]]) - c(.8,.2))) < 1e-6, NodeFinding(irt5.x[[3]]) == "@LIKELIHOOD" ) ## Add in virtual likelihood from a second judge NodeLikelihood(irt5.x[[3]]) <- NodeLikelihood(irt5.x[[3]]) * c(.75,.25) stopifnot( sum(abs(NodeLikelihood(irt5.x[[3]]) - c(.6,.05))) < 1e-6 ) DeleteNetwork(irt5) stopSession(sess)