0

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

enter image description here

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.

jrcalabrese
  • 2,184
  • 3
  • 10
  • 30
Fan Zhang
  • 1
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 13 '23 at 18:02
  • Please provide `dput(mydata)` to make your code [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – jrcalabrese Feb 15 '23 at 18:42
  • Interesting question. Since this is a question about the structure of the model, it is better suited to stats.stackexchange.com. – Robert Dodier Feb 15 '23 at 23:56

0 Answers0