enumerate_classes: Enumerate numbers of individual profiles and group classes

View source: R/enumeration.R

enumerate_classesR Documentation

Enumerate numbers of individual profiles and group classes

Description

Fits every requested combination and retains errors and warnings alongside successful fits. Information criteria are descriptive: neither the smallest BIC nor high entropy guarantees the correct number of classes. Unconverged, boundary, and unreplicated fits are reported, not silently selected.

Usage

enumerate_classes(
  data,
  vars,
  id,
  n_profiles = 1:4,
  n_group_classes = 1:3,
  model = "basic",
  seed = NULL,
  family = "profiles",
  between_variance = c("varying", "equal"),
  time = NULL,
  ...
)

Arguments

data

Data frame.

vars

Continuous indicator names.

id

The column that identifies the groups the observations are nested in (students in schools, reports in students). NULL enumerates single-level models, with a message; enumerate_lpa() and enumerate_lca() fit those by name.

n_profiles

Positive integer profile counts to try.

n_group_classes

Positive integer group-class counts to try. With id = NULL it is 1 and may be left out.

model

The covariance structures to cross with the class counts. "basic", the default, fits the four structures that combine variances equal or varying across profiles with covariances absent or present: "EEI" (equal variances, no covariances), "VVI" (varying variances, no covariances), "EEE" (one covariance matrix shared by all profiles) and "VVV" (a covariance matrix for each profile). They are the choices that matter most in practice, since omitting covariances between correlated indicators makes the grid favour additional profiles. "all" fits all 14 structures of Celeux and Govaert (1995). Otherwise name the structures by their three-letter codes, as multilpa()'s model takes them: the letters give the volume, shape and orientation of each profile's covariance matrix, each equal (E) or varying (V) across profiles, with I for no covariances. NULL crosses no structures and fits whatever the other arguments ask for. With one continuous indicator the structures reduce to equal or varying variance, and codes that coincide are fitted once; with only categorical indicators there is no structure to cross. A structure set through variance_model, covariance_model, volume, shape or orientation replaces the default.

seed

Optional reproducible seed for each fit.

family

"profiles" (the default) enumerates the profile model over n_profiles, n_group_classes and model. One or more of the group-class families "additive", "dispersion" and "additive_dispersion" enumerates those instead, over family, n_group_classes and between_variance; n_profiles and model are then refused, and the result is a latents_family_enumeration read with get_results.latents_family_enumeration() and candidate_fit().

between_variance

For group-class families: the between-variance restrictions to cross, "varying", "equal" or both (the default). The dispersion family is always fitted with "equal".

time

The occasion column: enumerate latent transition models (lta()) over n_profiles (default 2:4) and n_group_classes (default 1), holding every other lta() argument given in ... fixed. model, when given, crosses those covariance structures. The result is a latents_transition_enumeration, read with get_results.latents_transition_enumeration() and candidate_fit().

...

Further arguments to multilpa() (or to lta() with time); for group-class families only n_starts, max_iter, tol and min_variance.

Value

An object of class multilpa_enumeration. Read it with the verbs that describe it rather than by reaching into it: as.data.frame() gives one row per candidate model with every criterion and diagnostic, summary() gives one row per information criterion naming the candidate that minimises it, plot() draws one criterion across the grid, and candidate_fit() returns the fitted model for one cell of the grid.

Conditions

latents_bad_argument when model names an unknown structure, when it is given together with another way of setting the structure, or when it is given although every indicator is categorical.

References

Celeux, G., & Govaert, G. (1995). Gaussian parsimonious clustering models. Pattern Recognition, 28(5), 781–793.

See Also

candidate_fit() to take one fitted model out of the grid, summary.multilpa_enumeration() for the criterion-by-criterion comparison.

Examples

set.seed(1)
d <- data.frame(g = rep(1:10, each = 10), y = rnorm(100))
candidates <- enumerate_classes(d, "y", "g", n_profiles = 1:2,
                              n_group_classes = 1, n_starts = 2, seed = 1)
as.data.frame(candidates)
summary(candidates)

# Single level, crossing class counts with two named structures:
single <- enumerate_lpa(iris, c("Sepal.Length", "Sepal.Width",
                                "Petal.Length", "Petal.Width"),
                        n_profiles = 1:3, model = c("VVV", "EEE"),
                        n_starts = 2, seed = 1)
summary(single)

latents documentation built on Oct. 16, 2026, 5:09 p.m.