PnodeRules: Accesses the combination rules for a Pnode

PnodeRulesR Documentation

Accesses the combination rules for a Pnode

Description

In constructing a conditional probability table using the discrete partial credit framework (see calcDPCTable), the effective thetas for each parent variable are combined into a single effect theta using a combination rule. The function PnodeRules accesses the combination function associated with a Pnode.

Usage

PnodeRules(node)
PnodeRules(node) <- value

Arguments

node

A Pnode object.

value

The name of a combination function, the combination function or a list of names or combination functions (see details). If a list, it should have length one less than the number of states in node.

Details

Following the framework laid out in Almond (2015), the function calcDPCTable calculates a conditional probability table using the following steps:

  1. Each set of parent variable states is converted to a set of continuous values called effective thetas (see PnodeParentTvals). These are built into an array, eTheta, using expand.grid where each column represents a parent variable and each row a possible configuration of parents.

  2. For each state of the node except the last, the set of effective thetas is filtered using the local Q-matrix, PnodeQ(node) = Q. Thus, the actual effect thetas for state s is eTheta[,Q[s,]].

  3. For each state of the node except the last, the corresponding rule is applied to the effective thetas to get a single effective theta for each row of the table. This step is essentially calls the expression: do.call(rules[[s]], list(eThetas[,Q[s,]]), PnodeAlphas(node)[[s]], PnodeBetas(node)[[s]]).

  4. The resulting set of effective thetas are converted into conditional probabilities using the link function PnodeLink(node).

The function PnodeRules accesses the function used in step 3. It should should be the name of a function or a function with the general signature of a combination function described in Compensatory. Predefined choices include Compensatory, Conjunctive, Disjunctive, OffsetConjunctive, and OffsetDisjunctive. Note that the first three choices expect that there will be multiple alphas, one for each parent, and the latter two expect that there will be multiple betas, one for each beta. The value of PnodeAlphas and PnodeBetas should be set to match.

If the value of PnodeLink is partialCredit, then the link function can be different for state of the node. (If it is gradedResponse then the curves need to be parallel and it should be the same.) If the value of PnodeRules(node) is a list (note: list, not character vector), then a different rule is used for each state transition. The function calcDPCTable assumes the states are ordered from highest to lowest, and no transition is needed into the lowest state.

Value

A character scalar giving the name of a combination function or a combination function object, or a list of the same. If a list, its length is one less than the number of states of node.

Note that the setter form may destructively modify the Pnode object (this depends on the implementation).

Note

The functions PnodeRules and PnodeRules<- are abstract generic functions, and need specific implementations. See the PNetica-package for an example.

The values of PnodeLink, PnodeRules, PnodeQ, PnodeParentTvals, PnodeLnAlphas, and PnodeBetas all need to be consistent for this to work correctly, but no error checking is done on any of the setter methods.

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.

Almond, R.G., Mislevy, R.J., Steinberg, L.S., Williamson, D.M. and Yan, D. (2015) Bayesian Networks in Educational Assessment. Springer. Chapter 8.

See Also

Pnode, PnodeQ, PnodeLink, PnodeLnAlphas, PnodeBetas, BuildTable, PnodeParentTvals, maxCPTParam, calcDPCTable, mapDPC, Compensatory, OffsetConjunctive

Examples


## Not run: 
library(PNetica) ## Requires implementation
sess <- NeticaSession()
startSession(sess)

tNet <- CreateNetwork("TestNet",session=sess)

theta1 <- NewDiscreteNode(tNet,"theta1",
                         c("VH","High","Mid","Low","VL"))
PnodeStateValues(theta1) <- effectiveThetas(PnodeNumStates(theta1))
PnodeProbs(theta1) <- rep(1/PnodeNumStates(theta1),PnodeNumStates(theta1))
theta2 <- NewDiscreteNode(tNet,"theta2",
                         c("VH","High","Mid","Low","VL"))
PnodeStateValues(theta2) <- effectiveThetas(PnodeNumStates(theta2))
PnodeProbs(theta2) <- rep(1/PnodeNumStates(theta2),PnodeNumStates(theta2))

partial3 <- NewDiscreteNode(tNet,"partial3",
                            c("FullCredit","PartialCredit","NoCredit"))
PnodeParents(partial3) <- list(theta1,theta2)

## Usual way to set rules is in constructor
partial3 <- Pnode(partial3,rules="Compensatory", link="partialCredit")
PnodePriorWeight(partial3) <- 10
BuildTable(partial3)

stopifnot(
   PnodeRules(partial3) == "Compensatory"
)

## Use different rules for different levels
## Compensatory for 2nd transition, conjunctive for 1st
## Note:  Position is important, names are just for documentation. 
PnodeRules(partial3) <- list(FullCredit="Compensatory",
                             PartialCredit="Conjunctive")
BuildTable(partial3)

DeleteNetwork(tNet)

## End(Not run)

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