5

I have question regarding which R-package to use to create a latent class/mixture model with both categorical and continuous indicator variables. I have not yet found a good example of this using R, even though there are a lot of mixture and latent class analysis packages in R. The software package Mplus have this capability and on the UCLA website there is an example of how to create such a model with Mplus (https://stats.idre.ucla.edu/mplus/seminars/intromplus-part2/mplus-class-notesanalyzing-data-latent-class-and-other-mixture-models/ the second example).

The only way I have been able to replicate this example in R is using the depmixS4 package. Using the following code:

library(depmixS4)
lca<-read.table("https://stats.idre.ucla.edu/wp-content/uploads/2016/02/lca.dat", sep=",")
names(lca)<-c( "hm", "he", "voc", "nocol" ,"ach9", "ach10", "ach11","ach12")

mod <- mix(list(hm~1,he~1,voc~1,nocol~1,ach9~1,ach10~1 ,ach11~1 ,ach12~1  ), data=lca, nstates=2,
              family=list(multinomial(),multinomial(),multinomial(),multinomial(), gaussian(),gaussian(),gaussian(),gaussian()),
              respstart=runif(32))

fmod<-fit(mod)
summary(fmod)
fmod@response

This code seems to do the job of replicating the example with some minor differences between the output in the depmixS4 variant and the Mplus.

First, is this code correct for reproducing the Mplus example?

Second, does anyone have any other packages they would recommend when creating this type of model in R?

E_J
  • 183
  • 1
  • 9

1 Answers1

3

Regarding question 2, another similar question here (Which R package to use to conduct a latent class growth analysis (LCGA) / growth mixture model (GMM)?) suggested OpenMx for "advanced structural equation modeling" in R. If it can be used to estimate growth mixture models, I'm betting it can be used to model a hybrid latent class/profile model. Haven't played with it myself yet though.

D L Dahly
  • 3,663
  • 1
  • 24
  • 51
  • Thanks for the response. I looked at OpenMx but it seems to have a rather steep learning curve. I'll try to replicate the example with OpenMx when I get the time. Until then I think I will stick with depmixS4. – E_J Apr 10 '13 at 14:04
  • Curious if you were able to make any headway on this - realizing this is a ridiculously long time lag from the original post. I'm trying to do something very similar using OpenMx and am running up against a) the steep learning curve and b) almost no examples for this. – Joshua Rosenberg Jul 06 '17 at 22:50
  • I am afraid not! – D L Dahly Jul 14 '17 at 15:47