pcFactorStan (version 1.5.4)

generateCovItems: Generate paired comparison data with random correlations between items

Description

If you need access to the correlation matrix used to generate the absolute latent scores then you will need to generate them yourself. This is not difficult. See how in the example.

Usage

generateCovItems(df, numItems, th = 0.5, name, ..., scale = 1, alpha = 1)

Value

The given data.frame df with additional columns for each item. In addition, you can obtain the correlation matrix used to generate the latent worths from attr(df, "cor") and and latent worths from attr(df, "worth").

Arguments

df

a data frame with pairs of vertices given in columns pa1 and pa2, and item response data in other columns

numItems

how many items to create

th

a vector of thresholds

name

a vector of item names

...

Not used. Forces remaining arguments to be specified by name.

scale

a vector of scaling constants

alpha

a vector of item discriminations

Response model

See cmp_probs for details.

See Also

Other item generators: generateFactorItems(), generateItem(), generateSingleFactorItems()

Examples

Run this code
library(mvtnorm)
df <- twoLevelGraph(letters[1:10], 100)
df <- generateCovItems(df, 3)

# generateCovItems essentially does the same thing as:
numItems <- 3
palist <- letters[1:10]
trueCor <- cov2cor(rWishart(1, numItems, diag(numItems))[,,1])
theta <- rmvnorm(length(palist), sigma=trueCor)
dimnames(theta) <- list(palist, paste0('i', 3 + 1:numItems))
df <- generateItem(df, theta)
attr(df, "cor")

Run the code above in your browser using DataLab