lca: Latent class analysis

View source: R/lpa.R

lcaR Documentation

Latent class analysis

Description

Fits a single-level latent class model: each observation belongs to one of n_classes unobserved classes, and within a class the discrete indicators are independent. Categorical indicators have unrestricted response probabilities; ordinal and count in ... choose the structured measurement models described by multilpa(). It is the model multilca() fits with id = NULL, and it returns the same object, so every accessor, plot and inference verb of the package applies to it. In the results the classes are labelled profile_1, profile_2, and so on, as throughout the package.

Usage

lca(data, vars, n_classes, ...)

Arguments

data

A data frame with one row per observation.

vars

Names of the discrete indicator columns. Categories are taken from the data; ordinal and count in ... identify structured discrete indicators and the remaining columns are categorical.

n_classes

Number of classes, a positive whole number.

...

Further arguments for multilca(), such as missing, n_starts, seed, min_probability and profile_covariates, except id and n_group_classes, which a single-level model does not have.

Details

For observations nested in groups, use multilca() with the grouping column as id, which adds latent classes of groups above the classes of observations.

Value

A fitted multilpa object, as multilca() returns.

Conditions

latents_bad_argument when id or n_group_classes is passed; the conditions multilca() raises otherwise.

References

Lazarsfeld, P. F., & Henry, N. W. (1968). Latent Structure Analysis. Houghton Mifflin.

See Also

lpa() for continuous indicators; multilca() for the two-level model; enumerate_lca() to compare numbers of classes.

Examples

fit <- lca(student_esm, c("time_with_friends", "on_social_media",
                          "tv_video_games", "sports"),
           n_classes = 2, n_starts = 3, seed = 1)
fit
plot(fit, what = "heatmap")

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