generateCovItems: Generate paired comparison data with random correlations...

View source: R/generate.R

generateCovItemsR Documentation

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)

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

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").

Response model

See cmp_probs for details.

See Also

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

Examples

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")


pcFactorStan documentation built on Sept. 14, 2023, 1:09 a.m.