sim_gpcm: Simulate data for the gpcm model

View source: R/sim.R

sim_gpcmR Documentation

Simulate data for the gpcm model

Description

This function returns an integer matrix of simulated responses under given item and person parameters.

Usage

sim_gpcm(thres, alpha, theta)

Arguments

thres

A numeric matrix which contains threshold parameters for each item. The first row may contain zeroes only (as in PP_gpcm); otherwise a row of zeroes is added.

alpha

A numeric vector, which contains the slope parameters - one parameter per item is expected.

theta

A numeric vector which contains person parameters.

Details

alpha may also be a single number, which is then used for every item. A person with NA as person parameter gets a row of NA.

Value

An integer matrix with one row per person and one column per item.

See Also

sim_4pl, sim_mixed, PP_gpcm

Examples

set.seed(1750)
# thresholds of six items with three categories (the row of zeroes is optional)
thres <- rbind(0, matrix(c(-2, -1.23, 1.11, 3.48, 1, 2, -1, -0.2, 0.5, 1.3, -0.8, 1.5),
                         nrow = 2))
x <- sim_gpcm(thres = thres, alpha = c(0.5, 1, 1.5, 1.1, 1, 0.98), theta = rnorm(100))
head(x)

# the last two items get a fourth category
thres4 <- rbind(thres, c(NA, NA, NA, NA, 1.7, 1))
apply(sim_gpcm(thres = thres4, alpha = 1, theta = rnorm(100)), 2, max)


PP documentation built on Oct. 15, 2026, 1:06 a.m.