PnetPriorWeight {Peanut} | R Documentation |
The EM learning algorithm GEMfit
uses the built-in EM
learning of the Bayes net to build expected count tables for each
Pnode
. The expected count tables are a weighted average
of the case data and the prior from the parameterized table. This
gives the weight, in number of cases, given to the prior.
PnetPriorWeight(net) PnetPriorWeight(net) <- value PnodePriorWeight(node) PnodePriorWeight(node) <- value GetPriorWeight(node)
net |
A |
node |
A |
value |
A nonnegative numeric vector giving the prior weight.
This should either be a scalar or a vector with length equal to the
number of rows of the conditional probability table. In the case of
|
Suppose that value of the node and all of its parents are fully observed, and let X_{1i},…,X_{ki} be the observed counts for row i, and let p_{1i},…,p_{ki} be the conditional probabilities for row i. Then the posterior probabilities for row i can be found by normalizing X_{1i}+w_ip_{1i},…,X_{ki}+w_ip_{ki}. In the EM algorithm, the table is not fully observed but the expected value of X_{1i},…,X_{ki} is used instead.
This function gets or sets the vector w_1,…,w_I (where
I is the number of rows in the conditional probability table).
If value
is a scalar this is the same as giving all w_i
the same value.
The function PnodePriorWeight
gets or sets the prior weight for
a given node. The function PnetPriorWeight
gets or sets the
default weight for all nodes (a property of the network). Unless all
nodes have the name number of parents with the same number of states,
this should be a scalar. The expression GetPriorWeight(node)
gets the prior weight for the node or if that is null, it gets the
default prior weight from the net (using the function
PnodeNet
.
A numeric vector or scalar giving the weight or NULL
if the
default network weight is to be used.
The GEMfit
algorithm will update the prior weight for
each node based on how much information is available for each row.
Thus, even if the values are initially the same for each row, after
calling GEMfit
they usually will be different for each
row.
The functions PnetPriorWeight
and PnodePriorWeight
are
abstract generic functions, and they needs specific implementations. See the
PNetica-package
for an example.
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.
Pnet
, Pnode
, PnodeNet
,
BuildTable
, GEMfit
## Not run: library(PNetica) ## Implementation of Peanut protocol sess <- NeticaSession() startSession(sess) ## Create network structure using RNetica calls IRT10.2PL <- CreateNetwork("IRT10_2PL",session=sess) theta <- NewDiscreteNode(IRT10.2PL,"theta", c("VH","High","Mid","Low","VL")) PnodeStateValues(theta) <- effectiveThetas(PnodeNumStates(theta)) PnodeProbs(theta) <- rep(1/PnodeNumStates(theta),PnodeNumStates(theta)) J <- 10 ## Number of items items <- NewDiscreteNode(IRT10.2PL,paste("item",1:J,sep=""), c("Correct","Incorrect")) for (j in 1:J) { PnodeParents(items[[j]]) <- list(theta) PnodeStateValues(items[[j]]) <- c(1,0) PnodeLabels(items[[j]]) <- c("observables") } ## Convert into a Pnet IRT10.2PL <- as.Pnet(IRT10.2PL) PnetPriorWeight(IRT10.2PL) <- 10 ## Convert nodes to Pnodes for (j in 1:J) { items[[j]] <- Pnode(items[[j]]) } PnodePriorWeight(items[[2]]) <- 5 ## 5 states in parent, so 5 rows PnodePriorWeight(items[[3]]) <- c(10,7,5,7,10) stopifnot( abs(PnetPriorWeight(IRT10.2PL)-10) < .0001, is.null(PnodePriorWeight(items[[1]])), abs(GetPriorWeight(items[[1]])-10) < .0001, abs(GetPriorWeight(items[[2]])-5) < .0001, any(abs(GetPriorWeight(items[[3]])-c(10,7,5,7,10)) < .0001) ) PnetPriorWeight(IRT10.2PL) <- 15 stopifnot( abs(PnetPriorWeight(IRT10.2PL)-15) < .0001, is.null(PnodePriorWeight(items[[1]])), abs(GetPriorWeight(items[[1]])-15) < .0001, abs(GetPriorWeight(items[[2]])-5) < .0001, any(abs(GetPriorWeight(items[[3]])-c(10,7,5,7,10)) < .0001) ) DeleteNetwork(IRT10.2PL) stopSession(sess) ## End(Not run)