R: Simulate Binary Responses for a DINA Model

sim_dina_class {simcdm} | R Documentation

## 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` | η Matrix containing indicators.
`gs` | A `vec` describing the probability of guessing or the probability subject correctly answers item j when at least one attribute is lacking.
`ss` | A `vec` describing the probability of slipping or the probability of an incorrect response for individuals with all of the required attributes

### Value

A dichotomous item matrix with dimensions N x J.

### Author(s)

Steven Andrew Culpepper and James Joseph Balamuta

### See Also

`simcdm::sim_dina_attributes()` and `simcdm::sim_dina_items()`

### Examples

    # Set
    N       = 100
    rho     = 0
    K       = 3

    # Fixed Number of Assessment Items for Q
    J = 18

    # Specify Q
    qbj = c(4, 2, 1, 4, 2, 1, 4, 2, 1, 6, 5, 3, 6, 5, 3, 7, 7, 7)

    # Fill Q Matrix
    Q = matrix(, J, K)
    for (j in seq_len(J)) {
      Q[j,] = attribute_inv_bijection(K, qbj[j])
    }

    # Item parm vals
    ss = gs = rep(.2, J)

    # Generating attribute classes depending on correlation
    if (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 model
    ETA = sim_eta_matrix(K, J, Q)
    Y_sim = sim_dina_class(N, J, CLs, ETA, gs, ss)

[Package simcdm version 0.1.1 Index]