
Last chance! 50% off unlimited learning
Sale ends in
Function for fitting latent class models with multiple groups, which may or may not include latent class structure for group variable.
glca(formula, group = NULL, data = NULL, nclass = 3, ncluster = 0,
measure.inv = TRUE, std.err = TRUE, init.param = NULL,
n.init = 1, testiter = 50, maxiter = 1000, eps = 1e-06,
na.rm = FALSE, random.seed = NULL, verbose = TRUE)
a formula for specifying manifest items and covariates using the "item
" function
an optional vector specifying a group of observations. Given group variable, group covariates can be incorporated.
a data frame containing the manifest item, covariates and group variable
number of level-1 (individual-level) latent classes
number of level-2 (group-level) latent classes. When group
and ncluster
(>1) are given the multilevel latent class models will be fitted.
a logical value of the measurement invariance assumption across groups
a logical value for whether calculating standard errors for estimates
a list which contains user-defined initial parameter
number of random initial parameter sets
an integer for maximum number of test set iteration
an integer for maximum number of iteration
positive convergence tolerance
a logical value for whether or not to remove observations who has at least 1 item missing
random seed to have the equivalent solution for every trials
a logical value for whether or not to print the result of a function's execution
glca
returns an object of class "glca
".
The function summary
prints estimates for parameters and glca.gof
function gives goodness of fit measures for the model.
An object of class "glca
" is a list containing the following components:
the matched call
a list of model description
a list of data used for fitting
a list of parameter estimates
a list of standard errors for estimates
a list of logistic regression coefficients for prevalence of level-1 class
a data frame of posterior probablities of each individaul for latent classes and each group for latent clusters
a list of goodness of fit measures
a list containing information about convergence
The glca
is the function for implementing LCA consist of two-type latent categorical variables (i.e., level-1 and level-2 latent class). The level-1 (individual-level) latent class is identified by the association among the individuals' responses to multiple manifest items, but level-2 (group-level) latent class is categorized by the prevalence of level-1 latent class for group variable. The function glca
can handle two types of covariates: level-1 and level-2 covariates. If covariates vary across individuals, they are considered as level-1 covariates. When group
and ncluster
(>1) are given, covariates which are varying across groups are considered as level-2 covariates. Both types of covariates have effect on level-1 class prevalence.
The formula should consist of an ~
operator between two sides. Manifest items should be indicated in LHS of formula using item
function and covariates should be specified in RHS of formula. For example,
item(y1, y2, y3) ~ 1
item(y1, y2, y3) ~ x1 + x2
where the first fomula indicates LCA with three manifest variables (y1
, y2
, and y3
) and no covariate, and the second formula includes two covariates (x1
and x2
). Two types of covariates (i.e., level-1 and level-2 covariates) will be automatically detected by glca
.
The estimated parameters in glca
are rho
, gamma
, delta
, and beta
. The set of item response probabilities for each level-1 class is rho
. The sets of prevalences for level-1 and level-2 class are gamma
and delta
, respectively. The prevalence for level-1 class (i.e., gamma
) can be modeled as logistic regression using level-1 and/or level-2 covariates. The set of logistic regression coefficients is beta
in glca
output.
Vermunt, J.K. (2003) Multilevel latent class models. Sociological Methodology, 33, 213--239. 10.1111/j.0081-1750.2003.t01-1-00131.x
Collins, L.M. and Lanza, S.T. (2009) Latent Class and Latent Transition Analysis: With Applications in the Social, Behavioral, and Health Sciences. John Wiley & Sons Inc.
# NOT RUN {
##
## Example 1. GSS dataset
##
data("gss")
# LCA
lca = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
data = gss, nclass = 3)
summary(lca)
# LCA with covariate(s)
lcr = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ AGE,
data = gss, nclass = 3)
summary(lcr)
coef(lcr)
# Multiple-group LCA (MGLCA)
mglca = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
group = DEGREE, data = gss, nclass = 3)
summary(mglca)
# Multiple-group LCA with covariate(s) (MGLCR)
mglcr = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ SEX,
group = DEGREE, data = gss, nclass = 3)
summary(mglcr)
coef(mglcr)
# }
# NOT RUN {
##
## Example 2. BRFSS data
##
data("brfss")
# Multilevel LCA (MLCA)
brfss1000 = brfss[sample(1:nrow(brfss), 1000),]
mlca = glca(item(OBESE, PA300, FRTLT1A, VEGLT1A, SMOKER, DRNK30) ~ 1,
group = STATE, data = brfss1000, nclass = 3, ncluster = 2)
summary(mlca)
# MLCA with covariate(s) (MLCR)
# (SEX: level-1 covariate, REGION: level-2 covariate)
mlcr = glca(item(OBESE, PA300, FRTLT1A, VEGLT1A, SMOKER, DRNK30) ~ SEX + PARTY,
group = STATE, data = brfss1000, nclass = 3, ncluster = 2)
summary(mlcr)
coef(mlcr)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab