1

I try to estimate latent class multinomial logit model from gmnl reference manual examples, it results in error "Error in t.default(x) : argument is not a matrix"

Other models (e.g. "mixl") work

R version 4.0.2 (2020-06-22) -- "Taking Off Again"

Platform: x86_64-w64-mingw32/x64 (64-bit)

data("Electricity", package = "mlogit")

Electr <- mlogit.data(Electricity, id.var = "id", choice = "choice",
varying = 3:26, shape = "wide", sep = "")

Elec.lc <- gmnl(choice ~ pf + cl + loc + wk + tod + seas| 0 | 0 | 0 | 1,
data = Electr,
subset = 1:3000,
model = 'lc',
panel = TRUE,
Q = 2)

#Estimating LC model 
#Error in t.default(x) : argument is not a matrix
Maksym
  • 41
  • 3

1 Answers1

1

I got the same error message.

The issue seems to be connected to the mlogit-package.

After going back to a previous version of mlogit (1.0-2), I was able to get the code running. You can install this version with the following code:

install.packages("https://cran.r-project.org/src/contrib/Archive/mlogit/mlogit_1.0-2.tar.gz", repos=NULL,type="source")

and then try to rerun the latent class model:

data("Electricity", package = "mlogit")
Electr <- mlogit.data(Electricity, id.var = "id", choice = "choice", varying = 3:26, shape = "wide", sep = "")
Elec.lc <- gmnl(choice ~ pf + cl + loc + wk + tod + seas | 0 | 0 | 0 | 1, data = Electr, subset = 1:3000, model = "lc", panel = TRUE, Q = 2)
summary(Elec.lc)

However, this is only a temporary workaround.

anie
  • 11
  • 1
  • 1
    Thank you. Also, mlogit.data is deprecated, suggests to use dfidx::dfidx(). But gmnl requires data of class mlogit.data ¯\_(ツ)_/¯ – Maksym Aug 19 '20 at 22:05