| cluster_mmm | R Documentation |
Fits a mixture of Markov chains to sequence data and returns a
netobject_group containing per-cluster transition networks.
This is the MMM equivalent of cluster_network (which uses
distance-based clustering); both functions share the
cluster_by = ... surface argument so the call shape stays
uniform across clustering families.
cluster_mmm(
data,
k = 2L,
n_starts = 50L,
max_iter = 200L,
tol = 1e-06,
smooth = 0.01,
seed = NULL,
covariates = NULL,
covariate_effect = c("em", "posthoc"),
estimator = c("auto", "firth", "multinom", "chisq"),
cluster_by = "mmm",
...
)
data |
A data.frame (wide format), |
k |
Integer. Whole finite number of mixture components, >= 2. Default: 2. |
n_starts |
Integer. Positive whole finite number of random restarts. Default: 50. |
max_iter |
Integer. Positive whole finite maximum EM iterations per start. Default: 200. |
tol |
Numeric. Finite positive convergence tolerance. Default: 1e-6. |
smooth |
Numeric. Finite non-negative Laplace smoothing constant. Default: 0.01. |
seed |
Integer or NULL. Random seed. |
covariates |
Optional. Covariates integrated into the EM algorithm
to model covariate-dependent mixing proportions. Accepts a string,
character vector, formula, or data.frame (same forms as
|
covariate_effect |
How |
estimator |
Multinomial fitter for the post-hoc covariate
analysis (does not affect EM): |
cluster_by |
Character. Accepted only as |
... |
Unsupported. Supplying unused arguments raises an error. |
For the full net_mmm object with posterior probabilities, model
fit statistics, and S3 methods, use build_mmm instead.
A netobject_group (list of netobjects, one per
cluster). MMM-specific information is stored in
attr(, "clustering") (class "net_mmm_clustering"):
Integer vector of cluster assignments.
Number of clusters.
N x k matrix of posterior probabilities.
Mixing proportions.
List with AvePP, entropy, classification error.
Model fit statistics.
The full N-row sequence frame, matching
$assignments – so sequence_plot and
distribution_plot can recover both.
build_mmm for the full MMM object,
cluster_network for distance-based clustering
seqs <- data.frame(V1 = sample(c("A","B","C"), 30, TRUE),
V2 = sample(c("A","B","C"), 30, TRUE))
grp <- cluster_mmm(seqs, k = 2, n_starts = 1, max_iter = 10, seed = 1)
grp[[1]]$weights
attr(grp, "clustering")$assignments
# Visualise with sequence_plot
seqs <- data.frame(
V1 = sample(LETTERS[1:3], 40, TRUE),
V2 = sample(LETTERS[1:3], 40, TRUE),
V3 = sample(LETTERS[1:3], 40, TRUE)
)
grp <- cluster_mmm(seqs, k = 2)
sequence_plot(grp, type = "index")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.