## simulate DINA and DINO data according to a tetrachoric correlation
# define Q-matrix for 4 items and 2 attributes
q.matrix <- matrix(c(1,0,0,1,1,1,1,1), ncol = 2, nrow = 4)
# Slipping parameters
slip <- c(0.2,0.3,0.4,0.3)
# Guessing parameters
guess <- c(0,0.1,0.05,0.2)
set.seed(1567) # fix random numbers
dat1 <- sim.din(N = 200, q.matrix, slip, guess,
# Possession of the attributes with high probability
mean = c(0.5,0.2),
# Possession of the attributes is weakly correlated
Sigma = matrix(c(1,0.2,0.2,1), ncol=2), rule = "DINA")
head(dat1)
set.seed(15367) # fix random numbers
dat2 <- sim.din(N = 200, q.matrix, slip, guess, mean =
c(0.5,0.2), Sigma = matrix(c(1,0.2,0.2,1), ncol=2),
rule = "DINO")
head(dat2)
Run the code above in your browser using DataLab