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] <- lapply(mtcars[, factors], factor)