The order of class labels in LCA is arbitrary. This can result in a phenomenon called 'label switching', where classes change places between replications of an analysis. This function attempts to re-order classes in a substantively meaningful way.
Arguments
- x
An
MxModelestimated bymx_mixtureor one of its wrappers.- param
The parameter by which to order the classes, defaults to
'weights', which orders classes based on their sample size.- decreasing
logical. Should the classes be sorted in increasing or decreasing order? Default: TRUE
- order
Integer, indicating the ordering of classes. Ignored when NULL (default).
Details
The argument param can accept either:
The default string "weights", in which classes are sorted by size.
The
OpenMxmatrix indicator for a specific model parameter; e.g., the first mean is indicated by"M[1,1]". These indicators can be viewed by runningtable_results(x, columns = NULL).The letter indicating an
OpenMxmodel matrix, e.g.,"M"refers to the matrix of means. To account for all elements of the matrix, Euclidean distance to the origin is used.
Examples
if (FALSE) { # \dontrun{
df <- iris[1:4]
names(df) <- letters[1:4]
res1 <- mx_profiles(data = df, classes = 2)
mx_switch_labels(res1, decreasing = FALSE)
} # }