CecileProust-Lima / lcmm

R package lcmm
https://CecileProust-Lima.github.io/lcmm/
55 stars 13 forks source link

help with hlme function #266

Closed NivethaSridharan closed 3 weeks ago

NivethaSridharan commented 3 months ago

Hi,

My data set has the following variables:

  1. Id
  2. lesion id (each patient can have more than one lesion)
  3. lktrans (log transformed outcome)
  4. days (time points - baseline, d2, d14, d21)

My objective of my study is to identify the latent classes in the data and find it's impact on survival. I tried fitting a model model <- hlme( fixed = lktrans ~ days,
random = ~ days | ID + lesid,
subject = "ID",
data = data,
ng = 2,
idiag = TRUE,
mixture = ~ 1 | ID )

This throws an error "Error in hlme(fixed = lktrans ~ days, random = ~days | ID + lesid, subject = "ID", : The covariates in mixture should also be included in the argument fixed".

I would like to know if I am approaching the problem correctly, also how to include more than one random effects in the model . Please could you help me with resolving this error ?

Thanks in advance

VivianePhilipps commented 2 months ago

Hi,

the hlme function doesn't support hierarchical random effects. You can only have one grouping variable, and you specify it in the "subject" argument. If you neglect the leson id, the correct syntax would be :

model <- hlme(
fixed = lktrans ~ days,
random = ~ days,
subject = "ID",
data = data,
ng = 2,
idiag = TRUE,
mixture = ~ 1 )

Best,

Viviane