mplus.lca | R Documentation |
This function writes Mplus input files for conducting latent class analysis (LCA)
for continuous, count, ordered categorical, and unordered categorical variables.
LCA with continuous indicator variables are based on six different
variance-covariance structures, while LCA for all other variable types assume
local independence. By default, the function conducts LCA with continuous
variables and creates folders in the current working directory for each of the
six sets of analysis, writes Mplus input files for conducting LCA with
k = 1 to k = 6 classes into these folders, and writes the matrix
or data frame specified in x
into a Mplus data file in the current working
directory. Optionally, all models can be estimated by setting the argument
mplus.run
to TRUE
.
mplus.lca(x, ind = NULL,
type = c("continuous", "count", "categorical", "nominal"), cluster = NULL,
folder = c("A_Invariant-Theta_Diagonal-Sigma",
"B_Varying-Theta_Diagonal-Sigma",
"C_Invariant-Theta_Invariant-Unrestrictred-Sigma",
"D_Invariant-Theta_Varying-Unrestricted-Sigma",
"E_Varying-Theta_Invariant-Unrestricted-Sigma",
"F_Varying-Theta_Varying-Unrestricted-Sigma"),
file = "Data_LCA.dat", write = c("all", "folder", "data", "input"),
useobservations = NULL, missing = -99, classes = 6, estimator = "MLR",
starts = c(100, 50), stiterations = 10, lrtbootstrap = 1000,
lrtstarts = c(0, 0, 100, 50), processors = c(8, 8),
output = c("all", "SVALUES", "CINTERVAL", "TECH7", "TECH8", "TECH11", "TECH14"),
replace.inp = FALSE, mplus.run = FALSE, Mplus = "Mplus",
replace.out = c("always", "never", "modified"), check = TRUE)
x |
a matrix or data frame. Note that all variable names must be no longer than 8 character. |
ind |
a character vector indicating the variables names of the
latent class indicators in |
type |
a character string indicating the variable type of the
latent class indicators, i.e., |
cluster |
a character string indicating the cluster variable in
the matrix or data frame specified in |
folder |
a character vector with six character strings for specifying
the names of the six folder representing different
variance-covariance structures for conducting LCA with
continuous indicator variables. There is only one folder
for LCA with all other variable types which is called
|
file |
a character string naming the Mplus data file with or
without the file extension '.dat', e.g., |
write |
a character string or character vector indicating whether
to create the six folders specified in the argument
|
useobservations |
a character string indicating the conditional statement to select observations. |
missing |
a numeric value or character string representing missing
values ( |
classes |
an integer value specifying the maximum number of classes for the latent class analysis. By default, LCA with a maximum of 6 classes is specified (i.e., k = 1 to k = 6). |
estimator |
a character string for specifying the |
starts |
a vector with two integer values for specifying the
|
stiterations |
an integer value specifying the |
lrtbootstrap |
an integer value for specifying the |
lrtstarts |
a vector with four integer values for specifying the
|
processors |
a vector of one or two integer values for specifying the
|
output |
a character string or character vector specifying the
|
replace.inp |
logical: if |
mplus.run |
logical: if |
Mplus |
a character string for specifying the name or path of the Mplus executable to be used for running models. This covers situations where Mplus is not in the system's path, or where one wants to test different versions of the Mplus program. Note that there is no need to specify this argument for most users since it has intelligent defaults. |
replace.out |
a character string for specifying three settings, i.e.,
|
check |
logical: if |
Latent class analysis (LCA) is a model-based clustering and classification method used to identify qualitatively different classes of observations which are unknown and must be inferred from the data. LCA can accommodate continuous, count, binary, ordered categorical, and unordered categorical indicators. LCA with continuous indicator variables are also known as latent profile analysis (LPA). In LPA, the within-profile variance-covariance structures represent different assumptions regarding the variance and covariance of the indicator variables both within and between latent profiles. As the best within-profile variance-covariance structure is not known a priori, all of the different structures must be investigated to identify the best model (Masyn, 2013). This function specifies six different variance-covariance structures labeled A to F (see Table 1 in Patterer et al, 2023):
The within-profile variance is constrained to be profile-invariant and covariances are constrained to be 0 in all profiles (i.e., equal variances across profiles and no covariances among indicator variables). This is the default setting in Mplus.
The within-profile variance is profile-varying and covariances are constrained to be 0 in all profiles (i.e., unequal variances across profiles and no covariances among indicator variables).
The within-profile variance is constrained to be profile-invariant and covariances are constrained to be equal in all profiles (i.e., equal variances and covariances across profiles).
The within-profile variance is constrained to be profile-invariant and covariances are profile-varying (i.e., equal variances across profiles and unequal covariances across profiles).
The within-profile variances are profile-varying and covariances are constrained to be equal in all profiles (i.e., unequal variances across profiles and equal covariances across profiles).
The within-class variance and covariances are both profile-varying (i.e., unequal variances and covariances across profiles).
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
x |
matrix or data frame specified in the argument x |
args |
specification of function arguments |
result |
list with six entries for each of the variance-covariance structures and Mplus inputs based on different number of profiles in case of continuous indicators or list of Mplus inputs based on different number of classes in case of count, ordered or unordered categorical indicators. |
Takuya Yanagida takuya.yanagida@univie.ac.at
Masyn, K. E. (2013). Latent class analysis and finite mixture modeling. In T. D. Little (Ed.), The Oxford handbook of quantitative methods: Statistical analysis (pp. 551–611). Oxford University Press.
Muthen, L. K., & Muthen, B. O. (1998-2017). Mplus User's Guide (8th ed.). Muthen & Muthen.
Patterer, A. S., Yanagida, T., Kühnel, J., & Korunka, C. (2023). Daily receiving and providing of social support at work: Identifying support exchange patterns in hierarchical data. Journal of Work and Organizational Psychology, 32(4), 489-505. https://doi.org/10.1080/1359432X.2023.2177537
read.mplus
, write.mplus
, mplus
,
mplus.update
, mplus.print
, mplus.plot
,
mplus.bayes
, mplus.run
## Not run:
# Load data set "HolzingerSwineford1939" in the lavaan package
data("HolzingerSwineford1939", package = "lavaan")
#-------------------------------------------------------------------------------
# Example 1: LCA with k = 1 to k = 8 profiles, continuous indicators
# Input statements that contain parameter estimates
# Vuong-Lo-Mendell-Rubin LRT and bootstrapped LRT
mplus.lca(HolzingerSwineford1939, ind = c("x1", "x2", "x3", "x4"),
classes = 8, output = c("SVALUES", "TECH11", "TECH14"))
#-------------------------------------------------------------------------------
# Example 22: LCA with k = 1 to k = 6 profiles, ordered categorical indicators
# Select observations with ageyr <= 13
# Estimate all models in Mplus
mplus.lca(round(HolzingerSwineford1939[, -5]), ind = c("x1", "x2", "x3", "x4"),
type = "categorical", useobservations = "ageyr <= 13",
mplus.run = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.