Hello~

I am trying to fit a two-level growth mixture model (which is three-level LMM with two latent classes).

The subject's outcome (y0, y1, y2, y3) is nested within the subject and then nested within different centers.

##wide type data <- reshape(indata[,c("Center","ID","Time","y")], idvar = c("Center","ID"), timevar = "Time", direction = "wide", sep = "") centerdata= data.frame(Center= mydata3[!duplicated(mydata3$Center),1]) ## center-level model (class 1 and 2 are same except the labels) GMMClass1Center <- mxModel( model="GMMClass1Center", type='RAM', latentVars=c("iCenter"), mxData(centerdata, type="raw", primaryKey = "Center"), mxPath(from="iCenter",arrows=2, values=1, labels=c("varCenter1")) ) GMMClass2Center <- mxModel( model="GMMClass2Center", type='RAM', latentVars=c("iCenter"), mxData(centerdata, type="raw", primaryKey = "Center"), mxPath(from="iCenter", arrows=2, values=1, labels=c("varCenter2")) ) ## subject-level model (class 1 and 2 are same except the labels) GMMClass1 <- mxModel( 'GMMClass1', type='RAM', GMMClass1Center, manifestVars=c("y0","y1","y2","y3"), latentVars=c("intercept","slope"), mxData(data, 'raw'), mxPath(from=c("y0","y1","y2","y3"),arrows=2, free=TRUE,values=c(4,4,4,4), labels=c("residual1","residual1","residual1","residual1")), mxPath( from=c("intercept","slope"), arrows=2, connect="unique.pairs", free=TRUE, values=c(3,0.4,1), labels=c("sig11class1","sig12class1","sig22class1") ), mxPath( from="intercept", to=c("y0","y1","y2","y3"), arrows=1, free=FALSE, values=c(1,1,1,1) ), mxPath(from="slope",to=c("y0","y1","y2","y3"),arrows=1, free=FALSE,values=0:3), mxPath(from="one", to=c("y0","y1","y2","y3"),arrows=1, free=FALSE,values=c(0,0,0,0)), mxPath(from="one", to=c("intercept","slope"),arrows=1, free=TRUE, values=c(0,1),labels=c("intercept1","slope1")), mxPath(from=('GMMClass1Center.iCenter'), to=c("y0","y1","y2","y3"), free=FALSE,arrows=1, values=c(1,1,1,1), joinKey="Center"), mxFitFunctionML(vector=TRUE)) GMMClass2 <- mxModel( 'GMMClass2', type='RAM', GMMClass2Center, manifestVars=c("y0","y1","y2","y3"), latentVars=c("intercept","slope"), mxData(data, 'raw'), mxPath(from=c("y0","y1","y2","y3"),arrows=2, free=TRUE,values=c(4,4,4,4), labels=c("residual2","residual2","residual2","residual2")), mxPath( from=c("intercept","slope"), arrows=2, connect="unique.pairs", free=TRUE, values=c(3,0.4,1), labels=c("sig11class2","sig12class2","sig22class2")) , mxPath( from="intercept", to=c("y0","y1","y2","y3"), arrows=1, free=FALSE, values=c(1,1,1,1) ), mxPath(from="slope",to=c("y0","y1","y2","y3"),arrows=1, free=FALSE,values=c(0,1,2,3)), mxPath(from="one", to=c("y0","y1","y2","y3"),arrows=1, free=FALSE,values=c(0,0,0,0)), mxPath( from="one", to=c("intercept", "slope"), arrows=1, free=TRUE, values=c(4,1), labels=c("intercept2","slope2") ), mxPath(from=('GMMClass2Center.iCenter'), to=paste0('y',0:3),arrows=1, free=FALSE, values=c(1,1,1,1), joinKey="Center"), mxFitFunctionML(vector=TRUE)) ## calculate the probability of each latent class classP <- mxMatrix( type="Full", nrow=2, ncol=1, free=c(TRUE, FALSE), values=1, lbound=0, labels = c("p1","p2"), name="Props" ) mixExp <- mxExpectationMixture(components=c('GMMClass1', 'GMMClass2'), weights='Props', scale='sum') dataRaw <- mxData(data, type="raw") gmm <- mxModel("Growth Mixture Model", dataRaw,GMMClass1, GMMClass2, classP,mixExp, mxFitFunctionML(vector=F)) gmmFit <- mxRun(gmm, suppressWarnings=TRUE)

## Problem

I keep receiving the following message but I do set mxFitFunctionML(vector=TRUE) in each component model. The component model works great and if I ignore the center-level model, the regular Growth mixture model also works fine.

Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, :

Growth Mixture Model.fitfunction: component GMMClass1.fitfunction must be in probability units

Thank you so much!