Learn R Programming

latrend (version 1.1.2)

latrend-parallel: Parallel computing using latrend

Description

The model estimation functions support parallel computation through the use of the foreach mechanism. In order to make use of parallel execution, a parallel back-end must be registered.

Arguments

Windows

On Windows, the parallel-package can be used to define parallel socket workers.

nCores = parallel::detectCores(logical = FALSE)
cl = parallel::makeCluster(nCores - 1)
parallel::clusterEvalQ(cl, expr=library(latrend))

Then, register the cluster as the parallel back-end using the doParallel package:

doParallel::registerDoParallel(cl)

If you defined your own lcMethod or lcModel extension classes, make sure to load them on the workers as well. This can be done, for example, using:

parallel::clusterEvalQ(cl,
  expr = setClass('lcMethodMyImpl', contains = "lcMethod"))

Unix

On Unix systems, it is easier to setup parallelization as the R process is forked. In this example we use the doMC package:

nCores = parallel::detectCores(logical = FALSE)
doMC::registerDoMC(nCores - 1)

See Also

latrendRep, latrendBatch, latrendBoot, latrendCV