melff / mclogit

mclogit: Multinomial Logit Models, with or without Random Effects or Overdispersion
http://melff.github.io/mclogit/
22 stars 4 forks source link

systematic error with nested model #26

Closed ericwol closed 2 years ago

ericwol commented 2 years ago

Hi, I really like this package as I find it intuitive and great for multinomial regression - thanks for building and sharing it. I am having an issue with using it for nested designs though. I have tried the following implementation (illustrated here with a toy dataset) on a number of datasets and I'm systematically getting a "Error in *tmp*[[k]] : subscript out of bounds" error (right after the statement "converged" gets printed in the trace). Is there something I'm missing, or a workaround perhaps? Best wishes, E.

set.seed(1) country = c("france","ireland") county = c("cork","dublin","limerick","galway") dept = c("var","alpes-maritimes","vaucluse","bouches-du-rhone") fake.fr = expand.grid(country[1],dept) fake.ie = expand.grid(country[2],county) for(i in 1:6){ # creating 512 rows of this data fake.fr = rbind(fake.fr,fake.fr) fake.ie = rbind(fake.ie,fake.ie) } fake = rbind(fake.fr,fake.ie) n = nrow(fake) fake$x1 = runif(n) fake$x2 = rnorm(n) fake$y = factor(c("coffee","tea")[sample(1:2,size=n,replace=T)]) names(fake)[1:2] = c("country","county")

level-2 random effects works:

(om = mblogit(y~x1+x2, random=~1|country, data=fake))

level-2 and level-3 random effects does not work:

(om = mblogit(y~x1+x2, random=~1|county/country, data=fake))

melff commented 2 years ago

This looks familiar - similar to a bug that was fixed in one of the newer releases. Which release/version are you using? Thanks

ericwol commented 2 years ago

Hi Martin,

turns out I was using version 0.8.7.3, although I thought I was using the most recent version on CRAN. I usually install.packages() but I figured I had to pull 0.9.4.2 "manually". All good now, thank you for the quick reply, this is much appreciated.

Best wishes, Eric


From: Martin Elff @.> Sent: Thursday 5 May 2022 18:56 To: melff/mclogit @.> Cc: Wolsztynski, Eric @.>; Author @.> Subject: Re: [melff/mclogit] systematic error with nested model (Issue #26)

[EXTERNAL] This email was sent from outside of UCC.

This looks familiar - similar to a bug that was fixed in one of the newer releases. Which release/version are you using? Thanks

— Reply to this email directly, view it on GitHubhttps://github.com/melff/mclogit/issues/26#issuecomment-1118884110, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHHDDPRTI75N2JLYXYBUZ4TVIQDVJANCNFSM5VFZ7T5A. You are receiving this because you authored the thread.Message ID: @.***>