CecileProust-Lima / lcmm

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

Error in chol.default(varcov) : the leading minor of order 3 is not positive #281

Open rossneville opened 2 weeks ago

rossneville commented 2 weeks ago

Dear Cécile and Viviane,

Following on from a closed issues about externvar #274

I have updated my input model for use in externvar and I am now receiving an error:

Error in chol.default(varcov): the leading minor of order 3 is not positive

My input model is:

m1 <- lcmm(fixed = y ~ ns(Age_rescaled, knots = c(0.33, 0.67)), mixture = ~ns(Age_rescaled, knots = c(0.33, 0.67)), random = ~ns(Age_rescaled, knots = c(0.33, 0.67)), subject = "ID", ng = 3, nwg = T, link = "thresholds", data = df)

df1 <- df %>% group_by(ID) %>% mutate(agemax = max(Age_rescaled)) %>% ungroup %>% mutate(DVlast = ifelse(Age_rescaled==agemax,DV,NA))

This model converged when I checked (m1$conv), and all of the usual lcmm functions work fine with it.

Then, my externvar model is:

ext1 <- externVar(m1,fixed= AttentionLAST ~ 1, mixture=~1, data=df1,method="conditional",M=10,varest = "paramBoot")

This model gives the error.

Perhaps it has something to do with the proportion of convergence on bootstrap iterations, as shown in bold below (70%).

The m1 input model seems to work fine for external outcomes where I have observations at each level of Age_rescaled. However, this model where I only have an observation for AttentionLAST at the final Age_rescaled observation seems to be having problems running.

Is there any advice you could give?

Regards Ross

**Secondary linear mixed model fitted by maximum likelihood method primary model variance accounted for through parametric boostrap

externVar(model = mthresholds3, fixed = ISTlast ~ 1, mixture = ~1, data = paq, method = "conditional", varest = "paramBoot", M = 10)

Statistical Model: Dataset: paq Number of subjects: 412 Number of observations: 412 Number of observations deleted: 1838 Number of latent classes: 3 Number of parameters: 4

Iteration process:

Proportion of convergence on bootstrap iterations (%)= 70 Goodness-of-fit statistics: maximum log-likelihood: -1349.77 AIC: 2712.09 BIC: 2728.17**

VivianePhilipps commented 1 week ago

Hi,

I made a change in the externVar function (commit 2e23623). Could you please check it ?

Viviane

rossneville commented 1 week ago

Hi Viviane ExternVar seems to be working fine - I've used it multiple times today and not encountered the issue. Thanks for fixing it. Regards Ross

On Wed, 13 Nov 2024 at 13:20, VivianePhilipps @.***> wrote:

Hi,

I made a change in the externVar function (commit 2e23623 https://github.com/CecileProust-Lima/lcmm/commit/2e2362329400f6ebd83caac3be0cb9a76f07b3ec). Could you please check it ?

Viviane

— Reply to this email directly, view it on GitHub https://github.com/CecileProust-Lima/lcmm/issues/281#issuecomment-2473603704, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIT2M3LAFLCCTW45H3YFB432ANG23AVCNFSM6AAAAABRBTB6FSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZTGYYDGNZQGQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Dr Ross D. Neville, PhD, ProfCert University Teaching and Learning Head of Subject - Sport Management School of Public Health, Physiotherapy and Sport Science University College Dublin (UCD) Room G6 - Woodview House Belfield, Dublin 4 @.*** +353 (0) 1 716 3419