PnodeStateValues {Peanut}R Documentation

Accesses the numeric values associated with the state of a parameterized node.

Description

The values are a numeric value (on a standard normal scale) associated with the levels of a discrete Pnode. This function fetches or retrieves the numeric values for the states of node.

Note that the default method for the funciton PnodeParentTvals uses the values of PnodeStateValues on the parent nodes.

Usage

PnodeStateValues(node)
PnodeStateValues(node) <- value

Arguments

node

A Pnode whose levels are to be accessed.

value

A numeric vector of values which should have length length(PnodeStates(node)).

Details

Note that the first time the PnodeStateValues() are set, the entire vector must be set. After that point individual values may be changed.

Value

A numeric vector of length length(Pnodetates()), with names equal to the state names. If levels have not be set, NAs will be returned.

Author(s)

Russell Almond

See Also

Pnode, PnodeStates(), PnodeName(), PnodeStateTitles(), PnodeParentTvals()

Examples

## Not run: 
library(PNetica)##Requires PNetica
sess <- NeticaSession()
startSession(sess)
lnet <- CreateNetwork("LeveledNet", session=sess)

vnode <- NewDiscreteNode(lnet,"volt_switch",c("Off","Reverse","Forwards"))
stopifnot(
  length(PnodeStateValues(vnode))==3,
  names(PnodeStateValues(vnode)) == NodeStates(vnode),
  all(is.na(PnodeStateValues(vnode)))
)

## Don't run this until the levels for vnode have been set,
## it will generate an error.
try(PnodeStateValues(vnode)[2] <- 0)

PnodeStateValues(vnode) <- 1:3
stopifnot(
  length(PnodeStateValues(vnode))==3,
  names(PnodeStateValues(vnode)) == PnodeStates(vnode),
  PnodeStateValues(vnode)[2]==2
)

PnodeStateValues(vnode)["Reverse"] <- -2

DeleteNetwork(lnet)
stopSession(sess)

## End(Not run)

[Package Peanut version 0.6-1 Index]