CecileProust-Lima / lcmm

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

link thresholds - Convergence problem #202

Closed Tina-Kb closed 1 year ago

Tina-Kb commented 1 year ago

Hi,

I'm having convergence issues using the threshold link for a binary (0,1) outcome. In order to avoid numerical problems, my time variable has been centered around 0 and rescaled so that it ranges from -2 to 2. I was able to fit models with up to 3 classes. Models with 4 classes and 5 classes did not converge.

Here's the summary for the model with 4 classes and 5 classes respectively :

cannabis_f4 = gridsearch(rep = 100, maxiter = 15, minit = cannabis_f1, m=lcmm(dayweek_cannabis ~ poly(temps, degree = 3, raw = TRUE), subject = "ID", ng = 4, data = subset(traj_long, sex == 2), mixture = ~ poly(temps, degree = 3, raw = TRUE), link = "thresholds")) summary(cannabis_f4)

General latent class mixed model fitted by maximum likelihood method

lcmm(fixed = dayweek_cannabis ~ poly(temps, degree = 3, raw = TRUE), mixture = ~poly(temps, degree = 3, raw = TRUE), subject = "ID", ng = 4, link = "thresholds", data = subset(traj_long, sex == 2))

Statistical Model: Dataset: subset(traj_long, sex == 2) Number of subjects: 417 Number of observations: 1960 Number of observations deleted: 125 Number of latent classes: 4 Number of parameters: 19
Link function: thresholds

Iteration process: Maximum number of iteration reached without convergence Number of iterations: 100 Convergence criteria: parameters= 5e-06 : likelihood= 7.7e-05 : second derivatives= 1

Goodness-of-fit statistics: maximum log-likelihood: -624.73
AIC: 1287.46
BIC: 1364.09

 Discrete posterior log-likelihood: -624.73  
 Discrete AIC: 1287.46  

 Mean discrete AIC per subject: 1.5437  
 Mean UACV per subject: 1246.167  
 Mean discrete LL per subject: -1.4982  

Maximum Likelihood Estimates:

Fixed effects in the class-membership model: (the class of reference is the last class)

                 coef Se Wald p-value

intercept class1 0.36020
intercept class2 0.15861
intercept class3 1.43669

Fixed effects in the longitudinal model:

                                 coef Se Wald p-value

intercept class1 (not estimated) 0
intercept class2 -7.24835
intercept class3 -0.00151
intercept class4 1.53084
poly(...)1 class1 -0.59227
poly(...)1 class2 5.07309
poly(...)1 class3 0.00543
poly(...)1 class4 0.05678
poly(...)2 class1 -0.00806
poly(...)2 class2 1.64595
poly(...)2 class3 -3.30952
poly(...)2 class4 0.02355
poly(...)3 class1 0.08052
poly(...)3 class2 -1.24457
poly(...)3 class3 1.40177
poly(...)3 class4 0.06487

Residual standard error (not estimated) = 1

Parameters of the link function:

              coef Se Wald p-value

thresh. parm1 0.73177

cannabis_f5 = gridsearch(rep = 100, maxiter = 15, minit = cannabis_f1, m=lcmm(dayweek_cannabis ~ poly(temps, degree = 3, raw = TRUE), subject = "ID", ng = 5, data = subset(traj_long, sex == 2), mixture = ~ poly(temps, degree = 3, raw = TRUE), link = "thresholds")) summary(cannabis_f5)

General latent class mixed model fitted by maximum likelihood method

lcmm(fixed = dayweek_cannabis ~ poly(temps, degree = 3, raw = TRUE), mixture = ~poly(temps, degree = 3, raw = TRUE), subject = "ID", ng = 5, link = "thresholds", data = subset(traj_long, sex == 2))

Statistical Model: Dataset: subset(traj_long, sex == 2) Number of subjects: 417 Number of observations: 1960 Number of observations deleted: 125 Number of latent classes: 5 Number of parameters: 24
Link function: thresholds

Iteration process: Maximum number of iteration reached without convergence Number of iterations: 100 Convergence criteria: parameters= 5.6e-06 : likelihood= 4.1e-07 : second derivatives= 1

Goodness-of-fit statistics: maximum log-likelihood: -619.99
AIC: 1287.97
BIC: 1384.77

 Discrete posterior log-likelihood: -619.99  
 Discrete AIC: 1287.97  

 Mean discrete AIC per subject: 1.5443  
 Mean UACV per subject: 865.4495  
 Mean discrete LL per subject: -1.4868  

Maximum Likelihood Estimates:

Fixed effects in the class-membership model: (the class of reference is the last class)

                 coef Se Wald p-value

intercept class1 -1.00659
intercept class2 -0.94201
intercept class3 -2.31037
intercept class4 -1.89423

Fixed effects in the longitudinal model:

                                 coef Se Wald p-value

intercept class1 (not estimated) 0
intercept class2 -3.43443
intercept class3 0.62379
intercept class4 -0.92938
intercept class5 -5.26121
poly(...)1 class1 -0.55263
poly(...)1 class2 0.30553
poly(...)1 class3 -0.43885
poly(...)1 class4 1.01384
poly(...)1 class5 3.10987
poly(...)2 class1 -0.03367
poly(...)2 class2 -0.86678
poly(...)2 class3 0.33195
poly(...)2 class4 2.96298
poly(...)2 class5 0.98247
poly(...)3 class1 0.08350
poly(...)3 class2 -0.04108
poly(...)3 class3 0.92971
poly(...)3 class4 -1.39468
poly(...)3 class5 -0.77818

Residual standard error (not estimated) = 1

Parameters of the link function:

              coef Se Wald p-value

thresh. parm1 0.57553

Thanks!

Tina

Tina-Kb commented 1 year ago

Increasing the maximum number of iterations fixed the convergence issues.