CecileProust-Lima / lcmm

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

Error using externVar: "classmb is missing #255

Closed HannaMuetze closed 1 month ago

HannaMuetze commented 6 months ago

Dear all, I'm investigating the relationship between latent classes and external predictors using the code and datastructure below. Does anybody can help me? Thanks so much! Kind regards

XextHess <- externVar(TL_MOD_FMMAccmod6_3, # primary model
                       classmb = ~gold_msi, # external predictor variable 
                        subject = "id", # subject identifier
                       data = TL_PRE_Long4, # data
                      method = "twoStageJoint") 

Error message: "Fehler in .Contlcmm(fixed = fixed, mixture = mixture, random = random, : Argument "classmb" fehlt (ohne Standardwert)" --> english: "argument classmb is missing".

This is my data structure: id time accuracy gold_msi 1 0 0.9102564 80 2 0 0.8974359 58 3 0 0.8974359 57 4 0 0.8076923 43 5 0 0.8846154 69 6 0 0.1666667 70

VivianePhilipps commented 6 months ago

Hi,

could you give me information about the primary model, please? I need to run a similar model (same function, same number of variables, etc) so that I can check where the error occurs. Or do you have a reproducible example using the data provided in the package (data_lcmm, paquid)?

Viviane

HannaMuetze commented 6 months ago

Hi, thanks for your reply. I attached the dataset. You can find the complete code below. Thank you so much for your help! Kind regards, Hanna

library(readxl)
TL_PRE_Long4 <- read_excel("Data/Objects/TL_PRE_Long4_subset.xlsx")

# 1-class model for "minit"
FMMAccmod6_1 <- lcmm(accuracy ~ poly(time, degree = 2, raw = TRUE),
                     random =~ 1 + poly(time, degree = 2, raw = TRUE), 
                     ng = 1, 
                     subject = "id", data = TL_PRE_Long4,
                     link = "9-quant-splines")
# 3-class model (=primary model)
TL_MOD_FMMAccmod6_3  <- lcmm:: gridsearch(rep = 50, maxiter = 100, minit = FMMAccmod6_1, 
                                   m = lcmm(accuracy ~ poly(time, degree = 2, raw = TRUE),
                                            random = ~ 1 + poly(time, degree = 2, raw = TRUE),
                                            subject = "id", data = TL_PRE_Long4,
                                            link = "9-quant-splines", 
                                            mixture = ~ 1 + poly(time, degree = 2, raw = TRUE),
                                            ng = 3,
                                            nwg = F))
XextHess <- externVar(TL_MOD_FMMAccmod6_3, # primary model
                       classmb = ~gold_msi, # external predictor variable 
                        subject = "id", # subject identifier
                       data = TL_PRE_Long4, # data
                      method = "twoStageJoint") 

TL_PRE_Long4_subset.xlsx

CecileProust-Lima commented 4 months ago

Hi, the code of externVar was changed on the github version. It would be worth trying with it, and trying also with the "conditional" technique. Cécile