Pnode.NeticaNode | R Documentation |
"NeticaNode"
as a "Pnode"
The PNetica
package supplies the needed methods so that the
RNetica::NeticaNode
object is an instance of the
Peanut::Pnode
object. As a Pnode is nominally
parameterized, the are given the special label “pnode” to
indicate that this note has parametric information.
See NeticaNode
for a description of the Netica class.
With these methods, NeticaNode
now extends
Pnode
.
All reference classes extend and inherit methods from
"envRefClass"
.
All methods are implementations of generic functions in the
Peanut
package.
The following methods are related to the basic node structures and
they should operate on all NeticaNode
objects,
whether they are Pnode
s or not.
signature(net = NeticaNode)
:
Returns the NeticaBN
(also
Pnet
) which contains the node.
signature(net = NeticaNode)
:
Gets the name of the node.
signature(net = NeticaNode)
:
Sets the name of the node.
signature(net = NeticaNode)
:
Gets the title of the node.
signature(net = NeticaNode)
:
Sets the title of the node.
signature(net =
NeticaNode)
: Gets the description of the node.
signature(net = NeticaNode)
:
Gets the conditional probability table for a node..
signature(net = NeticaNode)
:
Sets the conditional probability table for a node.
(signature(net =
NeticaNode)
: Sets the description of the node.
signature(net = NeticaNode)
:
Gets the vector of names of the sets to which this node belongs.
signature(net =
NeticaNode)
: Sets the vector of sets to which the node belongs.
signature(net = NeticaNode)
:
Returns true or false, depending on whether or not node is continuous.
Documentation for other methods of the Pnode
generic functions for NeticaNode
objects can be
found in the documentation objects Pnode.Properties and
Pnode.States.
The “Pnode properies”,
lnAlphas
, betas
, Q
, rules
, link
,
linkScale
, and priorWeight
are stored in user fields
(NodeUserObj
) of the Netica node. A
NeticaNode
object which has those fields behaves
as a Pnode
and is suitable for the use with
Peanut
. The function
Pnode
will add default values for these fields if they are not
set.
To mark a node as a Pnode
, it is added to the
node set “pnode”. The is.Pnode
function checks for this method.
Russell Almond
Other methods of this class Pnode.States
,
Pnode.Properties
.
Base class: NeticaNode
.
Mixin class: Pnode
.
Generic functions from Peanut
package:
Pnode
,
PnodeNet
,
PnodeName
,
PnodeTitle
,
PnodeDescription
,
PnodeLabels
,
PnodeNumParents
,
PnodeParentNames
,
PnodeParents
,
PnodeProbs
,
as.Pnode
,
is.Pnode
,
isPnodeContinuous
.
sess <- NeticaSession()
startSession(sess)
nsnet <- CreateNetwork("NodeSetExample", session=sess)
Ability <- NewDiscreteNode(nsnet,"Ability",c("High","Med","Low"))
EssayScore <- NewDiscreteNode(nsnet,"EssayScore",paste("level",5:0,sep="_"))
Duration <- NewContinuousNode(nsnet,"Duration")
## Pnode, is.Pnode, as.Pnode
stopifnot(!is.Pnode(EssayScore),!is.Pnode(Duration))
EssayScore <- Pnode(EssayScore)
Duration <- as.Pnode(Duration)
stopifnot(is.Pnode(EssayScore),is.Pnode(Duration))
## PnodeNet
stopifnot(PnodeNet(Ability)==nsnet)
## PnodeName, PnodeTitle, PnodeDescription
PnodeTitle(Ability) <- "Student Ability"
PnodeDescription(Ability) <-
"Students who have more ability will have more success on the exam."
stopifnot(PnodeTitle(Ability) == "Student Ability",
PnodeDescription(Ability) ==
"Students who have more ability will have more success on the exam."
)
## PnodeLabels
stopifnot(
length(PnodeLabels(Ability)) == 0L ## Nothing set yet
)
PnodeLabels(Ability) <- "ReportingVariable"
stopifnot(
PnodeLabels(Ability) == "ReportingVariable"
)
PnodeLabels(EssayScore) <- c("Observable",PnodeLabels(EssayScore))
stopifnot(
!is.na(match("Observable",PnodeLabels(EssayScore)))
)
## Make EssayScore a reporting variable, too
PnodeLabels(EssayScore) <- c("ReportingVariable",PnodeLabels(EssayScore))
stopifnot(
setequal(PnodeLabels(EssayScore),c("Observable","ReportingVariable","pnodes"))
)
## Clear out the node set
PnodeLabels(Ability) <- character()
stopifnot(
length(PnodeLabels(Ability)) == 0L
)
## PnodeNumParents, PnodeParents
stopifnot(PnodeNumParents(Ability)==0L, PnodeParents(Ability)==list())
PnodeParents(EssayScore) <- list(Ability)
stopifnot(PnodeNumParents(EssayScore)==1L,
PnodeParents(EssayScore)[[1]]==Ability,
PnodeParentNames(EssayScore)=="Ability")
DeleteNetwork(nsnet)
## Node Probs
abc <- CreateNetwork("ABC", session=sess)
A <- NewDiscreteNode(abc,"A",c("A1","A2","A3","A4"))
B <- NewDiscreteNode(abc,"B",c("B1","B2","B3"))
C <- NewDiscreteNode(abc,"C",c("C1","C2"))
PnodeParents(A) <- list()
PnodeParents(B) <- list(A)
PnodeParents(C) <- list(A,B)
PnodeProbs(A)<-c(.1,.2,.3,.4)
PnodeProbs(B) <- normalize(matrix(1:12,4,3))
PnodeProbs(C) <- normalize(array(1:24,c(A=4,B=3,C=2)))
Aprobs <- PnodeProbs(A)
Bprobs <- PnodeProbs(B)
Cprobs <- PnodeProbs(C)
stopifnot(
CPTtools::is.CPA(Aprobs),
CPTtools::is.CPA(Bprobs),
CPTtools::is.CPA(Cprobs)
)
DeleteNetwork(abc)
stopSession(sess)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.