sim_data: Data simulation function

View source: R/sim_data.R

sim_dataR Documentation

Data simulation function

Description

Simulate item response data based on IRT Models. Models currently supported are 1-3 PL, GPCM, Rasch Testlet, and a mix of these models. Use '?MIRTutils-package' for more details, such as the context of the current package.

Usage

sim_data(thetas, SA_parm = NULL, Cluster_parm = NULL, Dv = 1)

Arguments

thetas

When tests contain only standalone items:

  • a vector of theta values where the length of thetas equals to the number of examinees.

When tests contain cluster items:

  • In general: a matrix or dataframe of theta values when tests contain cluster item, where the first column is theta for the overall dimension and the rest of columns are thetas for the specific (nuisance) dimensions.

  • Special case: when simulating for only one examinee and the test has cluster items, it can also be a vector of theta values, where the first element is the overall dimension theta and the rest are thetas for the specific (nuisance) dimensions.

SA_parm

A matrix or dataframe of item parameters for standalone items, where columns are a (slope), b1, b2, ..., b_k (difficulty or step difficulty), g (guessing), ItemID, and AssertionID. Columns must follow the above order. See example_SA_parm for an example. Use ?example_SA_parm for detailed column descriptions

Cluster_parm

a matrix or dataframe of item parameters for cluster items, where columns are a (slope), b (difficulty), cluster variance, cluster position, ItemID, and AssertionID. Columns must follow the above order. See example_Cluster_parm for an example. Use ?example_Cluster_parm for detailed column descriptions

Dv

scaling factor for IRT model (usually 1 or 1.7)

Value

A matrix of item response data. One examinee per row. One assertion per column. First SA data, then Cluster data.

Note

If the test does not have SA items or Cluster items, use default (NULL) for the corresponding parameter argument

Author(s)

Zhongtian Lin <lzt713@gmail.com)

Examples

data(example_SA_parm)
data(example_Cluster_parm)
sigma <- diag(c(1, sqrt(unique(example_Cluster_parm$cluster_var))))
mu <- rep(0, nrow(sigma))
thetas <- MASS::mvrnorm(7,mu,sigma)
thetas[,1] <- seq(-3,3,1) #overall dimension theta values
itmDat <- sim_data(thetas = thetas, SA_parm = example_SA_parm, Cluster_parm = example_Cluster_parm)


woshikaqia/MIRTutils documentation built on Aug. 21, 2024, 4:30 p.m.