Description Usage Arguments Details Value References Examples
View source: R/consensusMCindep.R
The function uses the Consensus Monte Carlo algorithm introduced by Scott et al. (see References) to combine the independent subset posterior samples subchains into the set of samples that estimate the posterior density given the full data set. The Consensus Monte Carlo algorithm uses a weighted average of the subset posterior samples to produce the combined posterior samples, where the weights are based on the inverse variance-covariance matrix of the subset posterior samples. Here, the model parameters are assumed to be independent, so that the covariance between model parameters is equal to zero.
1 | consensusMCindep(subchain, shuff = FALSE)
|
subchain |
array of subset posterior samples of the dimension c(d,sampT,M). Here d is the dimension of the parameter space, sampT is the number of samples, and M is the number of subposterior datasets. |
shuff |
shuff: logical; if TRUE, each of the M subsets of d dimensional parameters in subchain is shuffled. |
The array subchain must have dimension c(d,sampT,M). Here d is the dimension of the parameter space, sampT is the number of samples, and M is the number of subposterior datasets.
Returns an array of samples of dimension dim=c(d,sampT) representing an estimated (combined) full posterior density.
Scott, S.L., Blocker, A. W., Bonassi (2013) Bayes and Big Data: The consensus Monte Carlo Algorithm. Bayes 250 day.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | d <- 2 # dimension of the parameter space
sampT <- 1000 # number of subset posterior samples
M <- 3 # total number of subsets
## simulate Gaussian subposterior samples
theta <- array(NA,c(d,sampT,M))
norm.mean <- c(1.0, 2.0)
norm.sd <- c(0.5, 1.0)
for (i in 1:d)
for (s in 1:M)
theta[i,,s] <- rnorm(sampT, mean=norm.mean[i]+runif(1,-0.01,0.01), sd=norm.sd[i])
## combine samples:
full.theta <- consensusMCindep(subchain=theta, shuff=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.