PnetCompile {Peanut} | R Documentation |
This function requests that the Bayes net be compiled—transformed so that inference can be carried out.
PnetCompile(net)
net |
A |
Many Bayesian network algorithm have two phases. The graph is built as an acyclic directed graph. Before inference is carried out, the graph is transformed into a structure called a Junction Tree, Tree of Cliques or Markov Tree (Almond, 1995).
This function requests that implementation specific processing, particularly, building the appropriate Markov Tree, be done for the net, so that it can be placed in inference mode instead of editing mode.
The compile net
argument should be returned.
It should be harmless to call this function on a net which is already compiled.
Russell Almond
Almond, R. G. (1995). Graphical Belief Models. Chapman and Hall.
The following functions will likely return errors if the net
is
not compiled:
PnodeEvidence
, calcStat
,
PnodeMargin
, PnodeEAP
,
PnodeSD
, PnodeMedian
,
PnodeMode
.
## Not run: library(PNetica) ## Need a specific implementation sess <- NeticaSession() startSession(sess) irt10.base <- ReadNetworks(paste(library(help="PNetica")$path, "testnets","IRT10.2PL.base.dne", sep=.Platform$file.sep),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]]) } ## Make some statistics marginTheta <- Statistic("PnodeMargin","theta","Pr(theta)") meanTheta <- Statistic("PnodeEAP","theta","EAP(theta)") sdTheta <- Statistic("PnodeSD","theta","SD(theta)") medianTheta <- Statistic("PnodeMedian","theta","Median(theta)") modeTheta <- Statistic("PnodeMedian","theta","Mode(theta)") BuildAllTables(irt10.base) PnetCompile(irt10.base) ## Netica requirement calcStat(marginTheta,irt10.base) calcStat(meanTheta,irt10.base) calcStat(sdTheta,irt10.base) calcStat(medianTheta,irt10.base) calcStat(modeTheta,irt10.base) PnodeEvidence(irt10.items[[1]]) <- "Correct" calcStat(marginTheta,irt10.base) calcStat(meanTheta,irt10.base) calcStat(sdTheta,irt10.base) calcStat(medianTheta,irt10.base) calcStat(modeTheta,irt10.base) DeleteNetwork(irt10.base) stopSession(sess) ## End(Not run)