| PnodeEvidence | R Documentation |
Inference is a Bayesian network involves setting the state of a particular node to one of its possible states, either because the state has been observed, or because it has been hypothesized. This processis is often called instantiaion. This function returns the value (state) to which the node has been instantiated, or in the setter form set it. Depending on the implementation logic, the beliefs may be immediately updated or be updated on demand.
PnodeEvidence(node)
PnodeEvidence(node) <- value
node |
A |
value |
The value that the node will be instantiated to, see details. |
Currently, Peanut supports two ways of representing nodes,
discrete and continuous (see isPnodeContinuous).
The current PNetica-package implemenation
discritizes continuous nodes, using the PnodeStateBounds
to map real numbers to states of the observables. Functions
implementing these generic functions may treat these values
differently.
The behavior depends on the class of the value argument:
The character of factor should represent a state of the node. The node will be instantiated to that state.
For continuous nodes, the node will be
instantiated to that value. For discritized continuous nodes, the
node will be instantiated to the state in which the value lies
(see PnodeStateBounds).
The value is first converted to a numeric value with units of seconds. This can be overridden in the implementation.
PnodeNumStatesThe number should represent likelihoods, and this will enter appropriate virual evidence for the node.
This will retract any existing evidence associated with the node.
The getter function PnodeEvidence will return one of the value forms
described in details. If the node is not instantiated, it will return
NULL.
The setter function PnodeEvidence<- returns the node argument
invisibly.
The current options for this function make a lot of sense with Netica. There may be other modes that are not covered for other implementations.
Russell Almond
The function PnetCompile usually needs to be run before
this function has meaning.
The functions PnodeStates and
PnodeStateBounds define the legal values for the value
argument.
## Not run:
library(PNetica) ## Need a specific implementation
sess <- NeticaSession()
startSession(sess)
irt10.base <- ReadNetworks(system.file("testnets", "IRT10.2PL.base.dne",
package="PNetica"),
session=sess)
irt10.base <- as.Pnet(irt10.base) ## Flag as Pnet, fields already set.
irt10.theta <- PnetFindNode(irt10.base,"theta")
irt10.items <- PnetPnodes(irt10.base)
## Flag items as Pnodes
for (i in 1:length(irt10.items)) {
irt10.items[[i]] <- as.Pnode(irt10.items[[i]])
}
BuildAllTables(irt10.base)
PnetCompile(irt10.base) ## Netica requirement
stopifnot (is.na(PnodeEvidence(irt10.items[[1]])))
PnodeEvidence(irt10.items[[1]]) <- "Correct"
stopifnot(PnodeEvidence(irt10.items[[1]])=="Correct")
PnodeEvidence(irt10.items[[1]]) <- NULL
stopifnot (is.na(PnodeEvidence(irt10.items[[1]])))
PnodeEvidence(irt10.items[[1]]) <- c(Correct=.6,Incorrect=.3)
stopifnot(all.equal(PnodeEvidence(irt10.items[[1]]),
c(Correct=.6,Incorrect=.3),
tol=3*sqrt(.Machine$double.eps) ))
foo <- NewContinuousNode(irt10.base,"foo")
stopifnot(is.na(PnodeEvidence(foo)))
PnodeEvidence(foo) <- 1
stopifnot(PnodeEvidence(foo)==1)
DeleteNetwork(irt10.base)
stopSession(sess)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.