In the R package ltm by Dimitris Rizopoulos there is a function called unidimTest(). Computations of this function are very power consuming due the Monte Carlo procedure used inside. Without parallelizing only one core of your (surely) multicore computer is used for this computation. A simple modification of unidimTest() makes it possible to use the quite easy to use R package foreach for parallel computing using the R packages parallel and doParallel. See also parallel-r-loops-for-windows-and-linux by Vik Paruchuri.

I have changed the lines of unidimTest()

for (b in 1:B) { if (!missing(object)) z.vals <- rnorm(n, ablts, se.ablts) data.new <- rmvlogis(n, parms, IRT = IRT, z.vals = z.vals) T.boot[b, ] <- eigenRho(data.new)$ev }

to

T.boot[,] <- foreach(b=1:B, .combine="rbind", .errorhandling="pass") %dopar% { #if (!missing(object)) z.vals <- rnorm(n, ablts, se.ablts) data.new <- rmvlogis(n, parms, IRT = IRT, z.vals = z.vals) eigenRho(data.new)$ev }

and named the function unidimTest.p().

The function is called as

library(foreach) library(parallel) library(doParallel) registerDoParallel(cores=4) # put in here how many cores you want to be used set.seed(666) proc <- proc.time() uni.p <- unidimTest.p(fit.rasch.u, B=100) proc.time() - proc

and works at least on an Mac OS X (10.8.3) environment with R version 3.0.1.

## One thought on “Parallel computing unidimTest in IRT”