## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 3) set.seed(1) ## ----curved------------------------------------------------------------------- library(scmix) n1 <- 400; n2 <- 300 x1 <- rnorm(n1 + n2) x2 <- c( 0.5 + 1.0 * x1[1:n1]^2, -2.0 - 0.8 * x1[(n1 + 1):(n1 + n2)]^2) + rnorm(n1 + n2, 0, 0.6) Y <- cbind(x1, x2) truth <- rep(1:2, c(n1, n2)) fit <- scmix(Y, K = 7, m = 2, n_iter = 800, burn = 300, seed = 42) fit table(consensus = fit$cluster, truth) ## ----plot, fig.alt = "Scatter plot of the two curved clusters colored by the fitted consensus partition"---- plot(fit, Y) ## ----summary------------------------------------------------------------------ summary(fit) ## ----mw----------------------------------------------------------------------- sim <- scmix_sim_mw3(n = 600, seed = 7) # bundled S-1 generator fit2 <- scmix(sim$Y, K = 7, m = 2, n_iter = 800, burn = 300, seed = 11) c(K_consensus = fit2$K, ARI_vs_truth = round(scmix_ari(fit2$cluster, sim$z), 3))