label_switch {mixAR} | R Documentation |
A posteriori relabelling of a Markov chain
Description
Takes the output from a MCMC simulation of parameters of a mixture, and detects whether labels switch has occured while sampling, using the method by Celeux (2000).
Usage
label_switch(x, m)
Arguments
x |
output from an MCMC sampling of a mixture. A |
m |
the number of observations in the sample that will be used to
initialise the algorithm. |
Details
Function can be directly executed when x
is one of
mix_weights
, scale
, precision
, shift
or
mu
from bayes_mixAR
output. ARcoeff
cannot be input
as it is, but element from the list may be used.
Value
A list of 2:
x |
The input matrix, with adjusted labels |
true_perm |
The "true" permutation at each iteration. |
Note
There is no absolute choice on what x
should be to obtain the
"true" permutation at any given point. User is subject to make the
most suitable choice, given output of their MCMC.
Author(s)
Davide Ravagli
References
Celeux G (2000). Bayesian Inference of Mixture: The Label Switching Problem.. Payne R., Green P. (eds) COMPSTAT. Physica, Heidelberg.
See Also
Examples
model <- new("MixARGaussian",
prob = exampleModels$WL_At@prob, # c(0.5, 0.5)
scale = exampleModels$WL_At@scale, # c(1, 2)
arcoef = exampleModels$WL_At@arcoef@a ) # list(-0.5, 1.1)
y <- mixAR_sim(model, n = 300, init = rep(0, which.max(model@order)))
## just examples, use larger numbers in practice
nsim <- 30 # 200
burnin <- 10 # 100
x <- bayes_mixAR(y, model, fix_shift = FALSE, tau = c(.15, .25),
nsim = nsim, burnin = burnin)
label_switch(x$mix_weights, m = 5)