stephens {label.switching} | R Documentation |
Stephens' algorithm
Description
Stephens (2000) developed a relabelling algorithm that makes the permuted sample points to agree as much as possible on the matrix of classification probabilities, using the Kullback-Leibler divergence. The algorithm's input is the matrix of allocation probabilities for each MCMC iteration.
Usage
stephens(p, threshold, maxiter)
Arguments
p |
|
threshold |
An (optional) positive number controlling the convergence criterion. Default value: 1e-6. |
maxiter |
An (optional) integer controlling the max number of iterations. Default value: 100. |
Details
For a given MCMC iteration , let
and
,
denote the simulated mixture weights and component specific parameters respectively. Then, the
element of
p
corresponds to the conditional probability that observation belongs to component
and is proportional to
, where
denotes the density of component
. This means that:
In case of hidden Markov models, the probabilities should be replaced with the proper left (normalized) eigenvector of the state-transition matrix.
Value
permutations |
|
iterations |
integer denoting the number of iterations until convergence |
status |
returns the exit status |
Author(s)
Panagiotis Papastamoulis
References
Stephens, M. (2000). Dealing with label Switching in mixture models. Journal of the Royal Statistical Society Series B, 62, 795-809.
See Also
Examples
#load a toy example: MCMC output consists of the random beta model
# applied to a normal mixture of \code{K=2} components. The number
# of observations is equal to \code{n=5}. The number of MCMC samples
# is equal to \code{m=300}. The matrix of allocation probabilities
# is stored to matrix \code{p}.
data("mcmc_output")
# mcmc parameters are stored to array \code{mcmc.pars}
mcmc.pars<-data_list$"mcmc.pars"
# mcmc.pars[,,1]: simulated means of the two components
# mcmc.pars[,,2]: simulated variances
# mcmc.pars[,,3]: simulated weights
# the computed allocation matrix is p
p<-data_list$"p"
run<-stephens(p)
# apply the permutations returned by typing:
reordered.mcmc<-permute.mcmc(mcmc.pars,run$permutations)
# reordered.mcmc[,,1]: reordered means of the components
# reordered.mcmc[,,2]: reordered variances
# reordered.mcmc[,,3]: reordered weights