NodeFinding {RNetica}R Documentation

Returns of sets the observed value associated with a Netica node.

Description

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.

Usage

NodeFinding(node)
NodeFinding(node) <- value

Arguments

node

An active NeticaNode whose value was observed or hypothesized.

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 NodeStates(node). If an integer it should be a value between 1 and NodeNumStates(node) inclusive.

Details

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:

  1. "@NEGATIVE FINDINGS" — Negative findings have been entered using EnterNegativeFinding().

  2. "@LIKELIHOOD" — Uncertain evidence which provides a likelihood of various states of the node were entered using NodeLikelihood(node)

  3. "@NO FINDING" — No findings, including negative findings or likelihood findings were entered.

Value

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

Note

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.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: GetNodeFinding_bn(), EnterFinding_bn()

See Also

NeticaBN, NodeBeliefs(), EnterNegativeFinding(), EnterFindings(), RetractNodeFinding(), NodeLikelihood(), EnterGaussianFinding(), EnterIntervalFinding(), JointProbability(),NodeValue(), MostProbableConfig(), FindingsProbability()

Examples

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)


[Package RNetica version 0.8-2 Index]