label_switch | R Documentation |
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).
label_switch(x, m)
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. |
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.
A list of 2:
x |
The input matrix, with adjusted labels |
true_perm |
The "true" permutation at each iteration. |
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.
Davide Ravagli
Celeux2000mixAR
bayes_mixAR
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.