Search code examples
rmatrixmlogit

Error in s + x[[i]] : non-conformable arrays in R - gmnl package for Latent Class Analysis


I am running a latent class analysis for choice modeling by using gmnl package. After getting my data in the right format (mlogit.data), I met the error "Error in s + x[[i]] : non-conformable arrays" when running the gmnl model.

The code of running the models is:

 lc <- gmnl(choice ~ v1 + v2 + v3 + v4 
            + v5| 0 | 0 | 0 | 1, 
           data = car, 
           model = "lc",
           Q = 3,method = 'bhhh')

The sample of my data looks like:

data sample

I have searched similar issues that other people met, I found this related issue but it has not been addressed. Any help and hint will be highly appreciated.

Also, I would like to hear about any other useful packages that work well with latent class analysis, either a package from R or Python is fantastic!


Solution

  • I think the problem is that the number of alternatives isn't equal for all choicesets. That is not a problem when you use mlogit.