PnodePostWeight | R Documentation |
Before running GEMfit
, nodes are given a
prior weight (PnodePriorWeight
) indicating how much
weight should be given to the prior distribution. After running
the calcExpTables
step, there will be a posterior weight
giving the total weight of the prior plus data.
PnodePostWeight(node)
node |
A |
Let s
be a configuration of the parent variables, which
corresponds to a row of the CPT of node
(PnodeProbs(node)
). Let \bold{p}_s = (p_{s,1},
\ldots, p_{s,K})
be the corresponding row of the conditional
probability table and let n_s
be the corresponding prior weight
(an element of codePnodePriorWeight(node)). The corresponding
row of the effective Dirichlet prior for that row is \alpha_s =
(\alpha_{s,1}, \ldots, \alpha_{s,K})
, where
\alpha_{s,1}=p_{s,1}n_s
. Note that the matrix \bold{P}
and
the vector \bold{n}
(stacking the conditional probability
vectors and the prior weights) are sufficient statistics for the
conditional probability distribution of node
.
The function calcExpTables
does the E-step (and some of
the M-step) of the GEMfit
algorithm. Its output is new
values for the sufficient statistics, \tilde{\bold{P}}
and
\tilde{\bold{n}}
. At this point, the function
PnodeProbs
should return \tilde{\bold{P}}
(although possibly as an array rather than a matrix) and
PnodePostWeight(node)
returns \tilde{\bold{n}}
.
Although the PnodePostWeight(node)
is used in the next step,
maxAllTableParams
, it is not retained for the next round
of the GEMfit
algorithm, instead the
PnodePriorWeight(node)
is used for the next time
calcExpTables
is run.
Often, PnodePriorWeight(node)
is set to a scalar,
indicating that every row should be given the same weight, e.g.,
10
. In this case, PnodePostWeight(node)
will usually be
vector valued as different numbers of data points correspond to each
row of the CPT. Furthermore, unless the parent variables are fully
observed, the PnodePostWeight(node)
are unlikely to be integer
valued even if the prior weights are integers. However, the posterior
weights should always be at least as large as the prior weights.
A vector of numeric values corresponding to the rows of the CPT of
node
. An error may be produced if calcExpTables
has not yet been run.
Russell Almond
Almond, R. G. (2015) An IRT-based parameterization for conditional probability tables. In Agosta, J. M. and Carvalho, R. N. (Eds.) Proceedings of the Twelfth UAI Bayesian Modeling Application Workshop (BMAW 2015). CEUR Workshop Proceedings, 1565, 14–23. http://ceur-ws.org/Vol-1565/bmaw2015_paper4.pdf.
PnodePriorWeight
, GEMfit
,
calcExpTables
, maxAllTableParams
## Not run:
library(PNetica) ## Need a specific implementation
sess <- NeticaSession()
startSession(sess)
irt10.base <- ReadNetworks(system.file("testnets", "IRT10.2PL.base.dne",
package="PNetica"),
session=sess)
irt10.base <- as.Pnet(irt10.base) ## Flag as Pnet, fields already set.
irt10.theta <- PnetFindNode(irt10.base,"theta")
irt10.items <- PnetPnodes(irt10.base)
## Flag items as Pnodes
for (i in 1:length(irt10.items)) {
irt10.items[[i]] <- as.Pnode(irt10.items[[i]])
## Add node to list of observed nodes
PnodeLabels(irt10.items[[1]]) <-
union(PnodeLabels(irt10.items[[1]]),"onodes")
}
PnetCompile(irt10.base) ## Netica requirement
casepath <- system.file("testdat", "IRT10.2PL.200.items.cas", package="PNetica")
item1 <- irt10.items[[1]]
priorcounts <- sweep(PnodeProbs(item1),1,GetPriorWeight(item1),"*")
calcExpTables(irt10.base,casepath)
postcounts <- sweep(PnodeProbs(item1),1,PnodePostWeight(item1),"*")
## Posterior row sums should always be larger.
stopifnot(
all(apply(postcounts,1,sum) >= apply(priorcounts,1,sum))
)
DeleteNetwork(irt10.base)
stopSession(sess)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.