chain.mcmc: Parallel MCMC on Subsets

Description Usage Arguments Details Value References Examples

View source: R/Parallel.R

Description

Takes a dataset X, subdivides it into an inputted number of subsets, and runs an MCMC on each subset in parallel.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
chain.mcmc(
  chains,
  para,
  startval,
  niter,
  X,
  prior,
  likelihood,
  propvar = NULL,
  burn.rate = 0.1,
  random = T,
  num
)

Arguments

chains

Number of subsets in the simulation. Used when a divide-and-conquer algorithm is employed

para

Parameters to be estimate.

startval

Initial value of the chain.

niter

Number of iterations (including burned iterations).

X

Matrix of observations from the underlying model.

prior

Prior function for the parameters.

likelihood

Likelihood function.

propvar

The diagonal of the variance matrix for the proposal distribution. If no value is specified, the identify matrix is used.

burn.rate

The percentage of iterations to be burned.

random

If true, the rows of X are shuffled prior to the split.

num

Numerator of the sub-posterior exponent (Wu and Robert, 2019). Used when a divide-and-conquer algorithm is employed.

Details

In the divide-and-conquer scheme, the data set X is divided into K subsets X_k. The subposterior for subset X_k is thus

π_k(θ | X_k) ∝ (π(θ)^(1/K) ∏ p(x|θ))^λ

See Wu and Robert (2019) for more details.

Value

Returns a nested list. Each element in the list corresponds to an output from mcmc.sub.

References

Changye Wu and Christian P. Robert. Parallelising MCMC via Random Forests. arXiv e-prints, art. arXiv:1911.09698, 2019.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Parameter Estimation for Data from a Normal Distribution

#Prior
prior<-function(param){
  ifelse(all(param>0), 1, 0)
}

#Likelihood function
normal.likelihood<-function(X, param){
  mu=param[1]
  sigma=param[2]
  sum(dnorm(x=X, mean=mu, sd=sigma, log=TRUE))
}

#Simulate data
X<-rnorm(100, 2, 1.2)

#Parameters
param<-c("mu", "sigma")
niter<-10000
startval<-c(1, 1)
chains<-4

df<-chain.mcmc(chains,param, startval, niter=niter, X=X, prior=prior,
               likelihood=normal.likelihood, propvar=0.25, random=TRUE, num=1)

JacobRaymond/ConquerMCMC documentation built on May 12, 2020, 1:03 a.m.