enumerate_lca: Compare latent class models

View source: R/lpa.R

enumerate_lcaR Documentation

Compare latent class models

Description

Fits single-level latent class models with each number of classes in n_classes and returns them in one table for comparison by information criteria, entropy and the diagnostics of each fit. Every indicator is categorical unless named in ordinal or count, as in lca(). It is enumerate_classes() with id = NULL, and it returns the same object; the number of classes is its n_profiles column.

Usage

enumerate_lca(data, vars, n_classes = 1:4, ...)

Arguments

data

A data frame with one row per observation.

vars

Names of the categorical indicator columns.

n_classes

Positive whole numbers of classes to compare.

...

Further arguments for multilca(), such as missing, n_starts, seed and min_probability, except id, n_group_classes and categorical.

Details

For observations nested in groups, use enumerate_classes() with the grouping column as id and the indicators as categorical.

Value

An object of class multilpa_enumeration, as enumerate_classes() returns: as.data.frame() gives one row per candidate, summary() the candidate each criterion prefers, plot() the criteria against the number of classes, and candidate_fit() one fitted candidate, named by its n_profiles.

Conditions

latents_bad_argument when id, n_group_classes, categorical or model is passed.

See Also

lca() to fit one model; enumerate_lpa() for continuous indicators.

Examples

models <- enumerate_lca(student_esm, c("time_with_friends",
                                       "on_social_media", "sports"),
                        n_classes = 1:3, n_starts = 2, seed = 1)
summary(models)

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