PnodeLink | R Documentation |
In constructing a conditional probability table using the discrete
partial credit framework (see calcDPCTable
),
the effective thetas for each row of the table is converted into a
vector of probabilities using the link function. The function
PnodeLink
accesses the link function associated with a
Pnode
.
PnodeLink(node)
PnodeLink(node) <- value
node |
A |
value |
The name of a link function or function object which can serve as the link function. |
Following the framework laid out in Almond (2015), the function
calcDPCTable
calculates a conditional
probability table using the following steps:
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.
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,]]
.
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]])
.
The resulting set of effective thetas are converted into conditional probabilities using the link function.
A link function is a function of three arguments. The first is a
matrix of effective theta values with number of rows equal to the
number of rows of the conditional probability matrix and number of
columns equal to the number of states of node
minus one
(ordered from highest to lowest). The second is an optional link
scale, the third is a set of names for the states which is used to
give column names to the output matrix. The second and third both
default to NULL
.
Currently two link functions are partialCredit
and gradedResponse
. Note that the function
gradedResponse
assumes that the effective thetas in each row
are in increasing order. This puts certain restrictions on the
parameter values. Generally, this can only be guaranteed if each state
of the variable uses the same combination rules (see
PnodeRules(node)
), slope parameters (see
PnodeAlphas(node)
) and Q-matrix (see
PnodeQ(node)
). Also, the intercepts (see
PnodeBetas(node)
) should be in decreasing order. The
partialCredit
model has fewer restrictions.
The value of PnodeLinkScale(node)
is fed to the link
function. Currently, this is unused; but the DiBello-normal model
(see calcDNTable
) uses it. So the link scale
parameter is for
future expansion.
A character scalar giving the name of a combination function or a combination function object.
Note that the setter form may destructively modify the Pnode object (this depends on the implementation).
The functions PnodeLink
and PnodeLink<-
are abstract
generic functions, and need specific implementations. See the
PNetica-package
for an example.
A third normal link function, which would use the scale parameter, is planned but not yet implemented.
Russell Almond
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.
Pnode
, PnodeQ
, PnodeRules
PnodeLinkScale
, PnodeLnAlphas
,
PnodeBetas
, BuildTable
,
PnodeParentTvals
, maxCPTParam
calcDPCTable
, mapDPC
Compensatory
,
OffsetConjunctive
## 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 link is in constructor
partial3 <- Pnode(partial3,rules="Compensatory", link="gradedResponse")
PnodePriorWeight(partial3) <- 10
PnodeBetas(partial3) <- list(FullCredit=1,PartialCredit=0)
BuildTable(partial3)
## 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)
## Can use different slopes with partial credit
## Make Skill 1 more important for the transition to ParitalCredit
## And Skill 2 more important for the transition to FullCredit
PnodeLnAlphas(partial3) <- list(FullCredit=c(-.25,.25),
PartialCredit=c(.25,-.25))
BuildTable(partial3)
## Can also use Q-matrix to select skills
## Set up so that first skill only needed for first transition, second
## skill for second transition; Adjust alphas to match
PnodeQ(partial3) <- matrix(c(TRUE,TRUE,
TRUE,FALSE), 2,2, byrow=TRUE)
PnodeLnAlphas(partial3) <- list(FullCredit=c(-.25,.25),
PartialCredit=0)
BuildTable(partial3)
DeleteNetwork(tNet)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.