#############################################################################
# SIMULATED EXAMPLE 1: 13 items and 3 attributes
#############################################################################
set.seed(679)
N <- 3000
# specify true Q-matrix
q.matrix <- matrix( 0 , 13 , 3 )
q.matrix[1:3,1] <- 1
q.matrix[4:6,2] <- 1
q.matrix[7:9,3] <- 1
q.matrix[10,] <- c(1,1,0)
q.matrix[11,] <- c(1,0,1)
q.matrix[12,] <- c(0,1,1)
q.matrix[13,] <- c(1,1,1)
q.matrix <- rbind( q.matrix , q.matrix )
colnames(q.matrix) <- paste0("Attr",1:ncol(q.matrix))
# simulate data according to the DINA model
dat <- sim.din( N=N , q.matrix)$dat
# Joint maximum likelihood estimation (the default: method="JML")
res1 <- din.deterministic( dat , q.matrix )
# Adaptive estimation of guessing and slipping parameters
res <- din.deterministic( dat , q.matrix , method="adaptive" )
# Classification using Hamming distance
res <- din.deterministic( dat , q.matrix , method="hamming" )
# Classification using weighted Hamming distance
res <- din.deterministic( dat , q.matrix , method="weighted.hamming" )
#********* load NPCD library for JML estimation
miceadds::library_install("NPCD")
# choose a smaller dataset for reasons of computation time
# DINA model
res <- NPCD::JMLE( Y=dat[1:100,] , Q=q.matrix , model="DINA" )
as.data.frame(res$par.est ) # item parameters
res$alpha.est # skill classifications
# RRUM model
res <- NPCD::JMLE( Y=dat[1:100,] , Q=q.matrix , model="RRUM" )
as.data.frame(res$par.est )
Run the code above in your browser using DataLab