# generateItem

##### Generate pairwise comparison data for one or more items given absolute latent scores

To add a single item, `theta`

should be a vector of latent
scores. To add multiple items at a time, `theta`

should be a
matrix with one item in each column. Item names can be given as
the colnames of `theta`

.

The interpretation of `theta`

depends on the context where the
data were generated. For example, in chess, `theta`

represents
unobserved chess skill that is partially revealed by match
outcomes.

The graph can be regarded as undirected, but data are generated
relative to the order of vertices in the row. Vertices do not
commute. For example, a `-1`

for vertices ‘a’ and
‘b’ is the same as `1`

for vertices ‘b’ and
‘a’.

##### Usage

`generateItem(df, theta, th = 0.5, scale = 1, name)`

##### Arguments

- df
a data frame with pairs of vertices given in columns

`pa1`

and`pa2`

, and item response data in other columns- theta
a vector or matrix of absolute latent scores. See details below.

- th
a vector of thresholds

- scale
the scaling constant

- name
a vector of item names

##### Details

The pairwise comparison item response model has thresholds and a scale parameter similar to the partial credit model (Masters, 1982). The model is cumbersome to describe in traditional mathematical notation, but the R code is fairly straightforward,

softmax <- function(y) exp(y) / sum(exp(y))cmp_probs <- function(scale, pa1, pa2, thRaw) { th <- cumsum(thRaw) diff <- scale * (pa2 - pa1) unsummed <- c(0, c(diff + rev(th)), c(diff - th), use.names = FALSE) softmax(cumsum(unsummed)) }

The function `cmp_probs`

takes a `scale`

constant, the
latent scores for two objects `pa1`

and `pa2`

, and a
vector of thresholds `thRaw`

. The thresholds are parameterized
as the difference from the previous threshold. For example,
thresholds c(0.5, 0.5) are not at the same location but are at
locations c(0.5, 1.0). Thresholds are symmetric. If there is one
thresholds then the model admits three possible response outcomes
(e.g. win, tie, and lose). Responses are always stored centered
with zero representing a tie. Therefore, it is necessary to add one
plus the number of thresholds to response data to index into the
vector returned by `cmp_probs`

. For example, if our response
data (-1, 0, 1) has one threshold then we would add 2 (1 + 1
threshold) to obtain the indices (1, 2, 3).

Use `itemModelExplorer`

to explore the item model. In
this shiny app, the *discrimination* parameter does what is
customary in item response models. However, it is not difficult to
show that discrimination is a function of thresholds and
scale. That is, discrimination is not an independent parameter and
cannot be estimated. In pairwise comparison models, discrimination
and measurement error are confounded.

##### References

Masters, G. N. (1982). A Rasch model for partial credit scoring. Psychometrika, 47, 149<U+2013>174. doi: 10.1007/BF02296272

##### See Also

Other item generators: `generateCovItems`

,
`generateFactorItems`

##### Examples

```
# NOT RUN {
df <- roundRobinGraph(letters[1:5], 40)
df <- generateItem(df)
# }
```

*Documentation reproduced from package pcFactorStan, version 0.11, License: GPL (>= 3)*