Estimates latent profiles (finite mixture models) using the open source package mclust, or the commercial program Mplus (using the R-interface of MplusAutomation).

estimate_profiles(
df,
n_profiles,
models = NULL,
variances = "equal",
covariances = "zero",
package = "mclust",
select_vars = NULL,
...
)

## Arguments

df data.frame of numeric data; continuous indicators are required for mixture modeling. Integer vector of the number of profiles (or mixture components) to be estimated. Integer vector. Set to NULL by default, and models are constructed from the variances and covariances arguments. See Details for the six models available in tidyLPA. Character vector. Specifies which variance components to estimate. Defaults to "equal" (constrain variances across profiles); the other option is "varying" (estimate variances freely across profiles). Each element of this vector refers to one of the models you wish to run. Character vector. Specifies which covariance components to estimate. Defaults to "zero" (do not estimate covariances; this corresponds to an assumption of conditional independence of the indicators); other options are "equal" (estimate covariances between items, constrained across profiles), and "varying" (free covariances across profiles). Character. Which package to use; 'mclust' or 'MplusAutomation' (requires Mplus to be installed). Default: 'mclust'. Character. Optional vector of variable names in df, to be used for model estimation. Defaults to NULL, which means all variables in df are used. Additional arguments are passed to the estimating function; i.e., Mclust, or mplusModeler.

## Value

A list of class 'tidyLPA'.

## Details

Six models are currently available in tidyLPA, corresponding to the most common requirements. These are:

1. Equal variances and covariances fixed to 0

2. Varying variances and covariances fixed to 0

3. Equal variances and equal covariances

4. Varying variances and equal covariances (not able to be fit w/ mclust)

5. Equal variances and varying covariances (not able to be fit w/ mclust)

6. Varying variances and varying covariances

Two interfaces are available to estimate these models; specify their numbers in the models argument (e.g., models = 1, or models = c(1, 2, 3)), or specify the variances/covariances to be estimated (e.g.,: variances = c("equal", "varying"), covariances = c("zero", "equal")). Note that when mclust is used, models = c(1, 2, 3, 6) are the only models available.

## Examples


iris_sample <- iris[c(1:4, 51:54, 101:104), ] # to make example run more quickly

# Example 1:
iris_sample %>%
subset(select = c("Sepal.Length", "Sepal.Width",
"Petal.Length")) %>%
estimate_profiles(3)
#> tidyLPA analysis using mclust:
#>
#>  Model Classes AIC   BIC   Entropy prob_min prob_max n_min n_max BLRT_p
#>  1     3       62.15 68.94 1.00    1.00     1.00     0.17  0.50  0.01
# \donttest{
# Example 2:
iris %>%
subset(select = c("Sepal.Length", "Sepal.Width",
"Petal.Length")) %>%
estimate_profiles(n_profiles = 1:4, models = 1:3)
#> The 'variances'/'covariances' arguments were ignored in favor of the 'models' argument.#> tidyLPA analysis using mclust:
#>
#>  Model Classes AIC     BIC     Entropy prob_min prob_max n_min n_max BLRT_p
#>  1     1       1150.81 1168.87 1.00    1.00     1.00     1.00  1.00
#>  1     2       885.64  915.74  0.99    1.00     1.00     0.34  0.66  0.01
#>  1     3       765.16  807.31  0.93    0.94     1.00     0.27  0.40  0.01
#>  1     4       758.71  812.90  0.87    0.70     0.96     0.09  0.39  0.03
#>  2     1       1150.81 1168.87 1.00    1.00     1.00     1.00  1.00
#>  2     2       770.96  810.10  1.00    1.00     1.00     0.33  0.67  0.01
#>  2     3       702.55  762.76  0.89    0.91     1.00     0.31  0.35  0.01
#>  2     4       695.51  776.80  0.88    0.91     0.95     0.09  0.35  0.09
#>  3     1       851.33  878.43  1.00    1.00     1.00     1.00  1.00
#>  3     2       693.26  732.40  1.00    1.00     1.00     0.33  0.67  0.01
#>  3     3       650.14  701.32  0.92    0.94     1.00     0.33  0.34  0.01
#>  3     4       646.81  710.03  0.90    0.71     0.97     0.05  0.34  0.07
# Example 3:
iris_sample %>%
subset(select = c("Sepal.Length", "Sepal.Width",
"Petal.Length")) %>%
estimate_profiles(n_profiles = 1:4, variances = c("equal", "varying"),
covariances = c("zero", "zero"))
#> Warning: some model(s) could not be fitted!#> Warning: Mclust could not estimate model 2 with 4 classes.#> Warning:
#> One or more analyses resulted in warnings! Examine these analyses carefully: model_2_class_4#> tidyLPA analysis using mclust:
#>
#>  Model Classes AIC   BIC   Entropy prob_min prob_max n_min n_max BLRT_p
#>  1     1       96.05 98.96 1.00    1.00     1.00     1.00  1.00
#>  1     2       72.38 77.23 1.00    1.00     1.00     0.33  0.67  0.01
#>  1     3       62.15 68.94 1.00    1.00     1.00     0.17  0.50  0.03
#>  1     4       66.44 75.17 0.97    0.98     1.00     0.08  0.33  0.70
#>  2     1       96.05 98.96 1.00    1.00     1.00     1.00  1.00
#>  2     2       60.10 66.40 1.00    1.00     1.00     0.33  0.67  0.01
#>  2     3       58.86 68.56 1.00    1.00     1.00     0.17  0.50  0.36
#>  2     4                                                               # }