Learn R Programming

rpf (version 0.28)

rpf.sample: Randomly sample response patterns given a list of items

Description

Returns a random sample of response patterns given a list of item models and parameters.

Usage

rpf.sample(theta, items, params, design, prefix = "i", mean = NULL,
  cov = NULL)

Arguments

theta
either a vector (for 1 dimension) or a matrix (for >1 dimension) of person abilities or the number of response patterns to generate randomly
items
a list of item models
params
a list or matrix of item parameters. If omitted, random item parameters are generated for each item model.
design
a matrix assigning person abilities to item factors
prefix
Column names are taken from param or items. If no column names are available, some will be generated using the given prefix.
mean
mean vector of latent distribution (optional)
cov
covariance matrix of latent distribution (optional)

Value

  • Returns a data frame of response patterns

Details

The design matrix can accomodate more person abilities than item dimension. Refer to Cai (2010) for design matrix examples.

TODO: Add restrictions to design matrix to match restrictions imposed by Cai (2010).

References

Cai, L. (2010). A two-tier full-information item factor analysis model with applications. Psychometrika, 75, 581-612.

See Also

sample

Examples

Run this code
# 1 dimensional items
i1 <- rpf.drm()
i1.p <- rpf.rparam(i1)
i2 <- rpf.nrm(outcomes=3)
i2.p <- rpf.rparam(i2)
rpf.sample(5, list(i1,i2), list(i1.p, i2.p))

# multidimensional items
numItems <- 4
items <- vector("list", numItems)
correct <- vector("list", numItems)

i1 <- rpf.drm(factors=2)
i2 <- rpf.drm(factors=1, multidimensional=TRUE)

for (ix in 1:(numItems-1)) {
  items[[ix]] <- i1
  correct[[ix]] <- rpf.rparam(i1)
}
items[[4]] <- i2
correct[[4]] <- rpf.rparam(i2)

design <- matrix(c(1, 1, 1, 1,
                   2, 2, 3, NA), nrow=2, byrow=TRUE)
rpf.sample(10, items, correct, design)

Run the code above in your browser using DataLab