PnodeBetas: Access the combination function slope parameters for a Pnode

PnodeBetasR Documentation

Access the combination function slope parameters 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 expression PnodeAlphas(node) accesses the intercept parameters associated with the combination function PnodeRules(node).

Usage

PnodeBetas(node)
PnodeBetas(node) <- value

Arguments

node

A Pnode object.

value

A numeric vector of intercept parameters or a list of such vectors (see details). The length of the vector depends on the combination rules (see PnodeRules). 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. The compensatory function is a useful model for explaining the roles of the slope parameters, beta. Let theta_{i,j} be the effective theta value for the jth parent variable on the ith row of the effective theta table, and let beta_{j} be the corresponding slope parameter. Then the effective theta for that row is:

Z(theta_{i}) = (alpha_1theta_{i,1}+\ldots+alpha_Jtheta_{J,1})/C - beta ,

where C=\sqrt(J) is a variance stabilization constant and alphas are derived from PnodeAlphas. The functions Conjunctive and Disjunctive are similar replacing the sum with a min or max respectively.

In general, when the rule is one of Compensatory, Conjunctive, or Disjunctive, the the value of PnodeBetas(node) should be a scalar.

The rules OffsetConjunctive, and OffsetDisjunctive, work somewhat differently, in that they assume there is a single slope and multiple intercepts. Thus, the OffsetConjunctive has equation:

Z(theta_{i}) = alpha min(theta_{i,1}-beta_1, \ldots,theta_{J,1}-beta_{J}) .

In this case the assumption is that PnodeAlphas(node) will be a scalar and PnodeBetas(node) will be a vector of length equal to the number of parents. As a special case, if it is a vector of length 1, then a model with a common slope is used. This looks the same in calcDPCTable but has a different implication in mapDPC where the parameters are constrained to be the same.

When node has more than two states, there is a a different combination function for each transition. (Note that calcDPCTable assumes that the states are ordered from highest to lowest, and the transition functions represent transition to the corresponding state, in order.) There are always one fewer transitions than there states. The meaning of the transition functions is determined by the the value of PnodeLink, however, both the partialCredit and the gradedResponse link functions allow for different intercepts for the different steps, and the gradedResponse link function requires that the intercepts be in decreasing order (highest first). To get a different intercept for each transition, the value of PnodeBetas(node) should be a list.

If the value of PnodeRules(node) is a list, then a different combination rule is used for each transition. Potentially, this could require a different number of intercept parameters for each row. Also, if the value of PnodeQ(node) is not a matrix of all TRUE values, then the effective number of parents for each state transition could be different. In this case, if the OffsetConjunctive or OffsetDisjunctive rule is used the value of PnodeBetas(node) should be a list of vectors of different lengths (corresponding to the number of true entries in each row of PnodeQ(node)).

Value

A list of numeric vectors giving the intercepts for the combination function of each state transition. The vectors may be of different lengths depending on the value of PnodeRules(node) and PnodeQ(node). If the intercepts are the same for all transitions then a single numeric vector instead of a list is returned.

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

Note

The functions PnodeLnBetas and PnodeLnBetas<- 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, PnodeRules, PnodeLink, PnodeLnAlphas, 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="gradedResponse")
PnodePriorWeight(partial3) <- 10
BuildTable(partial3)


## increasing intercepts for both transitions
PnodeBetas(partial3) <- list(FullCredit=1,PartialCredit=0)
BuildTable(partial3)

stopifnot(
   all(abs(do.call("c",PnodeBetas(partial3)) -c(1,0) ) <.0001)
)


## increasing intercepts for both transitions
PnodeLink(partial3) <- "partialCredit"
## Full Credit is still rarer than partial credit under the partial
## credit model
PnodeBetas(partial3) <- list(FullCredit=0,PartialCredit=0)
BuildTable(partial3)


stopifnot(
   all(abs(do.call("c",PnodeBetas(partial3)) -c(0,0) ) <.0001)
)

## Switch to rules which use multiple intercepts
PnodeRules(partial3) <- "OffsetConjunctive"

## Make Skill 1 more important for the transition to ParitalCredit
## And Skill 2 more important for the transition to FullCredit
PnodeLnAlphas(partial3) <- 0
PnodeBetas(partial3) <- list(FullCredit=c(-.25,.25),
                                PartialCredit=c(.25,-.25))
BuildTable(partial3)


## Set up so that first skill only needed for first transition, second
## skill for second transition; Adjust betas to match
PnodeQ(partial3) <- matrix(c(TRUE,TRUE,
                             TRUE,FALSE), 2,2, byrow=TRUE)
PnodeBetas(partial3) <- list(FullCredit=c(-.25,.25),
                                PartialCredit=0)
BuildTable(partial3)


## Can also do this with special parameter values
PnodeQ(partial3) <- TRUE
PnodeBetas(partial3) <- list(FullCredit=c(-.25,.25),
                                PartialCredit=c(0,Inf))
BuildTable(partial3)


DeleteNetwork(tNet)
stopSession(sess)

## End(Not run)

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