| Title: | Deep Mixture Models for Continuous and Mixed-Type Data |
|---|---|
| Description: | Fits Gaussian, Student-t and skew-t deep mixture models to continuous observations, and single-head and two-head latent mixture models to combinations of continuous, binary, ordinal, nominal and count measurements. Mixed-response estimation uses Monte Carlo expectation- maximisation with structured data-derived initialisation. Utilities for posterior clustering, Gower dissimilarity, silhouette evaluation, adjusted Rand index and misclassification rate are provided. Original deep Gaussian mixture models are described by Viroli and McLachlan (2019) <doi:10.1007/s11222-017-9793-z>. |
| Authors: | Jinran Wu [aut, cre], Geoffrey J. McLachlan [aut] |
| Maintainer: | Jinran Wu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-11-25 18:26:38 UTC |
| Source: | https://github.com/cran/MixedDeepMM |
Fit a Deep Skew-t Mixture Model
dstmm( y, layers, k, r, it = 250, eps = 0.001, init = "kmeans", init_est = "factanal", seed = NULL, scale = FALSE, nu = 10, nu_structure = c("common", "first_layer", "pathway"), estimate_nu = TRUE, active_set = 1L, M = 1L, warm_start = NULL, psi_floor = 1e-06, nu_bounds = c(2.05, 200), min_iter = 50L, moving_window = 20L, alpha_tol = 1e-10, ridge = 1e-08, verbose = FALSE )dstmm( y, layers, k, r, it = 250, eps = 0.001, init = "kmeans", init_est = "factanal", seed = NULL, scale = FALSE, nu = 10, nu_structure = c("common", "first_layer", "pathway"), estimate_nu = TRUE, active_set = 1L, M = 1L, warm_start = NULL, psi_floor = 1e-06, nu_bounds = c(2.05, 200), min_iter = 50L, moving_window = 20L, alpha_tol = 1e-10, ridge = 1e-08, verbose = FALSE )
y |
Finite numeric data matrix with observations in rows and variables in columns. |
layers |
Number of latent mixture layers (1, 2, or 3). |
k |
Integer vector containing the number of components in each layer. |
r |
Integer vector of latent dimensions, one per layer. Dimensions must decrease from the observed dimension. |
it |
Maximum number of Monte Carlo EM iterations (default 250). |
eps |
Positive convergence threshold for the relative change in moving-average log-likelihood. |
init |
Initial clustering method: "kmeans", "random", "hclass", or "mclust". The last method requires the suggested package mclust. |
init_est |
Initial latent parameter estimation method: "factanal" or "ppca". |
seed |
Optional random seed. NULL leaves the current random-number state unchanged. |
scale |
Logical; if TRUE, standardize the input variables before fitting. |
nu |
Initial degrees of freedom, strictly greater than 2. A scalar or a vector compatible with nu_structure. |
nu_structure |
How degrees of freedom are shared: "common" (one value), "first_layer" (per first-layer component), or "pathway" (per complete path). |
estimate_nu |
Logical; if TRUE, update the degrees of freedom during fitting; otherwise hold them fixed. |
active_set |
Indices of layers permitted to have nonzero skewness vectors (default 1L). |
M |
Number of Monte Carlo draws per observation-path pair. M = 1 corresponds to stochastic EM. |
warm_start |
Optional previously fitted robust deep mixture model object used for initialization; NULL initializes from data. |
psi_floor |
Positive numerical floor used to keep covariance matrices positive definite. |
nu_bounds |
Length-two vector of lower and upper bounds for degrees-of-freedom estimation, with lower bound greater than 2. |
min_iter |
Minimum iteration number before convergence can stop the algorithm. |
moving_window |
Number of iterations in each of the two log-likelihood windows used to assess convergence. |
alpha_tol |
Nonnegative numerical tolerance for treating the skewness contribution as zero. |
ridge |
Nonnegative regularization value used in latent parameter updates. |
verbose |
Logical; if TRUE, print progress messages during fitting. |
An object of class "dstmm" containing the fitted model and diagnostics.
A unified model interface using existing continuous DGMM, RDMM and DStMM engines and a new single- or two-head mixed-response Monte Carlo EM estimator. Mixed Student-t and skew-t kernels extend the Gaussian formulation.
mixeddeepmm( data, types = NULL, family = c("gaussian", "t", "skew-t"), heads = c("single", "two"), layers, control = list() )mixeddeepmm( data, types = NULL, family = c("gaussian", "t", "skew-t"), heads = c("single", "two"), layers, control = list() )
data |
Data frame or all-numeric matrix of observations. Missing values are not supported. |
types |
Named character vector assigning every column one of |
family |
Latent kernel: Gaussian, Student-t or generalised-hyperbolic skew-t. |
heads |
One shared latent head, or separate continuous/discrete heads with shared deeper tail. |
layers |
List with |
control |
Fitting controls: |
For mixed responses the latent Gaussian hierarchy and measurement model are fitted using posterior draws conditional on continuous responses, importance weighted by non-Gaussian response likelihoods. Each fit saves a separate Monte Carlo approximation to the observed log likelihood for model comparison, with a delta-method integration-error estimate. The mixed Gaussian estimator uses the original paper's conditional Gaussian and GLLVM design with a component-specific two-head continuous measurement and one shallow Gaussian-mixture tail; it is not a full reimplementation of the published MDGMM estimation algorithm. Its structured PCA/indicator, clustering, and regression-based initialization is not the published NSEP algorithm; it uses no random initial parameter draws. MCEM integration still involves random sampling. Numerical integration and estimation sensitivity should be examined for the mixed Student-t and skew-t extensions. BIC counts the represented coefficients under reference-location constraints; residual factor rotational non-identifiability may affect interpretation.
A fitted object of class mixeddeepmm, supporting print, summary, predict, logLik, fitted, and plot.
sim <- simulate_mixeddeepmm(n = 40, seed = 1) fit <- mixeddeepmm(sim$data, sim$types, layers = list(k = c(2,2), r = c(2,1)), control = list(max_iter = 2, min_iter = 2, mc_samples = 8, mc_eval = 16)) print(fit)sim <- simulate_mixeddeepmm(n = 40, seed = 1) fit <- mixeddeepmm(sim$data, sim$types, layers = list(k = c(2,2), r = c(2,1)), control = list(max_iter = 2, min_iter = 2, mc_samples = 8, mc_eval = 16)) print(fit)
Evaluate an estimated partition against independent known labels.
mixeddeepmm_ari(truth, predicted)mixeddeepmm_ari(truth, predicted)
truth |
Known cluster labels. |
predicted |
Estimated labels. |
Adjusted Rand index numeric scalar.
Summarise Monte Carlo error, log-likelihood trace, starts and iteration counts. The result omits an end-of-run convergence flag.
mixeddeepmm_diagnostics(object)mixeddeepmm_diagnostics(object)
object |
A fitted |
List of fitting and Monte Carlo precision diagnostics.
Construct a single mixed-type dissimilarity matrix with equal
variable weights using cluster::daisy(metric="gower"). Binary and
nominal predictors are symmetric categorical variables; ordinal predictors
are ordered; continuous/count predictors are range-normalised numeric.
mixeddeepmm_gower_distance(data, types)mixeddeepmm_gower_distance(data, types)
data |
Complete mixed-response predictors, without the external truth. |
types |
Named character vector defining continuous, count, binary, nominal and ordinal response types. |
A dist/dissimilarity object.
mixeddeepmm_gower_silhouette
Compute the average silhouette width via
cluster::silhouette. Returns NA_real_ for partitions with
fewer than two or at least n nonempty groups. This score evaluates a
completed clustering, not an EM objective or a replacement for MCEM.
mixeddeepmm_gower_silhouette(clusters, distance)mixeddeepmm_gower_silhouette(clusters, distance)
clusters |
One cluster label per observation; external true labels are not used. |
distance |
Precomputed |
Numeric mean silhouette width, or NA_real_.
mixeddeepmm_gower_distance
Fit a supplied list of candidate architectures and compare observed log likelihood approximations and BIC.
mixeddeepmm_grid(data, types = NULL, candidates, control = list())mixeddeepmm_grid(data, types = NULL, candidates, control = list())
data |
Data frame. |
types |
Response type specification; see |
candidates |
List of named lists containing |
control |
Control settings passed to each model. |
Monte Carlo likelihood error affects BIC uncertainty. BIC is an approximate fit criterion and does not itself measure clustering quality.
List with comparison table and fits.
Compute the minimum misclassification rate (MR) after optimally matching predicted cluster labels to known class labels, using one-to-one assignment.
mixeddeepmm_mr(truth, predicted)mixeddeepmm_mr(truth, predicted)
truth |
Nonempty vector of reference class labels, without missing values. |
predicted |
Nonempty vector of estimated cluster labels, without missing values. |
Cluster labels are arbitrary. The Hungarian algorithm finds the one-to-one correspondence maximising the diagonal contingency-table count, with zero padding for unequal numbers of reference classes and predicted clusters. Unmatched groups therefore contribute errors. Reference labels must be kept out of unsupervised fitting and model selection.
A numeric scalar between 0 and 1: 0 is perfect agreement and smaller is better.
mixeddeepmm_mr(c("A", "A", "B", "B"), c(9, 9, 4, 4)) mixeddeepmm_mr(c("A", "A", "B", "B"), c(9, 9, 4, 9))mixeddeepmm_mr(c("A", "A", "B", "B"), c(9, 9, 4, 4)) mixeddeepmm_mr(c("A", "A", "B", "B"), c(9, 9, 4, 9))
Obtain posterior probabilities of latent pathways, their marginal layer probabilities, classifications or model-implied response means/probabilities.
## S3 method for class 'mixeddeepmm' predict( object, newdata = NULL, type = c("cluster", "posterior", "path", "layer", "response"), layer = NULL, mc_samples = NULL, cluster_level = c( "paper", "first", "shared_tail", "continuous_head", "discrete_head" ), ... ) ## S3 method for class 'mixeddeepmm' fitted(object, ...)## S3 method for class 'mixeddeepmm' predict( object, newdata = NULL, type = c("cluster", "posterior", "path", "layer", "response"), layer = NULL, mc_samples = NULL, cluster_level = c( "paper", "first", "shared_tail", "continuous_head", "discrete_head" ), ... ) ## S3 method for class 'mixeddeepmm' fitted(object, ...)
object |
Fitted |
newdata |
Optional data frame with the same named columns and known categorical levels. |
type |
Return specified-layer MAP classification ( |
layer |
Optional integer layer index for |
mc_samples |
Override MC importance sample size when predicting mixed data. |
cluster_level |
Named layer when layer is NULL: paper uses the common first layer for single head and shared tail for two heads; first selects layer 1; shared_tail selects the last layer. Head options are available as indicated by the architecture. |
... |
Additional arguments. |
By default cluster_level="paper" selects the first common head in single-head models and the shared tail in two-head models. When predicting link probabilities, observed responses inform the latent posterior. Thus the estimates are conditional fitted probabilities and are not leave-one-out predictive scores.
Numeric vector, matrix or named list of fitted values, according to type.
Simulate the manuscript's three-continuous and five-discrete response design, with three generating classes.
simulate_mixeddeepmm(n = 600L, seed = 2026L)simulate_mixeddeepmm(n = 600L, seed = 2026L)
n |
Sample size (at least 30). |
seed |
Random seed. |
List with data, types, group, and latent.
sim <- simulate_mixeddeepmm(n = 50, seed = 42) str(sim$data)sim <- simulate_mixeddeepmm(n = 50, seed = 42) str(sim$data)
Display goodness of fit, Monte Carlo precision, iteration count and likelihood history (without an end-of-run convergence flag).
## S3 method for class 'mixeddeepmm' summary(object, ...) ## S3 method for class 'mixeddeepmm' print(x, ...) ## S3 method for class 'summary.mixeddeepmm' print(x, ...) ## S3 method for class 'mixeddeepmm' logLik(object, ...) ## S3 method for class 'mixeddeepmm' plot(x, ...)## S3 method for class 'mixeddeepmm' summary(object, ...) ## S3 method for class 'mixeddeepmm' print(x, ...) ## S3 method for class 'summary.mixeddeepmm' print(x, ...) ## S3 method for class 'mixeddeepmm' logLik(object, ...) ## S3 method for class 'mixeddeepmm' plot(x, ...)
object |
A |
x |
A model or summary object. |
... |
Other options passed to plot, as appropriate. |
A summary list, an invisible object for print/plot, or logLik object.