| Type: | Package |
| Title: | Simulate Cognitive Diagnostic Model ('CDM') Data |
| Version: | 0.1.2 |
| Description: | Provides efficient R and 'C++' routines to simulate cognitive diagnostic model data for Deterministic Input, Noisy "And" Gate ('DINA') and reduced Reparameterized Unified Model ('rRUM') from Culpepper and Hudson (2017) <doi:10.1177/0146621617707511>, Culpepper (2015) <doi:10.3102/1076998615595403>, and de la Torre (2009) <doi:10.3102/1076998607309474>. |
| URL: | https://tmsalab.github.io/simcdm/,https://github.com/tmsalab/simcdm |
| BugReports: | https://github.com/tmsalab/simcdm/issues |
| License: | GPL-2 |GPL-3 [expanded from: GPL (≥ 2)] |
| Depends: | R (≥ 4.1.0) |
| Imports: | Rcpp (≥ 1.0.11) |
| LinkingTo: | Rcpp, RcppArmadillo (≥ 0.12.6.6.0) |
| Suggests: | testthat, covr, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| RoxygenNote: | 7.2.3 |
| Encoding: | UTF-8 |
| NeedsCompilation: | yes |
| Packaged: | 2023-11-29 07:19:26 UTC; ronin |
| Author: | James Joseph Balamuta |
| Maintainer: | James Joseph Balamuta <balamut2@illinois.edu> |
| Repository: | CRAN |
| Date/Publication: | 2023-11-29 07:50:02 UTC |
simcdm: Simulate Cognitive Diagnostic Model ('CDM') Data
Description
Provides efficient R and 'C++' routines to simulate cognitive diagnostic model data for Deterministic Input, Noisy "And" Gate ('DINA') and reduced Reparameterized Unified Model ('rRUM') from Culpepper and Hudson (2017)doi: 10.1177/0146621617707511, Culpepper (2015)doi:10.3102/1076998615595403, and de la Torre (2009)doi:10.3102/1076998607309474.
Author(s)
Maintainer: James Joseph Balamutabalamut2@illinois.edu (ORCID) [copyright holder]
Authors:
Steven Andrew Culpeppersculpepp@illinois.edu (ORCID) [copyright holder]
Other contributors:
Aaron Hudsonawhudson@uw.edu (ORCID) [contributor, copyright holder]
See Also
Useful links:
Report bugs athttps://github.com/tmsalab/simcdm/issues
Constructs Unique Attribute Pattern Map
Description
Computes the powers of 2 from0 up toK - 1 forK-dimensional attribute pattern.
Usage
attribute_bijection(K)Arguments
K | Number of Attributes. |
Value
Avec with lengthK detailing the power's of 2.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
Examples
## Construct an attribute bijection ----biject = attribute_bijection(3)Simulate all the Latent Attribute Profile\mathbf{\alpha}_c inMatrix form
Description
Generate the\mathbf{\alpha}_c = (\alpha_{c1}, \ldots, \alpha_{cK})'attribute profile matrix for members of classc such that\alpha_{ck} ' is 1 if members of classc possess skillkand zero otherwise.
Usage
attribute_classes(K)Arguments
K | Number of Attributes |
Value
A2^K byKmatrix of latent classescorresponding to entryc ofpi based uponmastery and nonmastery of theK skills.
Author(s)
James Joseph Balamuta and Steven Andrew Culpepper
See Also
sim_subject_attributes() andattribute_inv_bijection()
Examples
## Simulate Attribute Class Matrix ----# Define number of attributesK = 3# Generate an Latent Attribute Profile (Alpha) Matrixalphas = attribute_classes(K)Perform an Inverse Bijection of an Integer to Attribute Pattern
Description
Convert an integer between0 and2^{K-1} toK-dimensional attribute pattern.
Usage
attribute_inv_bijection(K, CL)Arguments
K | Number of Attributes. |
CL | An |
Value
AK-dimensional vector with an attribute pattern correspondingtoCL.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
Examples
## Construct an attribute inversion bijection ----inv_biject1 = attribute_inv_bijection(5, 1)inv_biject2 = attribute_inv_bijection(5, 2)Simulate a DINA Model's\eta Matrix
Description
Generates a DINA model's\eta matrix based on alphas andthe\mathbf{Q} matrix.
Usage
sim_dina_attributes(alphas, Q)Arguments
alphas | A |
Q | A |
Value
The\etamatrix with dimensionsN \times J underthe DINA model.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
sim_dina_class() andsim_dina_items()
Examples
N = 200K = 5J = 30delta0 = rep(1, 2 ^ K)# Creating Q matrixQ = matrix(rep(diag(K), 2), 2 * K, K, byrow = TRUE)for (mm in 2:K) { temp = combn(seq_len(K), m = mm) tempmat = matrix(0, ncol(temp), K) for (j in seq_len(ncol(temp))) tempmat[j, temp[, j]] = 1 Q = rbind(Q, tempmat)}Q = Q[seq_len(J), ]# Setting item parameters and generating attribute profilesss = gs = rep(.2, J)PIs = rep(1 / (2 ^ K), 2 ^ K)CLs = c((1:(2 ^ K)) %*% rmultinom(n = N, size = 1, prob = PIs))# Defining matrix of possible attribute profilesAs = rep(0, K)for (j in seq_len(K)) { temp = combn(1:K, m = j) tempmat = matrix(0, ncol(temp), K) for (j in seq_len(ncol(temp))) tempmat[j, temp[, j]] = 1 As = rbind(As, tempmat)}As = as.matrix(As)# Sample true attribute profilesAlphas = As[CLs, ]# Simulate item data under DINA model dina_items = sim_dina_items(Alphas, Q, ss, gs)# Simulate attribute data under DINA model dina_attributes = sim_dina_attributes(Alphas, Q)Simulate Binary Responses for a DINA Model
Description
Generate the dichotomous item matrix for a DINA Model.
Usage
sim_dina_class(N, J, CLASS, ETA, gs, ss)Arguments
N | Number of Observations |
J | Number of Assessment Items |
CLASS | Does the individual possess all the necessary attributes? |
ETA |
|
gs | A |
ss | A |
Value
A dichotomous item matrix with dimensionsN \times J.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
sim_dina_attributes() andsim_dina_items()
Examples
# Set N = 100rho = 0K = 3# Fixed Number of Assessment Items for QJ = 18# Specify Qqbj = c(4, 2, 1, 4, 2, 1, 4, 2, 1, 6, 5, 3, 6, 5, 3, 7, 7, 7)# Fill Q MatrixQ = matrix(, J, K)for (j in seq_len(J)) { Q[j,] = attribute_inv_bijection(K, qbj[j])}# Item parm valsss = gs = rep(.2, J)# Generating attribute classes depending on correlationif (rho == 0) { PIs = rep(1 / (2 ^ K), 2 ^ K) CLs = c(seq_len(2 ^ K) %*% rmultinom(n = N, size = 1, prob = PIs)) - 1}if (rho > 0) { Z = matrix(rnorm(N * K), N, K) Sig = matrix(rho, K, K) diag(Sig) = 1 X = Z %*% chol(Sig) thvals = matrix(rep(0, K), N, K, byrow = T) Alphas = 1 * (X > thvals) CLs = Alphas %*% attribute_bijection(K)}# Simulate data under DINA modelETA = sim_eta_matrix(K, J, Q)Y_sim = sim_dina_class(N, J, CLs, ETA, gs, ss)Simulation Responses from the DINA model
Description
Sample responses from the DINA model for given attribute profiles, Q matrix,and item parmeters. Returns amatrix of dichotomous responsesgenerated under DINA model.
Usage
sim_dina_items(alphas, Q, ss, gs)Arguments
alphas | A |
Q | A |
ss | A |
gs | A |
Value
AN byJmatrix of responses from the DINA model.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
sim_dina_class() andsim_dina_attributes()
Examples
N = 200K = 5J = 30delta0 = rep(1, 2 ^ K)# Creating Q matrixQ = matrix(rep(diag(K), 2), 2 * K, K, byrow = TRUE)for (mm in 2:K) { temp = combn(seq_len(K), m = mm) tempmat = matrix(0, ncol(temp), K) for (j in seq_len(ncol(temp))) tempmat[j, temp[, j]] = 1 Q = rbind(Q, tempmat)}Q = Q[seq_len(J), ]# Setting item parameters and generating attribute profilesss = gs = rep(.2, J)PIs = rep(1 / (2 ^ K), 2 ^ K)CLs = c((1:(2 ^ K)) %*% rmultinom(n = N, size = 1, prob = PIs))# Defining matrix of possible attribute profilesAs = rep(0, K)for (j in seq_len(K)) { temp = combn(1:K, m = j) tempmat = matrix(0, ncol(temp), K) for (j in seq_len(ncol(temp))) tempmat[j, temp[, j]] = 1 As = rbind(As, tempmat)}As = as.matrix(As)# Sample true attribute profilesAlphas = As[CLs, ]# Simulate item data under DINA model dina_items = sim_dina_items(Alphas, Q, ss, gs)# Simulate attribute data under DINA model dina_attributes = sim_dina_attributes(Alphas, Q)Generate ideal response\eta Matrix
Description
Creates the ideal response matrix for each trait
Usage
sim_eta_matrix(K, J, Q)Arguments
K | Number of Attribute Levels |
J | Number of Assessment Items |
Q | Q Matrix with dimensions |
Value
Amat with dimensionsJ \times 2^K.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
sim_q_matrix(),attribute_bijection(), andattribute_inv_bijection()
Examples
## Simulation Settings ----# Fixed Number of Assessment Items for QJ = 18# Fixed Number of Attributes for QK = 3## Pre-specified configuration ----# Specify Qqbj = c(4, 2, 1, 4, 2, 1, 4, 2, 1, 6, 5, 3, 6, 5, 3, 7, 7, 7)# Fill Q MatrixQ = matrix(, J, K)for (j in seq_len(J)) { Q[j,] = attribute_inv_bijection(K, qbj[j])}# Create an eta matrixETA = sim_eta_matrix(K, J, Q)## Random generation of Q matrix with ETA matrix ----# Construct a random q matrixQ_sim = sim_q_matrix(J, K)# Generate the eta matrixETA_gen = sim_eta_matrix(K, J, Q_sim)Generate a Random Identifiable Q Matrix
Description
Simulates a Q matrix containing three identity matrices after a rowpermutation that is identifiable.
Usage
sim_q_matrix(J, K)Arguments
J | Number of Items |
K | Number of Attributes |
Value
A dichotomousmatrix for Q.
Author(s)
Steven Andrew Culpepper and James Joseph Balamuta
See Also
attribute_bijection() andattribute_inv_bijection()
Examples
## Simulate identifiable Q matrices ----# 7 items and 2 attributesq_matrix_j7_k2 = sim_q_matrix(7, 2)# 10 items and 3 attributesq_matrix_j10_k3 = sim_q_matrix(10, 3)Generate data from the rRUM
Description
Randomly generate response data according to the reduced ReparameterizedUnified Model (rRUM).
Usage
sim_rrum_items(Q, rstar, pistar, alpha)Arguments
Q | A |
rstar | A |
pistar | A |
alpha | A |
Value
Y Amatrix withN rows andJ columns indicatingthe indviduals' responses to each of the items, whereJrepresents the number of items.
Author(s)
Steven Andrew Culpepper, Aaron Hudson, and James Joseph Balamuta
References
Culpepper, S. A. & Hudson, A. (In Press). An improved strategy for Bayesianestimation of the reduced reparameterized unified model. AppliedPsychological Measurement.
Hudson, A., Culpepper, S. A., & Douglas, J. (2016, July). Bayesian estimationof the generalized NIDA model with Gibbs sampling. Paper presented at theannual International Meeting of the Psychometric Society, Asheville, NorthCarolina.
Examples
# Set seed for reproducibilityset.seed(217)# Define Simulation ParametersN = 1000 # number of individualsJ = 6 # number of itemsK = 2 # number of attributes# Matrix where rows represent attribute classesAs = attribute_classes(K) # Latent Class probabilitiespis = c(.1, .2, .3, .4) # Q MatrixQ = rbind(c(1, 0), c(0, 1), c(1, 0), c(0, 1), c(1, 1), c(1, 1) ) # The probabiliies of answering each item correctly for individuals # who do not lack any required attributepistar = rep(.9, J)# Penalties for failing to have each of the required attributesrstar = .5 * Q# Randomized alpha profilesalpha = As[sample(1:(K ^ 2), N, replace = TRUE, pis),]# Simulate datarrum_items = sim_rrum_items(Q, rstar, pistar, alpha)Simulate Subject Latent Attribute Profiles\mathbf{\alpha}_c
Description
Generate a sample from the\mathbf{\alpha}_c = (\alpha_{c1}, \ldots, \alpha_{cK})'attribute profile matrix for members of classc such that\alpha_{ck} ' is 1 if members of classc possess skillkand zero otherwise.
Usage
sim_subject_attributes(N, K, probs = NULL)Arguments
N | Number of Observations |
K | Number of Skills |
probs | A |
Value
AN byKmatrix of latent classescorresponding to entryc ofpi based uponmastery and nonmastery of theK skills.
Author(s)
James Joseph Balamuta and Steven Andrew Culpepper
See Also
attribute_classes() andattribute_inv_bijection()
Examples
# Define number of subjects and attributesN = 100K = 3# Generate a sample from the Latent Attribute Profile (Alpha) Matrix# By default, we sample from a uniform distribution weighting of classes.alphas_builtin = sim_subject_attributes(N, K)# Generate a sample using custom probabilities from the# Latent Attribute Profile (Alpha) Matrixprobs = rep(1 / (2 ^ K), 2 ^ K)alphas_custom = sim_subject_attributes(N, K, probs)