| Title: | Bayesian Model-Based Clustering with Sparse Conditional Mixture Models |
|---|---|
| Description: | Fits Bayesian sparse conditional (Gaussian) mixture models for model-based clustering. Each mixture component factorizes into a chain of univariate polynomial regressions with per-component, per-equation Bayesian variable selection under a centered Zellner g-prior; the number of clusters is selected within a single run via an overfitted sparse mixture (Dirichlet concentration 1/K). The blocked Gibbs sampler draws the selection sets exactly by enumeration (or by validated single-flip Metropolis-Hastings in higher dimension), is provably well-posed under a documented proper fallback prior, and reports a label-invariant consensus partition (Dahl's least-squares criterion). Companion package to Dong, Liao, and Lee (2026), "Replacing three nested searches with one sweep: a Bayesian treatment of sparse conditional mixture clustering". Multiple-imputation functionality for the same engine is also exposed. |
| Authors: | Aqi Dong [aut, cre], Yang-Li Liao [aut], Danhyang Lee [aut] |
| Maintainer: | Aqi Dong <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.1 |
| Built: | 2026-09-19 09:13:55 UTC |
| Source: | https://github.com/cran/scmix |
Pools estimates and variances across completed data sets from
scmix_impute.
rubin_pool_scmix(completed, est_fun, var_fun)rubin_pool_scmix(completed, est_fun, var_fun)
completed |
list of completed data matrices. |
est_fun, var_fun
|
functions mapping a completed matrix to a named numeric vector of estimates and matching variances. |
List with pooled estimates, total variance, standard errors, degrees of freedom, and 95 percent interval endpoints.
Y <- scmix_sim_mw3(n = 120, seed = 7)$Y set.seed(7) Y[sample(length(Y), 30)] <- NA imp <- scmix_impute(Y, M = 2, K = 4, n_iter = 300, burn = 100, seed = 8) pool <- rubin_pool_scmix(imp$completed, colMeans, function(d) apply(d, 2, stats::var) / nrow(d)) pool$est pool$seY <- scmix_sim_mw3(n = 120, seed = 7)$Y set.seed(7) Y[sample(length(Y), 30)] <- NA imp <- scmix_impute(Y, M = 2, K = 4, n_iter = 300, burn = 100, seed = 8) pool <- rubin_pool_scmix(imp$completed, colMeans, function(d) apply(d, 2, stats::var) / nrow(d)) pool$est pool$se
Fits the Bayesian sparse conditional mixture model of Dong, Liao, and Lee to a
numeric data matrix and returns a clustering. Each mixture component
factorizes into a chain of univariate polynomial regressions (degree
m) with per-component, per-equation Bayesian variable selection
under a centered Zellner g-prior; the number of clusters is selected
within the run by an overfitted sparse mixture (Dirichlet concentration
a = 1/K). A single run returns the estimated number of clusters,
a label-invariant consensus partition, selection probabilities for every
term of every within-component regression, and coefficient summaries.
scmix( Y, K = 7L, m = 2L, n_iter = 1500L, burn = 600L, order = NULL, a = 1/K, g = NULL, enum_max = 12L, seed = NULL, verbose = 0L, ... )scmix( Y, K = 7L, m = 2L, n_iter = 1500L, burn = 600L, order = NULL, a = 1/K, g = NULL, enum_max = 12L, seed = NULL, verbose = 0L, ... )
Y |
numeric matrix (n x p); rows are observations. Must be complete
for |
K |
integer, overfitted cap on the number of components (the number
of occupied components is estimated; |
m |
integer polynomial degree of the conditional means (2 = quadratic, the recommended default; 1 = linear). |
n_iter, burn
|
total and burn-in Gibbs sweeps. |
order |
optional integer permutation of |
a |
Dirichlet concentration of the mixture weights (default
|
g |
g-prior scale: |
enum_max |
exact enumeration of selection sets while a regression
has at most |
seed |
optional integer seed (full run reproducibility). |
verbose |
print progress every |
... |
further arguments passed to the engine (see
|
An object of class "scmix": a list with components
integer vector, the consensus partition (Dahl's least-squares criterion over the posterior similarity matrix).
number of clusters in the consensus partition.
posterior mode of the number of occupied components across sweeps.
list (one matrix per mixture component label) of posterior selection probabilities; rows = equations, columns = candidate terms (named).
coefficient summaries (posterior means conditional on inclusion) and residual-variance posterior means, per label.
fraction of post-burn-in sweeps each label was
occupied (interpret per-label summaries only for labels with
alive_frac near 1).
the final-sweep posterior draw of the allocations
(a sample, not a point estimate; prefer cluster).
bookkeeping.
Dong, A., Liao, Y.-L., and Lee, D. (2026). Replacing three nested searches with one sweep: a Bayesian treatment of sparse conditional mixture clustering. Melnykov, V. and Wang, Y. (2023). Conditional mixture modeling and model-based clustering. Pattern Recognition 133, 108994. doi:10.1016/j.patcog.2022.108994 Dahl, D. B. (2006). Model-based clustering for expression data via a Dirichlet process mixture model. In Bayesian Inference for Gene Expression and Proteomics, 201–218. Cambridge University Press.
set.seed(1) n <- 200 x1 <- rnorm(n) x2 <- c(0.5 + x1[1:100]^2, -2 - 0.8 * x1[101:200]^2) + rnorm(n, 0, 0.6) fit <- scmix(cbind(x1, x2), K = 5, m = 2, n_iter = 400, burn = 150, seed = 42) fit$K # curved clusters found from one run table(fit$cluster, rep(1:2, each = 100)) summary(fit)set.seed(1) n <- 200 x1 <- rnorm(n) x2 <- c(0.5 + x1[1:100]^2, -2 - 0.8 * x1[101:200]^2) + rnorm(n, 0, 0.6) fit <- scmix(cbind(x1, x2), K = 5, m = 2, n_iter = 400, burn = 150, seed = 42) fit$K # curved clusters found from one run table(fit$cluster, rep(1:2, each = 100)) summary(fit)
The adjusted Rand index between two partitions (Hubert and Arabie, 1985); label-invariant, 1 for identical partitions, ~0 for unrelated ones.
scmix_ari(a, b)scmix_ari(a, b)
a, b
|
Two label vectors of equal length. |
The adjusted Rand index, a scalar.
a <- rep(1:3, each = 5) b <- c(rep(2:1, each = 5), rep(3, 5)) # same partition, labels permuted scmix_ari(a, b)a <- rep(1:3, each = 5) b <- c(rep(2:1, each = 5), rep(3, 5)) # same partition, labels permuted scmix_ari(a, b)
The validated sampling engine underlying scmix and
scmix_impute, exposed for power users; see the package
source for complete documentation of every argument and output.
scmix_engine(Y, ...)scmix_engine(Y, ...)
Y |
numeric matrix, |
... |
engine arguments; see |
Engine output list; see scmix for main fields.
d <- scmix_sim_mw3(n = 150, seed = 2) eng <- scmix_engine(d$Y, K = 4, m = 1, n_iter = 200, burn = 80, consensus = TRUE, seed = 3) scmix_ari(eng$z_consensus, d$z) # linear conditionals, short run # quadratic conditionals at a more realistic length eng2 <- scmix_engine(d$Y, K = 4, m = 2, n_iter = 400, burn = 200, consensus = TRUE, seed = 3) eng2$Kstar_consensus scmix_ari(eng2$z_consensus, d$z)d <- scmix_sim_mw3(n = 150, seed = 2) eng <- scmix_engine(d$Y, K = 4, m = 1, n_iter = 200, burn = 80, consensus = TRUE, seed = 3) scmix_ari(eng$z_consensus, d$z) # linear conditionals, short run # quadratic conditionals at a more realistic length eng2 <- scmix_engine(d$Y, K = 4, m = 2, n_iter = 400, burn = 200, consensus = TRUE, seed = 3) eng2$Kstar_consensus scmix_ari(eng2$z_consensus, d$z)
Runs the same engine as scmix in multiple-imputation mode
(linear conditionals, m = 1) for a data matrix with missing
values, returning completed data sets and Rubin-pooling utilities.
scmix_impute( Y, M = 10L, K = 10L, n_iter = 1500L, burn = 500L, a = 1/K, seed = NULL, verbose = 0L, ... )scmix_impute( Y, M = 10L, K = 10L, n_iter = 1500L, burn = 500L, a = 1/K, seed = NULL, verbose = 0L, ... )
Y |
numeric matrix with |
M |
number of completed data sets to return. |
K |
integer, overfitted cap on the number of components (the number
of occupied components is estimated; |
n_iter, burn
|
total and burn-in Gibbs sweeps. |
a |
Dirichlet concentration of the mixture weights (default
|
seed |
optional integer seed (full run reproducibility). |
verbose |
print progress every |
... |
further engine arguments. |
List with completed (list of M completed matrices) and
the fitted-model summaries of scmix.
Y <- scmix_sim_mw3(n = 120, seed = 7)$Y set.seed(7) Y[sample(length(Y), 30)] <- NA imp <- scmix_impute(Y, M = 2, K = 4, n_iter = 300, burn = 100, seed = 8) length(imp$completed) anyNA(imp$completed[[1]])Y <- scmix_sim_mw3(n = 120, seed = 7)$Y set.seed(7) Y[sample(length(Y), 30)] <- NA imp <- scmix_impute(Y, M = 2, K = 4, n_iter = 300, burn = 100, seed = 8) length(imp$completed) anyNA(imp$completed[[1]])
Draws one data set from the three-component, quadratic-conditional setting of Melnykov and Wang (2023), supplementary Table S-1 (p = 3), as replicated in the accompanying paper.
scmix_sim_mw3(n = 1000, seed = NULL)scmix_sim_mw3(n = 1000, seed = NULL)
n |
Sample size. |
seed |
Optional seed. |
A list with elements Y (an n x 3 matrix) and
z (the true component labels).
Melnykov, V. and Wang, Y. (2023). Conditional mixture modeling and model-based clustering. Pattern Recognition, 133:108994. doi:10.1016/j.patcog.2022.108994
d <- scmix_sim_mw3(n = 300, seed = 1) dim(d$Y) table(d$z)d <- scmix_sim_mw3(n = 300, seed = 1) dim(d$Y) table(d$z)