consensus: MCMC Weighing with the Consensus Monte Carlo Method

Description Usage Arguments Value References See Also Examples

View source: R/Consensus.R

Description

This function estimates a parameter vector using the consensus Monte Carlo approach proposed by Scott et al. (2016). Using list of MCMC, it returns a weighted average of parameters.

Usage

1
consensus(Chain.Obs)

Arguments

Chain.Obs

A nested list of MCMC run on subsets. The length of the list corresponds to the number of chains. Each unit correspond to a list for one of the subsets, composted of three elements:

Chains

A Markov Chain.

Estimates

A vector parameter estimate obtained using the MCMC in "Chains"

Log-Likelihood

A two dimensional vector. One dimension, called "loglik", contains the loglikelihood evaluated at every point of the chain. "prior.vec", meanwhile, is the value of the prior at each point of the chain.

Value

A vector of parameter estimates.

References

Steven L. Scott, Alexander W. Blocker, Fernando V. Bonassi, Hugh A. Chipman, Edward I. George, and Robert McCulloch. Bayes and big data: The consensus monte carlo algorithm. International Journal of Management Science and Engineering Management, 11(2):78–88, 2016.

See Also

rf.chains

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
26
27
28
29
#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

#Simulate"Chain.Obs"
Chain.Obs<-chain.mcmc(chains,param, startval, niter=niter, X=X, prior=prior,
               likelihood=normal.likelihood, propvar=0.25, random=TRUE, num=1)

#Weigh the observations
df<-consensus(Chain.Obs)

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