Learn R Programming

LCPA (version 1.0.0)

get.entropy: Calculate Classification Entropy

Description

Computes the relative entropy statistic to evaluate classification quality in Latent Class Analysis (LCA) or Latent Profile Analysis (LPA) models. Entropy measures how accurately cases are assigned to latent classes based on posterior probabilities, with values closer to 1 indicating better separation between classes.

Usage

get.entropy(object)

Value

A numeric value between 0 and 1 representing the relative entropy (Nylund-Gibson et al., 2018; Clark et al., 2013):

  • 1.0: Perfect classification (each case belongs exclusively to one class)

  • 0.8-1.0: Good classification quality

  • 0.6-0.8: Moderate classification quality

  • < 0.6: Poor classification quality (consider model simplification)

Calculated using the formula: $$1 - \frac{\sum_{n=1}^N \sum_{l=1}^L -p_{nl} \ln(p_{nl})}{N \ln(L)}$$

where:

  • \(N\) = Sample size

  • \(L\) = Number of latent classes

  • \(p_{nl}\) = Posterior probability of observation \(n\) belonging to class \(l\)

Arguments

object

An object of class "LCA" or "LPA" returned by LCA or LPA functions, or any other object containing:

  • P.Z.Xn: \(N \times L\) matrix of posterior class probabilities for each observation.

  • params$P.Z: Vector of length \(L\) with latent class prior probabilities.

References

Nylund-Gibson, K., & Choi, A. Y. (2018). Ten frequently asked questions about latent class analysis. Translational Issues in Psychological Science, 4(4), 440-461. https://doi.org/10.1037/tps0000176

Clark, S. L., Muthén, B., Kaprio, J., D'Onofrio, B. M., Viken, R., & Rose, R. J. (2013). Models and Strategies for Factor Mixture Analysis: An Example Concerning the Structure Underlying Psychological Disorders. Structural Equation Modeling: A Multidisciplinary Journal, 20(4), 681-703. https://doi.org/10.1080/10705511.2013.824786

Examples

Run this code
# Example with simulated data
set.seed(123)
data.obj <- sim.LCA(N = 500, I = 4, L = 2, IQ=0.9)
response <- data.obj$response

# Fit 2-class model with EM algorithm
# \donttest{
fit.em <- LCA(response, L = 2, method = "EM", nrep = 10)

entropy_value <- get.entropy(fit.em)
cat("Classification entropy:", round(entropy_value, 3), "\n")

# }

Run the code above in your browser using DataLab