Pnode | R Documentation |
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
.
is.Pnode(x)
as.Pnode(x)
Pnode (node, lnAlphas, betas, rules="Compensatory",
link="partialCredit",Q=TRUE,linkScale=NULL,
priorWeight=NULL)
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
|
lnAlphas |
A numeric vector of list of numeric vectors giving the
log slope parameters. See |
betas |
A numeric vector or list of numeric vectors giving the
intercept parameters. See |
rules |
The combination rule or a list of combination rules.
These should either be names of functions or function objects. See
|
link |
The name of the link function or the link function
itself. See |
Q |
A logical matrix or the constant |
linkScale |
A numeric vector of link scale parameters or
|
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 |
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.
The function is.Pnet
returns a logical scalar indicating
whether or not the object claims to follow the Pnet
protocol.
Russell Almond
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.
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
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.