Description Usage Arguments Value References See Also Examples
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.
1 | consensus(Chain.Obs)
|
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:
|
A vector of parameter estimates.
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.
rf.chains
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.