NodeValue {RNetica} | R Documentation |
This enters a numeric value (finding) for a continuous node or a discrete node which has numeric values assigned to the states.
NodeValue(node) NodeValue(node) <- value
node |
An active |
value |
A real value for the node. |
The behavior of the levels depends on whether the node is discrete
(is.discrete(node)==TRUE
) or continuous
(is.discrete(node)==FALSE
).
Discrete. For if node is a discrete node, then the
states of node must have been assigned numeric values with
NodeLevels(node)
in order for NodeValue()
to make sense. If all states have not been assigned values,
NodeValue()
will generate an error.
If the value of the node is determined, either because the value of
the node has been set with NodeFinding()
or because the
value can be determined exactly from the value of other nodes in the
network (through logical probability distributions or formulae), then
NodeValue(node)
will return the value associated with the
state of the node. Otherwise, it will return NA
.
The expression NodeValue(node)<-value
, can be used to
set the value of node to the state associate with the numerical
value. If value does not correspond to one of the node
levels, this will generate an error.
Continuous. For continuous nodes,
NodeFinding(node)
returns the value associated with the
node, either set with a previous call to
NodeValue(node)<-value
, or which can be determined
through formulae.
The expression NodeValue(node) <- value
will set the
value (the equivalent of a finding for a discrete node) to
value. If node has been associated with cut
scores through a previous call to NodeLevels(node)
, then
this will also associate a finding with the node.
The function NodeValue(node)
returns the value of node
if that can be determined (see Details) or NA
if it cannot. It
may generate an error if node
is discrete and has not had
numeric values associated with its states.
The expression NodeValue(node) <- value
returns
node
.
Netica manual is not particularly clear on how continuous nodes are handled.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: GetNodeValueEntered_bn(), EnterNodeValue_bn()
NodeFinding()
, NodeLevels()
,
EnterNegativeFinding()
, EnterFindings()
,
RetractNodeFinding()
, NodeStates()
,
NodeEquation()
,is.continuous()
,
NodeExpectedValue()
, NodeBeliefs()
sess <- NeticaSession() startSession(sess) aNet <- CreateNetwork("aNet", session=sess) dTheta <- NewDiscreteNode(aNet, "ThetaD", c("neg2","neg1","zero","pos1","pos2")) NodeLevels(dTheta) <- c(-2,-1,0,1,2) NodeFinding(dTheta) <- "pos1" stopifnot(NodeValue(dTheta)==1) NodeValue(dTheta) <- 0 stopifnot(NodeFinding(dTheta)=="zero") ## Not run: ## The error handling seems broken under Windows. cat("This next statement generates an error as 1/2 is not a legal value.") stopifnot(class(try(NodeValue(dTheta) <- 1/2)) == "try-error") ## End(Not run) cTheta <- NewContinuousNode(aNet, "ThetaC") NodeLevels(cTheta) <- qnorm(c(.001,1/5,2/5,2/5,4/5,.999)) ## Netica doesn't allow - sign or decimal point in state name, need to ## jump through a few hoops here. midpoints <- round(qnorm((1:5)/5-.1),2) NodeStates(cTheta) <- sub(".","o", paste(ifelse(midpoints<0,"n","p"),abs(midpoints),sep=""), fixed=TRUE) NodeValue(cTheta) <- -1 stopifnot(NodeFinding(cTheta)=="n1o28") NodeFinding(cTheta) <- "p0" ## No value associated with this finding. stopifnot(is.na(NodeValue(cTheta))) DeleteNetwork(aNet) stopSession(sess)