*! version 1.0.1 12jun2023

Title

lcaentropy -- Calculate entropy for models with categorical latent variables

Syntax

lcaentropy
[,
force]

options

force Forces the calculation of entropy when small values of p result in missing values of ln(p) by replacing p*ln(p) with 0 in those cases.

Description

lcaentropy calculates entropy after a model with one or more categorical latent variables (e.g. latent class or latent profile models) is estimated using gsem. Entropy can be described as a measure of certainty of
posterior classification. The measure of entropy implemented by lcaentropy was first described by Ramaswamy, DeSarbo, Reibstein, and Robinson (1993), and is commonly described in the latent class analysis literature (see, for example, Collins and Lanza, 2010). lcaentropy uses the predicted posterior latent class probabilities generated by predict (see gsem_predict).

When the model contains more than one categorical latent variable, lcaentropy returns entropy calculated across all combinations of the categorical latent variables, as well as entropy for each latent variable separately.

Options

force prevents an error when small predicted probabilities result in missing values. Calculating entropy requires the evaluation of p*ln(p) where it p is the predicted posterior
probability of each observation belonging to a given class. When p < 1e-323, the function ln() returns a missing value. By default lcaentropy returns an error when values of p are
sufficiently small to result in a missing value from ln(). Using force effectively sets p*ln(p) to 0 for that observation in the particular class.

Examples

Setup

. webuse gsem_lca1

. gsem (accident play insurance stock <- ), logit lclass(C 2)

Calculate entropy

. lcaentropy

Stored results

lcaentropy stores the following in r():

Scalars

r(entropy) Entropy across all categorical latent variables

Matrices

r(class_entropy) Entropy for each class

References

Collins, L. M., & Lanza, S. T. (2009). Latent class and latent transition analysis: With applications in the social, behavioral, and health sciences (Vol. 718). John Wiley & Sons.

Ramaswamy, V., DeSarbo, W. S., Reibstein, D. J., & Robinson, W. T. (1993). An empirical pooling approach for estimating marketing mix elasticities with PIMS data. Marketing science, 12(1), 103-124.

Author

RA Medeiros

RA Medeiros Statistical Consulting

ramedeiros@ramstat.com