melff / mclogit

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

Error `'a' (<dimension1> x 1) must be square` #22

Closed fweber144 closed 2 years ago

fweber144 commented 2 years ago

For some models fitted by mclogit::mblogit(), I get the error

Error in solve.default(X[[i]], ...) : 'a' (<dimension1> x 1) must be square

thrown by mclogit:::PQLMQL_innerFit(). (The <dimension1> can be 3, for example.)

I think the problematic line is https://github.com/melff/mclogit/blob/7f47d53713b124a100538bfd65dc899c320ffa4f/pkg/R/mmclogit-fitPQLMQL.R#L271 because, if S.k is a matrix there, then diag() returns a vector containing the diagonal elements. Perhaps that line was supposed to read

S.k <- diag(x=diag(S.k),nrow=d)

instead? But I don't know anything about the mathematical details of this line, so my guess might be completely wrong.

And I'm not sure, but perhaps this is the same bug as in #21?

Note that this issue occurs with both, the current CRAN version 0.8.7.3 as well as with the current GitHub version at commit 7f47d53713b124a100538bfd65dc899c320ffa4f installed via devtools::install_github("melff/mclogit",subdir="pkg").

Zhiwen-Owen-Jiang commented 2 years ago

I found this bug either. The code that previously I could run failed.

melff commented 2 years ago

This appears to be fixed in release 0.9.4.

fweber144 commented 2 years ago

Thanks, this seems indeed to be fixed. However, I now get an error from predict.mmblogit() which I'll open a new issue for.