PnodeLabels | R Documentation |
A label is a character identifier associated with a node which provides information about its role in the models. This function returns or sets the labels associated with a node.
PnodeLabels(node)
PnodeLabels(node) <- value
node |
A |
value |
A character vector containing the names of the labels that node should be associated with. These names should follow the variable naming rules. |
Netica node sets are a collection of string labels that can be
associated with various nodes in a network. These have proved to be
very useful on writing code as often it is useful to perform some
operation on only a certain kind of nodes. One
purpose of node sets is to label a set of nodes that play a similar
role in the model. For example, "ReportingVariable"
or
"Observable"
.
The PnodeLabels
function is an attempt to generalize that
mechanism. The expression PnodeLabels(node)
returns the
labels currently associated with node, thus provides a general
mechanism for identifying the roles that a node might play.
The expression PnodeLabels(node)<-value
removes any
labels previously associated with node and adds the new labels
named in value. The elements of value need not
correspond to existing labels, new node sets will be created for
new values. (Warning: this implies that if the name of the node set
is spelled incorrectly in one of the calls, this will create a new
node set. For example, "Observable"
and "Observables"
would be two distinct labels.)
Two labels have special meaning in the Peanut package. The function
BuildAllTables(net)
rebuilds the tables for nodes
which are labeled “pnode” (i.e., parameterized nodes). The
function GEMfit
attempts to fit the parameters for nodes
labeled “pnodes”, and associates values in the cases argument
with the nodes labeled “onodes”.
A character vector giving the names of the labels node is associated with. The setter form returns node.
Russell Almond
Pnode
, BuildAllTables
,
GEMfit
, PnetPnodes
## Not run:
library(PNetica)##Requires PNetica
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="_"))
stopifnot(
length(PnodeLabels(Ability)) == 0L ## Nothing set yet
)
PnodeLabels(Ability) <- "ReportingVariable"
stopifnot(
PnodeLabels(Ability) == "ReportingVariable"
)
PnodeLabels(EssayScore) <- "Observable"
stopifnot(
PnodeLabels(EssayScore) == "Observable"
)
## Make EssayScore a reporting variable, too
PnodeLabels(EssayScore) <- c("ReportingVariable",PnodeLabels(EssayScore))
stopifnot(
setequal(PnodeLabels(EssayScore),c("Observable","ReportingVariable"))
)
## Clear out the node set
PnodeLabels(Ability) <- character()
stopifnot(
length(PnodeLabels(Ability)) == 0L
)
DeleteNetwork(nsnet)
stopSession(sess)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.