PnodeWarehouse-class: Class '"PnodeWarehouse"'

PnodeWarehouse-classR Documentation

Class "PnodeWarehouse"

Description

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.

Details

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:

  1. Find an existing node with name NodeName in a network with name Model.

  2. 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.

Node-level Key Fields

:

Model

A character value giving the name of the Bayesian network to which this node belongs. Corresponds to the value of PnodeNet.

NodeName

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.

Node-level Fields

:

ModelHub

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)).

NodeTitle

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.

NodeDescription

A character value describing the node, meant for human consumption (documentation). Corresponds to the value of PnodeDescription.

NodeLabels

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.

State-level Key Fields

:

Continuous

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.

Nstates

The number of states. This should be an integer greater than or equal to 2. Corresponds to the value of PnodeNumStates.

StateName

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.

State-level Fields

:

StateTitle

A longer name not subject to variable naming restrictions. Corresponds to the value of PnodeStateTitles.

StateDescription

A human readable description of the state (documentation). Corresponds to the value of PnodeStateDescriptions.

StateValue

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.

LowerBound

This servers as the lower bound for each partition of the continuous variagle. -Inf is a legal value for the first or last row.

UpperBound

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.

Objects from the Class

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.

Methods

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.

WarehouseSupply

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.

WarehouseFetch

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.

WarehouseMake

signature(warehouse = "PnodeWarehouse", name = "character"). This creates the node using the meta-data in the Manifest.

WarehouseFree

signature(warehouse = "PnodeWarehouse", name = "character"). This removes the node from the warehouse inventory.

ClearWarehouse

signature(warehouse = "PnodeWarehouse"). This removes all nodes from the warehouse inventory.

is.PnodeWarehouse

signature(obj = "PnodeWarehouse"). This returns TRUE.

WarehouseManifest

signature(warehouse = "PnodeWarehouse"). This returns the data frame with instructions on how to build nodes. (see Details)

WarehouseManifest<-

signature(warehouse = "PnodeWarehouse", value="data.frame"). This sets the data frame with instructions on how to build nodes.(see Details)

WarehouseData

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)

Note

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.

Author(s)

Russell Almond

See Also

Warehouse, WarehouseManifest, BuildNodeManifest

Implementation in the PNetica package: NNWarehouse, MakePnode.NeticaNode

Examples

## 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)

ralmond/Peanut documentation built on Sept. 19, 2023, 8:27 a.m.