MCMCcopies.cl: Parallel simulation of iid copies of a MCMC algorithm -...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function simulates “parallel chains” (iid copies) of a MCMC algorithm for n (time) iterations, i.e. for each chain k, the whole trajectory of the chain is generated. It returns an object of class plMCMC (for parallel MCMC) holding an array of the trajectories and running information. This functions is similar to MCMCcopies and MCMCcopies.mc except that it uses HPC in a more generic way, implementing several types of HPC for running on a single, multicore computer or on a true cluster using MPI communications.

Usage

1
2
MCMCcopies.cl(mcmc_algo, n=100, nmc=10, Ptheta0, target, f_param, q_param,
              cltype="PAR_SOCK", nbnodes=4) 

Arguments

mcmc_algo

a list defining an MCMC algorithm in terms of the functions it uses, such as RWHM, see details below.

n

The number of (time) iterations of each single chain to run.

nmc

The number of iid copies of each single chain.

Ptheta0

A (nmc x d) matrix, with the ith row giving a d-dimensional initial theta values for the ith chain.

target

The target density for which the MCMC algorithm is defined; may be given only up to a multiplicative constant for most MCMC. target must be a function such as the multidimensional gaussian target_norm(x,param) with argument and parameters passed like in this example.

f_param

A list holding all the necessary target parameters, consistent with the target definition.

q_param

A list holding all the necessary parameters for the proposal density of the MCMC algorithm mcmc_algo.

cltype

Character string specifying the type of cluster; currently implemented types are: "PAR_SOCK" for socket cluster with parallel library, the default; "SNOW_SOCK" for socket cluster with snow library, and "SNOW_RMPI" for snow MPI cluster with Rmpi library.

nbnodes

The number of nodes or virtual cores requested to run the nmc simulations in parallel. For the snow version, defaults to all; for the cluster version, defaults to 4.

Details

MCMCcopies.cl simulates in parallel nmc iid copies of the MCMC algorithm passed in the list mcmc_algo, for n (time) iterations, and returns an object of class plMCMC holding an array of the trajectories and running information.

About parallel computing:

The Rmpi option is less efficient than the default option using parallel if you are running on a single computer. MPI communication are required only for running on a true cluster/grid.

This generic cluster version implementing several types of cluster for running on a single, multicore computer or on a true cluster using MPI communications may not work on all platform/OS. For instance the parallel socket cluster version does not work on Windows machines (see the parallel package documentation).

About passing your MCMC algorithm:

The list mcmc_algo must contain the named elements:

For examples, see the algorithms currently implemented: RWHM, the Random Walk Hasting-Metropolis with gaussian proposal; HMIS_norm, an Independence Sampler HM with gaussian proposal; AMHaario, the Adaptive-Metropolis (AM) from Haario (2001); IID_norm, a gaussian iid sampler which is merely a "fake" MCMC for testing purposes.

Value

MCMCcopies.cl returns a list of class plMCMC with items:

Ptheta

The nmc copies of chains in an array(n,d,nmc) of simulated values, where 1st value (1,d,nmc) is Ptheta0.

prob.accept

The estimated rate of acceptation over all simulations.

algo

The MCMC algorithm name i.e. mcmc_algo$name.

target

The target density.

f_param

The list holding all the target parameters.

q_param

The list holding all the proposal density parameters.

Author(s)

Houssam Alrachid and Didier Chauveau.

References

See Also

A simpler cluster version MCMCcopies.mc, a single core version MCMCcopies, and functions doing simulation and entropy and Kullback estimation simultaneously: EntropyParallel and EntropyParallel.cl

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Toy example using the bivariate gaussian target

n = 150; nmc = 20; d=2 # bivariate example
varq=0.1 # variance of the proposal (chosen too small)
q_param=list(mean=rep(0,d),v=varq*diag(d))
## initial distribution, located in (2,2), "far" from target center (0,0)
Ptheta0 <- DrawInit(nmc, d, initpdf = "rnorm", mean = 2, sd = 1) 
# simulations (may be compared with the singlecore version using system.time)
s1 <- MCMCcopies.cl(RWHM, n, nmc, Ptheta0, target_norm,
		              target_norm_param, q_param, nbnodes = 2)
summary(s1) # method for "plMCMC" object
  
## see MCMCcopies example for plots

EntropyMCMC documentation built on May 2, 2019, 6:43 a.m.