Learn R Programming

ergm (version 3.1.3)

ergm-parallel: Parallel Processing in the ergm Package

Description

ergm can take advantage of multiple CPUs or CPU cores on the system on which it runs, as well as computing clusters. It uses package snow to facilitate this, and supports all cluster types that it does.

The parallel API and the number of nodes used are controlled using the parallel and parallel.type arguments passed to the control functions, such as control.ergm.

This entry describes common problems and workarounds associated with particular parallel processing APIs.

Arguments

MPI

To use MPI to accellerate ERGM sampling, pass the control parameter parallel.type="MPI". ergm and snow use Rmpi package to communicate with an MPI cluster. ergm will check if an MPI cluster already exists and will create one if one doesn't.

On some installations, the function stopCluster does not work properly for MPI clusters. Because ergm creates a cluster every time it needs an MCMC sample and disbands it once it finishes, using MPI on these installations may fail. A workaround is to start the cluster outside of ergm (e.g., dummy <- makeCluster(nnodes, type="MPI")). ergm will notice the preexisting cluster and make use of it, but it will not stop it.

Examples

Run this code
# See help(ergm) for a description of this model.
data(florentine)
gest <- ergm(flomarriage ~ kstar(1:2) + absdiff("wealth") + triangles,
             eval.loglik=FALSE,
             control=control.ergm(parallel=2, parallel.type="SOCK"))
summary(gest)
# Note the combined MCMC diagnostics:
mcmc.diagnostics(gest)

Run the code above in your browser using DataLab