estimate_profiles: Estimate latent profiles

Description Usage Arguments Details Value Examples

View source: R/estimate-profiles.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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.

n_profiles

Integer vector of the number of profiles (or mixture components) to be estimated.

models

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.

variances

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.

covariances

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).

package

Character. Which package to use; 'mclust' or 'MplusAutomation' (requires Mplus to be installed). Default: 'mclust'.

select_vars

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.

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.

Value

A list of class 'tidyLPA'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)


# Example 2:
iris %>%
  subset(select = c("Sepal.Length", "Sepal.Width",
    "Petal.Length")) %>%
  estimate_profiles(n_profiles = 1:4, models = 1:3)

# 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"))

data-edu/tidyLPA documentation built on Feb. 13, 2020, 9:45 a.m.