Latent class models

Latent Class Analysis (LCA) is a method for identifying latent variables among polychromous outcome variables. It is similar to factor analysis, but can be used with discrete/categorical data. To this end, LCA is mostly used when analyzing surveys.

In this section, we are going to use the poLCA function from the poLCA package. It uses expectation-maximization and Newton-Raphson algorithms for finding the maximum likelihood for the parameters.

The poLCA function requires the data to be coded as integers starting from one or as a factor, otherwise it will produce an error message. To this end, let's transform some of the variables in the mtcars dataset to factors:

> factors <- c('cyl', 'vs', 'am', 'carb', 'gear')
> mtcars[, factors] ...

Get Mastering Data Analysis with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.