Description Usage Arguments Details Value Author(s) References Examples
Main function of the package. The algorithm consists of the allocation sampler combined with a MC3 scheme.
1 2  coupledMetropolis(Kmax, nChains, heats, binaryData, outPrefix,
ClusterPrior, m, alpha, beta, gamma, z.true, ejectionAlpha, burn)

Kmax 
Maximum number of clusters (integer, at least equal to two). 
nChains 
Number of parallel (heated) chains. Ideally, it should be equal to the number of available threads. 
heats 

binaryData 
The observed binary data (array). Missing values are allowed as long as the corresponding entries are denoted as 
outPrefix 
The name of the produced output folder. An error is thrown if the directory exists. 
ClusterPrior 
Character string specifying the prior distribution of the number of clusters on the set \{1,…,K_{max}\}. Available options: 
m 
The number of MCMC cycles. At the end of each cycle a swap between a pair of heated chains is attempted. Each cycle consists of 10 iterations. 
alpha 
First shape parameter of the Beta prior distribution (strictly positive). Defaults to 1. 
beta 
Second shape parameter of the Beta prior distribution (strictly positive). Defaults to 1. 
gamma 

z.true 
An optional vector of cluster assignments considered as the groundtruth clustering of the observations. Useful for simulations. 
ejectionAlpha 
Probability of ejecting an empty component. Defaults to 0.2. 
burn 
Optional integer denoting the number of MCMC cycles that will be discarded as burnin period. 
In the case that the most probable number of clusters is larger than 1, the output is postprocessed using the label.switching package. In addition to the objects returned to the user (see value
below), the complete output of the sampler is written to the directory outPrefix
. It consists of the following files:
K.allChains.txt
m
\timesnChains
matrix containing the simulated values of the number of clusters (K) per chain.
K.txt
the m
simulated values of the number of clusters (K) of the cold chain (posterior distribution).
p.varK.txt the simulated values of the mixture weights (not identifiable).
rawMCMC.mapK.KVALUE.txt the raw MCMC output which corresponds to the most probable model (not identifiable).
reorderedMCMCECRITERATIVE1.mapK.KVALUE.txt
the reordered MCMC output which corresponds to the most probable model, reordered according to the ECRITERATIVE1
algorithm.
reorderedMCMCECR.mapK.KVALUE.txt
the reordered MCMC output which corresponds to the most probable model, reordered according to the ECR
algorithm.
reorderedMCMCSTEPHENS.mapK.KVALUE.txt
the reordered MCMC output which corresponds to the most probable model, reordered according to the STEPHENS
algorithm.
reorderedSingleBestClusterings.mapK.KVALUE.txt the most probable allocation of each observation after reordering the MCMC sample which corresponds to the most probable number of clusters.
theta.varK.txt the simulated values of Bernoulli parameters (not identifiable).
zECRITERATIVE1.mapK.KVALUE.txt
the reordered simulated latent allocations which corresponds to the most probable model, reordered according to the ECRITERATIVE1
algorithm.
zECR.mapK.KVALUE.txt
the reordered simulated latent allocations which corresponds to the most probable model, reordered according to the ECR
algorithm.
zKL.mapK.KVALUE.txt
the reordered simulated latent allocations which corresponds to the most probable model, reordered according to the STEPHENS
algorithm.
z.varK.txt the simulated latent allocations (not identifiable).
classificationProbabilities.mapK.KVALUE.csv
the reordered classification probabilities per observation after reordering the most probable number of clusters with the ECR
algorithm.
xEstimated.txt Observed data with missing values estimated by their posterior mean estimate. This file is produced only in the case that the observed data contains missing values.
KVALUE
will be equal to the inferred number of clusters. Note that the label switching part is omitted in case that the most probable number of clusters is equal to 1.
The basic output of the sampler is returned to the following R
objects:
K.mcmc 
object of class 
parameters.ecr.mcmc 
object of class 
allocations.ecr.mcmc 
object of class 
classificationProbabilities.ecr 
data frame of the reordered classification probabilities per observation after reordering the most probable number of clusters with the 
clusterMembershipPerMethod 
data frame of the most probable allocation of each observation after reordering the MCMC sample which corresponds to the most probable number of clusters according to 
K.allChains 

chainInfo 
Number of cycles, burnin period and acceptance rate of swap moves. 
Panagiotis Papastamoulis
Altekar G, Dwarkadas S, Huelsenbeck JP, Ronquist F. (2004): Parallel Metropolis coupled Markov chain Monte Carlo for Bayesian phylogenetic inference. Bioinformatics 20(3): 407415.
Nobile A and Fearnside A (2007): Bayesian finite mixtures with an unknown number of components: The allocation sampler. Statistics and Computing, 17(2): 147162.
Papastamoulis P. and Iliopoulos G. (2010). An artificial allocations based solution to the label switching problem in Bayesian analysis of mixtures of distributions. Journal of Computational and Graphical Statistics, 19: 313331.
Papastamoulis P. and Iliopoulos G. (2013). On the convergence rate of Random Permutation Sampler and ECR algorithm in missing data models. Methodology and Computing in Applied Probability, 15(2): 293304.
Papastamoulis P. (2014). Handling the label switching problem in latent class models via the ECR algorithm. Communications in Statistics, Simulation and Computation, 43(4): 913927.
Papastamoulis P (2016): label.switching: An R package for dealing with the label switching problem in MCMC outputs. Journal of Statistical Software, 69(1): 124.
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 30 31 32 33 34 35  #generate dataset from a mixture of 2 tendimensional Bernoulli distributions.
set.seed(1)
d < 10 # number of columns
n < 50 # number of rows (sample size)
K < 2 # true number of clusters
p.true < myDirichlet(rep(10,K)) # true weight of each cluster
z.true < numeric(n) # true cluster membership
z.true < sample(K,n,replace=TRUE,prob = p.true)
#true probability of positive responses per cluster:
theta.true < array(data = NA, dim = c(K,d))
for(j in 1:d){
theta.true[,j] < rbeta(K, shape1 = 1, shape2 = 1)
}
x < array(data=NA,dim = c(n,d)) # data: n X d array
for(k in 1:K){
myIndex < which(z.true == k)
for (j in 1:d){
x[myIndex,j] < rbinom(n = length(myIndex),
size = 1, prob = theta.true[k,j])
}
}
# number of heated paralled chains
nChains < 2
heats < seq(1,0.8,length = nChains)
## Not run:
cm < coupledMetropolis(Kmax = 10,nChains = nChains,heats = heats,
binaryData = x, outPrefix = 'BayesBinMixExample',
ClusterPrior = 'poisson', m = 1100, burn = 100)
# print summary using:
print(cm)
## End(Not run)
# it is also advised to use z.true = z.true in order to directly compare with
# the true values. In general it is advised to use at least 4 chains with
# heats < seq(1,0.3,length = nChains)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.