mixture_starts: Automatically set starting values for an OpenMx mixture model

View source: R/mx_mixture.R

mixture_startsR Documentation

Automatically set starting values for an OpenMx mixture model

Description

Automatically set starting values for an OpenMx mixture model. This function was designed to work with mixture models created using tidySEM functions like mx_mixture, and may not work with other mxModels.

Usage

mixture_starts(model, splits, ...)

Arguments

model

A mixture model of class mxModel.

splits

Optional. A numeric vector of length equal to the number of rows in the mxData used in the model object. The data will be split by this vector. See Details for the default setting and possible alternatives.

...

Additional arguments, passed to functions.

Details

Starting values are derived by the following procedure:

  1. The mixture model is converted to a multi-group model.

  2. The data are split along splits, and assigned to the corresponding groups of the multi-group model.

  3. The multi-group model is run, and the final values of each group are assigned to the corresponding mixture component as starting values.

  4. The mixture model is returned with these starting values.

If the argument splits is not provided, the function will call kmeans(x = data, centers = classes)$cluster, where data is extracted from the model argument.

Sensible ways to split the data include:

  • Using Hierarchical clustering: cutree(hclust(dist(data)), k = classes))

  • Using K-means clustering: kmeans(x = data, centers = classes)$cluster

  • Using agglomerative hierarchical clustering: hclass(hc(data = data), G = classes)[, 1]

  • Using a random split: sample.int(n = classes, size = nrow(data), replace = TRUE)

Value

Returns an mxModel with starting values.

References

Shireman, E., Steinley, D. & Brusco, M.J. Examining the effect of initialization strategies on the performance of Gaussian mixture modeling. Behav Res 49, 282–293 (2017). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3758/s13428-015-0697-6")}

Van Lissa, C. J., Garnier-Villarreal, M., & Anadria, D. (2023). Recommended Practices in Latent Class Analysis using the Open-Source R-Package tidySEM. Structural Equation Modeling. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10705511.2023.2250920")}

Examples

## Not run: 
df <- iris[, 1, drop = FALSE]
names(df) <- "x"
mod <- mx_mixture(model = "x ~ m{C}*1
                           x ~~ v{C}*x",
                           classes = 2,
                           data = df,
                           run = FALSE)
mod <- mixture_starts(mod)

## End(Not run)

tidySEM documentation built on Oct. 25, 2023, 1:06 a.m.