PnodeWarehouse-class | R Documentation |
"PnodeWarehouse"
A Warehouse
objects which holds and builds
Pnode
objects. In particular, its
WarehouseManifest
contains a node manifest (see
BuildNodeManifest
) which contains information about how
to build the nodes if they are not present. Note that the key of the
node manifest is the name of both the network and the node.
The PnetWarehouse
either supplies prebuilt nodes or builds them
from the instructions found in the manifest. Nodes exist inside
networks, so the key for a node is a pair (Model,NodeName)
.
Thus, two nodes in different networks can have identical names.
The function WarehouseSupply
will attempt to:
Find an existing node with name NodeName
in a network
with name Model
.
Build a new node in the named network using the metadata in the manifest.
The manifest is an object of type data.frame
where
the columns have the values show below. The key is the combination of
the “Model” and “NodeName” columns. There should be one
row with this combination of variables for each state of the
variable. In particular, the number of rows should equal the value of
the Nstates
column in the first row with that model–variable
combination. The “StateName” column should be unique for each
row.
The arguments to WarehouseData
should be a character vector of
length two, (Model,NodeName)
. It will return a
data.frame
with one row for each state of the variable.
:
A character value giving the name of the Bayesian network
to which this node belongs. Corresponds to the value of
PnodeNet
.
A character value giving the name of the node. All
rows with the same value in the model and node name columns are
assumed to reference the same node. Corresponds to the value of
PnodeName
.
:
If this is a spoke model (meant to be attached to a
hub) then this is the name of the hub model (i.e., the name of the
proficiency model corresponding to an evidence model). Corresponds to
the value of PnetHub(PnodeNet(node))
.
A character value containing a slightly longer
description of the node, unlike the name this is not generally
restricted to variable name formats. Corresponds to the value of
PnodeTitle
.
A character value describing the node, meant
for human consumption (documentation). Corresponds to the value of
PnodeDescription
.
A comma separated list of identifiers of sets which
this node belongs to. Used to identify special subsets of nodes
(e.g., high-level nodes or observeable nodes). Corresponds to the
value of PnodeLabels
.
:
A logical value. If true, the variable will be continuous, with states corresponding to ranges of values. If false, the variable will be discrete, with named states.
The number of states. This should be an integer
greater than or equal to 2. Corresponds to the value of
PnodeNumStates
.
The name of the state. This should be a string value
and it should be different for every row within the subset of rows
corresponding to a single node. Corresponds to the value of
PnodeStates
.
:
A longer name not subject to variable naming
restrictions. Corresponds to the value of
PnodeStateTitles
.
A human readable description of the state
(documentation). Corresponds to the value of
PnodeStateDescriptions
.
A real numeric value assigned to this state.
PnodeStateValues
. Note that this has different meaning
for discrete and continuous variables. For discrete variables, this
associates a numeric value with each level, which is used in
calculating the PnodeEAP
and PnodeSD
functions. In the continuous case, this value is ignored and the
midpoint between the “LowerBounds” and “UpperBounds”
are used instead.
This servers as the lower bound for each partition
of the continuous variagle. -Inf
is a legal value for the
first or last row.
This is only used for continuous variables, and the
value only is needed for one of the states. This servers as the
upper bound of range each state. Note the upper
bound needs to match the lower bounds of the next state. Inf
is a legal value for the first or last row.
A virtual Class: No objects may be created from it.
Classes can register as belonging to this abstract class. The trick
for doing this is:
setIs("NodehouseClass","PnodeWarehouse")
Currently NNWarehouse
is an example of an object
of this class.
Note that for all of these methods, the name
should be a vector
of two elements, the network name and the node name. Thus each network
defines its own namespace for variables.
signature(warehouse =
"PnodeWarehouse", name = "character")
. This finds a node with
the appropriate name in the specified network. If one does not
exist, it is created using the metadata in the manifest.
signature(warehouse =
"PnodeWarehouse", name = "character")
. This fetches the node
with the given name in the named network, or returns NULL
if it has not been built.
signature(warehouse =
"PnodeWarehouse", name = "character")
. This creates the node
using the meta-data in the Manifest.
signature(warehouse =
"PnodeWarehouse", name = "character")
. This removes the node
from the warehouse inventory.
signature(warehouse =
"PnodeWarehouse")
. This removes all nodes
from the warehouse inventory.
signature(obj =
"PnodeWarehouse")
. This returns TRUE
.
signature(warehouse =
"PnodeWarehouse")
. This returns the data frame with
instructions on how to build nodes. (see Details)
signature(warehouse =
"PnodeWarehouse", value="data.frame")
. This sets the data
frame with instructions on how to build nodes.(see Details)
signature(warehouse =
"PnodeWarehouse", name="character")
. This returns the portion
of the data frame with instructions on how to build a particular
node. This is generally one row for each state of the node.
(see Details)
The test for matching upper and lower bounds is perhaps too strict. In particular, if the upper and lower bounds mismatch by the least significant digit (e.g., a rounding difference) they will not match. This is a frequent cause of errors.
Russell Almond
Warehouse
, WarehouseManifest
,
BuildNodeManifest
Implementation in the PNetica
package:
NNWarehouse
,
MakePnode.NeticaNode
## This expression provides an example Node manifest
nodeman1 <- read.csv(system.file("auxdata", "Mini-PP-Nodes.csv",
package="Peanut"),
stringsAsFactors=FALSE)
## Not run:
library(PNetica) ## Requires PNetica
sess <- NeticaSession()
startSession(sess)
## This expression provides an example Node manifest
netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv",
package="PNetica"),
row.names=1,stringsAsFactors=FALSE)
## Network and node warehouse, to create networks and nodes on demand.
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name")
Nodehouse <- NNWarehouse(manifest=nodeman1,
key=c("Model","NodeName"),
session=sess)
CM <- WarehouseSupply(Nethouse,"miniPP_CM")
WarehouseSupply(Nethouse,"PPdurAttEM")
WarehouseData(Nodehouse,c("miniPP_CM","Physics"))
WarehouseSupply(Nodehouse,c("miniPP_CM","Physics"))
WarehouseData(Nodehouse,c("PPdurAttEM","Attempts"))
WarehouseSupply(Nodehouse,c("PPdurAttEM","Attempts"))
WarehouseData(Nodehouse,c("PPdurAttEM","Duration"))
WarehouseSupply(Nodehouse,c("PPdurAttEM","Duration"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.