I am using R-package "lcmm" to build a latent class growth model.
Here is the first two rows of my dataset in long-format,
ID target time age diabetes
1 3.2 1 56 0
1 1.1 2 56 0
My aim is to identify latent classes according to the variable “target”, so here are the R codes that build the basic model:
m1<-hlme(target ~ poly(time, degree=3, raw=TRUE), subject = "ID", random = ~poly(time, degree=3, raw=TRUE), mixture = ~poly(time, degree=3, raw=TRUE), ng = 2, data = mydata)
In addition, there are two covariates, “age” and “diabetes” (related to “target”) that may help to identify latent classes, but I do not know where to add them into the model.
Should I add them directly in the function like (A) or use the “classmb” in the codes like (B) as follows?
(A)
m1<-hlme(target ~ poly(time, degree=3, raw=TRUE) + age + diabetes, subject = "ID", random = ~poly(time, degree=3, raw=TRUE), mixture = ~poly(time, degree=3, raw=TRUE), ng = 2, data = mydata)
(B)
m1<-hlme(target ~ poly(time, degree=3, raw=TRUE), subject = "ID", random = ~poly(time, degree=3, raw=TRUE), mixture = ~poly(time, degree=3, raw=TRUE), classmb= ~age + diabetes, ng = 2, data = mydata)
Should I choose A or B, or add them there both?
Thank you in advance.