I'm really enjoying the capabilities of this great package. I'm trying to fit a 4-factor IRT model with about ~100 items and response data from ~16,000 individuals. This is a computationally intensive model on one-core, even for the MH-RM estimator, so I'm hoping to take advantage of my 8-core PC and the mirtCluster() feature. Unfortunately, I don't appear to be successful in fitting the model in parallel--the CPU usage from my MS Window's Task Manager suggests that only one core is being utilized. Below I include replicable code for a simulation of the situation that I am facing.
library("mirt")
library("MASS")
library("parallel")
mirtCluster()
N = 16000 #Number of persons
J = 100 # number of items
K = 4 # Number of dimensions
#Confirmatory MIRT 2-PL model
#simulate data
# Item loadings
a = mat.or.vec(nr = J, nc = K) + NA
for(j in 1:J){
k_j = sample(1:K,1)
a[j,sample(1:K,k_j,replace = FALSE)] = runif(k_j,0.5,1.5)
}
d = rnorm(J,mean =0, sd = sqrt(2))
items = rep('dich',J)
# Q matrix specifying loadings to be stimated
Q_df = data.frame(mat.or.vec(nr = nrow(a), nc = ncol(a)))
names(Q_df) = paste("F",c(1:ncol(a)), sep = "")
row.names(Q_df) = paste("Item_",1:nrow(a), sep = "")
Q_df[a!=0]=1
# Specify the theta covariances to be estimated
SQ_df = data.frame(matrix(rep(TRUE,ncol(a)^2), nr = ncol(a)))
names(SQ_df) <- row.names(SQ_df) <- names(Q_df)
Q_df
SQ_df
model.2 = mirt.model(input = as.matrix(Q_df), COV = as.matrix(SQ_df))
### simulate a new matrix
x = rnorm(N, 0, 1)
mu_theta = rep(0,ncol(a))
S_theta = diag(ncol(a))
S_theta[S_theta==0] = 1/3
Theta = cbind(x,x,x,x)+mvrnorm(N, mu_theta, S_theta)
a
d
items
dataset = simdata(a,d,N,items,Theta = Theta)
head(dataset)
# Fit the model
covdataset = data.frame(x = x)
mod2 <- mirt(dataset, model.2, covdata = covdataset, TOL = 1E-3,
formula = ~x, technical = list(parallel = TRUE))
mirtCluster(remove = TRUE)