0

When I try to fit an Ordered Logit model to a long dataset the functions return an error Error in solve.default(H, g[!fixed]): system is computationally singular: reciprocal condition number = 3.64628e-18.

I've seen this but the data is not available anymore and I couldn't fix my issue. Also, tried this one and this one with no success.

The code that reproduces the dataset I am using is:

# Example of caracteristic dummies caract <- tibble::tribble(~CPU, ~RAM, 1, 1, -1, 1, 1, -1, -1, -1) # Weights for choosing the probabilities weights <- c(0.3954545, 0.2727273, 0.2363636, 0.0954546) # Simulating the choices block block <- caract block$Alternative <- 1:4 # Simulating the dataset df <- NULL n_decisors <- 50 set.seed(123456) i <- 1 for(i in 1:n_decisors){ block$Decisor <- i block$Choice <- sample(1:4, prob = weights) df <- rbind(df, block) } 

And the model fitting procedure that returns the error is:

library(mlogit) # Creating the model data object df_mlogit <- mlogit.data(data = df, choice = "Choice", shape = "long", alt.var = "Alternative", varying = 1:2, ranked = T) # Fitting the model m <- mlogit(formula = Choice ~ CPU + RAM, rpar = c(CPU = "n", RAM = "n"), data = df_mlogit) 

When I make the block of choices non-exhaustive by sampling rows from caract in each iteration of the df simulation the error doesn't occur but I need to estimate a case where the data is the format simulates in this example. Also, I know nnet::multinom(Choice ~ CPU + RAM, data=df) solve this, but it won't fit a mixed logit model, which is also necessary for me.

5
  • Perhaps nnet::multinom(Choice ~ CPU + RAM, data=df) might be an alternative for you? Commented Jun 12, 2019 at 16:14
  • It actually is @jay.sf but I also need to adjust a mixed logit model, and as far as I know nnet::multinom(Choice ~ CPU + RAM, data=df) won't solve this for the mixed logit case. Commented Jun 12, 2019 at 16:21
  • I see. You may be interested in this post: stats.stackexchange.com/a/365115/163114 Commented Jun 12, 2019 at 16:25
  • In fact the frequentist alternative gmnl suffers from a similar issue. The data objet must be a mlogit.data class and when fitting it returns the error Error in s + x[[i]] : non-conformable arrays. Guess I will have to try the bayesian approach. Thanks for the help. Commented Jun 12, 2019 at 16:49
  • IMO this is not just a programming issue and may be better asked at Cross Validated where there are people more familiar with this type of model. Voting to migrate there. Commented Jun 12, 2019 at 17:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.