CalcNodeState {RNetica} | R Documentation |
The expression CalcNodeState(node)
will return the state of
node
if it is known deterministically, and NA
if the exact
value is not known. The expression CalcNodeValue(node)
will
return the numeric value of the node (e.g., the value set with
NodeLevels(node)
.
CalcNodeState(node) CalcNodeValue(node)
node |
An active |
According to the Netica manual, the way that the value of node
could be known absolutely is if it was set directly a call to
NodeFinding(node)
or NodeValue(node)
, or
if the value can be calculated exactly through logical conditional
probability tables (i.e., ones with just 0's and 1's) or formula (see
NodeEquation()
.
The expression CalcNodeState(node)
is appropriate when
node
is discrete, or has been discretized through a call to
NodeLevels(node)
. Otherwise it will generate an error.
The expression CalcNodeValue(node)
is appropriate when
node
is continuous, or the states have been assigned numeric
values through a call to NodeLevels(node)
. Otherwise it
will generate an error.
The expression CalcNodeState(node)
will return a
character scalar giving the name of the current state of node
if it can be determined, otherwise it will return NA
.
The expression CalcNodeValue(node)
will return a
numeric scalar giving the name of the current value of node
if it can be determined, otherwise it will return NA
.
This function is not behaving at all like what I expected. In
particular, it is returning NA
in many cases where I expect it
to produce a value. I've queried Norsys about this, but use with caution
until I get a clarification.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: CalcNodeState_bn(), CalcNodeValue_bn()
NodeFinding()
, NodeLevels()
,
NodeValue()
, IsNodeDeterministic()
,
NodeEquation()
,is.continuous()
,
NodeExpectedValue()
sess <- NeticaSession() startSession(sess) lights <- CreateNetwork("lights", session=sess) switchs <- NewDiscreteNode(lights,paste("Switch",1:2,sep=""),c("Up","Down")) bulb <- NewDiscreteNode(lights,"Bulb",c("On","Off")) ## Set up a two-way switch (Xor) network AddLink(switchs[[1]],bulb) AddLink(switchs[[2]],bulb) ## This sets up a logical table, so that the light is on iff ## both switches are in the same orientation. bulb[] <-"Off" bulb[Switch1="Up",Switch2="Up"]<-"On" bulb[Switch1="Down",Switch2="Down"]<-"On" switchs[[1]][] <- .5 switchs[[2]][] <- .5 CompileNetwork(lights) ## Bulb is a deterministic node. stopifnot(IsNodeDeterministic(bulb)) ## value of node is unknown, returns NA stopifnot(is.na(CalcNodeState(bulb))) NodeFinding(switchs[[1]]) <- "Up" NodeFinding(switchs[[2]]) <- "Up" stopifnot(CalcNodeState(switchs[[1]])=="Up") stopifnot(CalcNodeState(bulb)=="On") NodeLevels(bulb) <-c(1,0) NodeLevels(switchs[[1]]) <-c(1,0) NodeLevels(switchs[[2]]) <-c(1,0) ## I expect both of these to return 1, but they return NA CalcNodeValue(bulb) CalcNodeValue(switchs[[1]]) DeleteNetwork(lights) stopSession(sess)