View source: R/plotly_mixturegram.R
plotly_mixturegram | R Documentation |
Construct a mixturegram for determining an apporpriate number of components using plotly
.
plotly_mixturegram(data, pmbs, method=c("pca","kpca","lda"), all.n=FALSE, id.con=NULL, score=1, iter.max=50, nstart=25, xlab = "K", xlab.size = 15, xtick.size = 15, ylab = NULL, ylab.size = 15, ytick.size = 15, cex = 12, col.dot = "red", width = 1, title = "Mixturegram", title.size = 15, title.x = 0.5, title.y = 0.95)
data |
The data, which must either be a vector or a matrix. If a matrix, then the rows correspond to the observations. |
pmbs |
A list of length (K-1) such that each element is an nxk matrix of the posterior membership probabilities. These are obtained from each of the "best" estimated k-component mixture models, k = 2,...,K. |
method |
The dimension reduction method used. |
all.n |
A logical specifying whether the mixturegram should plot the profiles of all observations ( |
id.con |
An argument that allows one to impose some sort of (meaningful) identifiability constraint so that the mixture components are in some sort of comparable order between mixture models with different numbers of components. If |
score |
The value for the specified dimension reduction technique's score, which is used for constructing the mixturegram. By default, this value is |
iter.max |
The maximum number of iterations allowed for the k-means clustering algorithm, which is passed to the |
nstart |
The number of random sets chosen based on k centers, which is passed to the |
title |
Text of the main title. |
title.size |
Size of the main title. |
title.x |
Horsizontal position of the main title. |
title.y |
Vertical posotion of the main title. |
xlab |
Label of X-axis. |
xlab.size |
Size of the lable of X-axis. |
xtick.size |
Size of tick lables of X-axis. |
ylab |
Label of Y-axis. |
ylab.size |
Size of the lable of Y-axis. |
ytick.size |
Size of tick lables of Y-axis. |
cex |
Size of dots. |
col.dot |
Color of dots. |
width |
Line width. |
plotly_mixturegram
returns a mixturegram where the profiles are plotted over component values of k = 1,...,K.
Young, D. S., Ke, C., and Zeng, X. (2018) The Mixturegram: A Visualization Tool for Assessing the Number of Components in Finite Mixture Models, Journal of Computational and Graphical Statistics, 27(3), 564–575.
boot.comp
, mixturegram
## Not run: ##Data generated from a 2-component mixture of normals. set.seed(100) n <- 100 w <- rmultinom(n,1,c(.3,.7)) y <- sapply(1:n,function(i) w[1,i]*rnorm(1,-6,1) + w[2,i]*rnorm(1,0,1)) selection <- function(i,data,rep=30){ out <- replicate(rep,normalmixEM(data,epsilon=1e-06, k=i,maxit=5000),simplify=FALSE) counts <- lapply(1:rep,function(j) table(apply(out[[j]]$posterior,1, which.max))) counts.length <- sapply(counts, length) counts.min <- sapply(counts, min) counts.test <- (counts.length != i)|(counts.min < 5) if(sum(counts.test) > 0 & sum(counts.test) < rep) out <- out[!counts.test] l <- unlist(lapply(out, function(x) x$loglik)) tmp <- out[[which.max(l)]] } all.out <- lapply(2:5, selection, data = y, rep = 2) pmbs <- lapply(1:length(all.out), function(i) all.out[[i]]$post) plotly_mixturegram(y, pmbs, method = "pca", all.n = TRUE, id.con = NULL, score = 1, title = "Mixturegram (Well-Separated Data)") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.