vignettes/blog/2020-05-15-calculating-the-score-distribution-giving-ability.Rmd
2020-05-15-calculating-the-score-distribution-giving-ability.Rmd
[A muggle preface by Ivailo] As every fantasy lover knows, IRT people belong to two towers, or is it schools of magic. The little wizards and witches of one school learn to condition on their sufficient statistics before they can even fly or play quidditch, while at the other school they will integrate out anything thrown at them.
The two approaches have their subtle differences. To predict the score distribution conditional on ability, wizards at the first school apply the same powerful curse, elementary symmetric functions, that they use for all kinds of magic β from catching dragons over estimating parameters, up to item-total and item-rest regressions, to mention but a few. At the second school, computing the score distribution used to be a frustrating task until Lord and Wingersky (1984) came up with a seemingly unrelated jinx that did the trick.
In what follows, Timo explains how the two kinds of magic relate to each other.
Consider the Rasch model. Let denote the binary-coded response to item and assume that: where is person ability, the difficulty of item , and the number of correct answers. Conditional on the personβs ability and the item difficulties, the test score distribution is: where is the elementary symmetric function (esf) of order of the item parameters .
Thus, the esf arise naturally when one works with Rasch models. They
appear when we expand a linear factorization of a monic polynomial. More
specifically, since
,
we find the identity:
which is a generalization of Newtonβs
binomial theorem where
and
.
The notation can be adapted to also handle items with more than two score categories. Let denote the dummy-coded response to item ; that is, category of item is picked and zero otherwise. Let denote the number of points earned for a response in category such that . The IRT model becomes
This is a nominal response model with fixed integer item-category scores. We use the letter for the item parameters but note that we have included a dummy parameter for the lowest category. For a dichotomous item, , so that , , , and .
Using this notation, the test score distribution is: where . and esf are defined as: It follows that: where now runs over values of ; that is, from zero to the highest test score .
To illustrate, consider items with three categores each; that is, , and . Writing as short-hand for the above identity says: where Looking at the subscripts, an easy trick is: is the sum of the products of item parameters over all possible ways to obtain a score . For example, a score of 2 can be obtained by a score of 2 on item 2, a score of 1 on both items or a score of 2 on item 1. Note that, for any score that is impossible, the corresponding esf is set to zero.
The esf are sums of products and calculating these is not trivial as rounding errors tend to accumulate. Fortunately, the esf satisfy the following recursive relation: where denotes the item parameters excluding the parameters that belong to item . This recursion is the basis for a numerically stable algorithm known as the sum (or summation)-algorithm. Proposed by Andersen (1972), this algorithm is implemented in dexterβs elsym function.
We illustrate the sum-algorithm with three Rasch items ordered in an arbitrary way. We begin the recursion with the first item: and , where the superscript indicates the number of items. Then, we add the second item: Finally, we add the third item:
Now consider two ways to calculate the conditional test score distribution. First, using the identity in the previous section, we can write: This is the expression used by the p_score function in dexter.
Second, we can also write: where is short-hand for . Written in this way, the test score distribution is an esf, albeit with argument . The following R function uses this observation to calculate the score distribution:
LW = function(Pi, a)
{
first = which(a==0)
last = c(first[-1]-1,length(a))
dexter:::elsym(Pi,a,first,last)
}
The elsym function is internal to dexter, hence the three colons. This function actually implements the Lord-Wingersky algorithm, extended to polytomous items. Compared to the first solution, it has the advantage that it works for any valid and and could be used with any IRT model, not just the NRM implemented in dexter.