Pnode: A Parameterized Bayesian network node

PnodeR Documentation

A Parameterized Bayesian network node

Description

A node in a parameterized Bayesian network. Note that this is a abstract class. If an object implements the Pnode protocol, then is.Pnode(node) should return TRUE.

Usage

is.Pnode(x)
as.Pnode(x)
Pnode (node, lnAlphas, betas, rules="Compensatory",
       link="partialCredit",Q=TRUE,linkScale=NULL,
       priorWeight=NULL) 

Arguments

x

A object to test to see if it is a parameterized node, or to coerce it to a parameterized node.

node

An object that will become the base of the parameterized node. This should already be a parameterized node, e.g., a NeticaNode object.

lnAlphas

A numeric vector of list of numeric vectors giving the log slope parameters. See PnodeLnAlphas for a description of this parameter. If missing, the constructor will try to create a pattern of zero values appropriate to the rules argument and the number of parent variables.

betas

A numeric vector or list of numeric vectors giving the intercept parameters. See PnodeBetas for a description of this parameter. If missing, the constructor will try to create a pattern of zero values appropriate to the rules argument and the number of parent variables.

rules

The combination rule or a list of combination rules. These should either be names of functions or function objects. See PnodeRules for a description of this argument.

link

The name of the link function or the link function itself. See PnodeLink for a description of the link function.

Q

A logical matrix or the constant TRUE (indicating that the Q-matrix should be a matrix of TRUEs). See PnodeQ for a description of this parameter.

linkScale

A numeric vector of link scale parameters or NULL if scale parameters are not needed for the chosen link function. See PnodeLinkScale for a description of this parameter.

priorWeight

A numeric vector of weights given to the prior parameter values for each row of the conditional probability table when learning from data (or a scalar if all rows have equal prior weight). See PnodePriorWeight for a description of this parameter.

Details

The Pnode class is basically a protocol which any Bayesian network node object can follow to work with the tools in the Peanut package. This is really an abstract class (in the java language, Pnode would be an interface rather than a class). In particular, a Pnode is any object for which is.Pnode returns true. The default method looks for the string "Pnode" in the class list.

Fields. A Pnode object has eight “fields” (implemented through the accessor methods), which all Pnode objects are meant to support. These correspond to the arguments of the calcDPCTable function.

The function PnodeNet returns the Pnet object which contains the nodes.

The function PnodeQ gets or sets a Q-matrix describing which parent variables are relevant for which state transitions. The default value is TRUE which indicates that all parent variables are relevant.

The function PnodePriorWeight gets or sets the prior weights associated with the node. This gives the relative weighting of the parameterized table as a prior and the observed data in the GEMfit algorithm.

The function PnodeRules gets or sets the combination rules used to combine the influence of the parent variables.

The functions PnodeLnAlphas and PnodeAlphas get or set the slope parameters associated with the combination rules. Note that in many applications, the slope parameters are constrained to be positive and maximization is done over the log of the slope parameter.

The function PnodeBetas gets or sets the difficulty (negative intercept) parameter associated with the combination rule.

The function PnodeLink gets or sets the link function used to translate between the output of the combination rule and a row of the conditional probability table.

The function PnodeLinkScale gets or sets a scale parameter associated with the link function.

There are some additional optional fields which describe metadata about the node and its states. The generic functions PnodeName(), PnodeTitle(), and PnodeDescription() access basic metadata about the node.

The generic function PnodeLabels() accesses a set of character labels associated with the node. This is useful for identifying sets of nodes (e.g., observables, high-level proficiency variables.)

The generic functions PnodeStates(), PnodeStateTitles(), and PnodeStateDescriptions() access basic information about the states of the node. The generic function PnodeNumStates() returns the number of states. The generic function PnodeStateValues() access the numeric values associated with the states.

The generic function PnodeParents(node) access the parent set of the node. Note that this function has a setter form which changes the topology of the graph. The generic functions PnodeParentNames() and PnodeNumParents() return the corresponding information about the parent variable.

Generic Functions. The importance of the Pnode object is that it supports the GEMfit method which adjust the parameters of the Pnode objects to fit a set of case data. In order to be compatible with GEMfit, the Pnode object must support three methods: PnodeParentTvals, BuildTable, and maxCPTParam.

The generic function PnodeParentTvals returns a list of effective theta values (vectors of real numbers) associated with the states of the parent variables. These are used to build the conditional probability tables.

The generic function BuildTable calls the function calcDPCTable to generate a conditional probability table for the node using the current parameter values. It also sets the node experience.

The generic function maxCPTParam calls the function mapDPC to calculate the optimal parameter values for the CPT for the node and the updates the parameter values.

Value

The function is.Pnet returns a logical scalar indicating whether or not the object claims to follow the Pnet protocol.

Author(s)

Russell Almond

References

Almond, R. G. (2015) An IRT-based Parameterization for Conditional Probability Tables. Paper presented at the 2015 Bayesian Application Workshop at the Uncertainty in Artificial Intelligence Conference.

See Also

Parameter Fields: PnodeQ, PnodePriorWeight, PnodeRules, PnodeLink, PnodeLnAlphas, PnodeAlphas, PnodeBetas, PnodeLinkScale

Metadata fields:PnodeNet, PnodeParents, PnodeParentNames, PnodeNumParents, PnodeName, PnodeTitle, PnodeDescription, PnodeLabels, PnodeStates, PnodeNumStates, PnodeStateTitles, PnodeStateDescriptions, PnodeStateValues, isPnodeContinuous, PnodeStateBounds

Generic Functions: BuildTable, PnodeParentTvals, maxCPTParam

Functions: GetPriorWeight, calcDPCTable, mapDPC

Related Classes: Pnet

Examples


 ## Not run: 

## These are the implementations of the two key generic functions in
## PNetica

BuildTable.NeticaNode <- function (node) {
  node[] <- calcDPCFrame(ParentStates(node),NodeStates(node),
                          PnodeLnAlphas(node), PnodeBetas(node),
                          PnodeRules(node),PnodeLink(node),
                          PnodeLinkScale(node),PnetQ(node),
                          PnodeParentTvals(node))
  NodeExperience(node) <- GetPriorWeight(node)
  invisible(node)
}

maxCPTParam.NeticaNode <- function (node, Mstepit=3,
                                    tol=sqrt(.Machine$double.eps)) {
  ## Get the posterior pseudo-counts by multiplying each row of the 
  ## node's CPT by its experience.
  counts <- sweep(node[[]],1,NodeExperience(node),"*")
  est <- mapDPC(counts,ParentStates(node),NodeStates(node),
                PnodeLnAlphas(node), PnodeBeta(node),
                PnodeRules(node),PnodeLink(node),
                PnodeLinkScale(node),PnodeQ(node),
                control=list(reltol=tol,maxits=Mstepit)
                )
  PnodeLnAlphas(node) <- est$lnAlphas
  PnodeBetas(node) <- est$betas
  PnodeLinkScale(node) <- est$linkScale
  invisible(node)
}




## End(Not run)


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