BuildTable: Builds the conditional probability table for a Pnode

BuildTable.NeticaNodeR Documentation

Builds the conditional probability table for a Pnode

Description

The function BuildTable calls calcDPCFrame to calculate the conditional probability for a Pnode object, and sets the current conditional probability table of node to the resulting value. It also sets the NodeExperience(node) to the current value of GetPriorWeight(node).

Usage

## S4 method for signature 'NeticaNode'
BuildTable(node)

Arguments

node

A Pnode and NeticaNode object whose table is to be built.

Details

The fields of the Pnode object correspond to the arguments of the calcDPCTable function. The output conditional probability table is then set in the node object in using the [] (Extract.NeticaNode) operator.

In addition to setting the CPT, the weight given to the nodes in the EM algorithm are set to GetPriorWeight(node), which will extract the value of PnodePriorWeight(node) or if that is null, the value of PnetPriorWeight(NodeParents(node)) and set NodeExperience(node) to the resulting value.

Value

The node argument is returned invisibly. As a side effect the conditional probability table and experience of node is modified.

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

Pnode.NeticaNode, Pnode, PnodeQ, PnodePriorWeight, PnodeRules, PnodeLink, PnodeLnAlphas, PnodeAlphas, PnodeBetas, PnodeLinkScale,GetPriorWeight, calcDPCTable, NodeExperience(node), Extract.NeticaNode ([)

Examples


sess <- NeticaSession()
startSession(sess)

## Network with two proficiency variables and observables for each
## different type of rule

binAll <- CreateNetwork("binAll", session=sess)
PnetPriorWeight(binAll) <- 11           #Give it something to see.

## Set up Proficiency Model.
thetas <- NewDiscreteNode(binAll,paste("theta",0:1,sep=""),
                          c("Low","Med","High")) # Create the variable with 3 levels
names(thetas) <- paste("theta",0:1,sep="")
NodeParents(thetas[[2]]) <- thetas[1]

for (nd in thetas) {
  NodeLevels(nd) <- effectiveThetas(NodeNumStates(nd))
  PnodeRules(nd) <- "Compensatory"
  PnodeLink(nd) <- "normalLink"
  PnodeBetas(nd) <- 0 # A numeric vector of intercept parameters
  PnodeQ(nd) <- TRUE # All parents are relevant.
  NodeSets(nd) <- c("pnodes","Proficiency") # A character vector
                   # containing the names of the node sets
}

## Standard normal prior.
PnodeAlphas(thetas[[1]]) <- numeric() # A numeric vector of (log) slope parameters
PnodeLinkScale(thetas[[1]]) <- 1 # A positive numeric value, or NULL
                                 # if the scale parameter is not used
                                 # for the link function.
## Regression with a correlation of .6
PnodeAlphas(thetas[[2]]) <- .6
PnodeLinkScale(thetas[[2]]) <- .8

BuildTable(thetas[[1]])
BuildAllTables(binAll)

DeleteNetwork(binAll)
stopSession(sess)


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