Skip to content

naokoski/coLCA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coLCA

The goal of coLCA is to create some additional functionality for the poLCA package. It provides convenience functions to improve workflow and some additional statistics (cAIC, aBIC and the LMR LRT).

Installation

You can install the development version of coLCA from GitHub with:

# install.packages("devtools")
devtools::install_github("naokoski/coLCA")

Usage

coLCA provides convenience functions for estimating all the required latent class models from a single function call, which also calculates additional information criteria (consistent AIC and sample-adjusted BIC), not provided in poLCA. A second function extracts all the model selection statistics and outputs them as a dataframe for easy comparison; the function also compares each model of k classes to the model of k+1 classes using the Lo-Mendell-Rubin Likelihood Ratio Test that is not available in poLCA. The Lo-Mendell-Rubin Likelihood Ratio Test is estimated using the tidyLPA package.

It is common, when performing Latent Class Analysis, that the researcher will estimate a number of models each with an additional class, which will then be compared using statistics and the researcher’s own judgment, in order to choose the model which performs best and at the same time fits well with current knowledge.

When using the poLCA package, each model needs to be run individually and each of the results saved. Model selection statistics then need to be extracted from each model output object and tabulated in order to be compared and used in publications. This package provides convenience functions to improve this workflow and outputs. One function allows the researcher to provide the maximum number of classes they wish to estimate, returning a list containing all the model outputs between one and the maximum number of classes set by the researcher. A second function takes this output, extracts all the necessary statistics and outputs them as a dataframe.

Example

This is a basic example which shows you how to solve a common problem:

#library(coLCA)

##' Estimate latent class models with 1,2,3 and 4 classes
##' Each model to iterate up to 5,000 times and estimated 10 times
##' using different start values each time.
##' 
##' data(election)
##' 
##' Define the model (the example is of a latent class model with no covariates)
##' f <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,MORALB,CARESB,KNOWB,LEADB,DISHONB,INTELB) ~ 1
##' 
##' The argument k is the only argument not included in the poLCA() function. All other arguments are the same.
##' lc_models <- estimateModels(formula = f, data = election, k = 4, maxiter = 5000, nrep = 10)
##' 
##' Create a dataframe containing the model selection statistics for each of the 
##' latent class models estimated
##' 
##' lc_stats <- compareModels(lc_models)

References

Linzer, Drew A. and Jeffrey Lewis. 2013. “poLCA: Polytomous Variable Latent Class Analysis.” R package version 1.4. http://dlinzer.github.com/poLCA.

Linzer DA, Lewis JB (2011). “poLCA: An R Package for Polytomous Variable Latent Class Analysis.” Journal of Statistical Software, 42(10), 1–29. https://www.jstatsoft.org/v42/i10/.

Rosenberg JM, Beymer PN, Anderson DJ, Van Lissa CJ, Schmidt JA (2018). “tidyLPA: An R Package to Easily Carry Out Latent Profile Analysis (LPA) Using Open-Source or Commercial Software.” Journal of Open Source Software, 3(30), 978. doi: 10.21105/joss.00978, https://joss.theoj.org/papers/10.21105/joss.00978.

Nylund, K. L., Asparouhov, T., & Muthén, B. O. (2007). Deciding on the number of classes in latent class analysis and growth mixture modeling: A Monte Carlo simulation study. Structural equation modeling: A multidisciplinary Journal, 14(4), 535-569.

About

A companion R package to poLCA

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages