# Error in mlogit package: system is computationally singular: reciprocal condition number = 8.87901e-37

I have a data set that is formatted according to mlogit's standards using mlogit.data command in Rstudio. Here is the first three rows of the dataset.

         Trip  SevereEarthquake  Night  Age  Mode
1.NTG    1     0                 0      18   FALSE
1.TGNV   1     0                 0      18   FALSE
1.TGV    1     0                 0      18   TRUE


After some variable creation which I do not include here to make the question short, I ran a multinomial logit model using the code below and it worked fine.

mlogit(Mode ~ SE.TGV + SE.TGNV + AGE.NTG, data, reflevel = "NTG")


However when I define nests in the code (as below) to do a nested logit model I get an error:

mlogit(Mode ~ SE.TGV + SE.TGNV + AGE.NTG, data, reflevel = "NTG",
nests = list(notrip = "NTG", trip = c("TGV","TGNV")))

Error in solve.default(crossprod(attr(x, "gradi")[, !fixed])) :
system is computationally singular: reciprocal condition number = 8.87901e-37


What is causing this problem? How can I solve this?

• Have you seen these similar posts: 1, 2 and 3? If yes and the issue is still unresolved then do provide more details. – mnm Oct 30 '17 at 10:54
• Thank you very much for your comment. I did check them, however, I could not use their answer on my problem. In my case a multinomial logit model is working just fine but when I define nests the problem arises. Would you please tell me what details are necessary? – Amir Hossein Oct 30 '17 at 11:33

## 1 Answer

This means that your variables are 'dependent'.

Your NTG and TGNV have the exact same values. Your system can't tell if contributions are made because of either one of them.

Either you should try to find more data that is different between NTG and TGNV to make the system independent, or you can just get rid of one of the two.

-- edit:

I don't know much R (yet!), but after you combine TGV and TGNV, shouldn't your Mode relate to 'trip' instead of both TGV and TGNV? Since TGV and TGNV are now grouped, the model matrix can't separate them or something like that. (And maybe the AGE.NTG part has to change too.

mlogit(Mode ~ ??? + AGE.NTG, data, reflevel = "NTG",
nests = list(notrip = "NTG", trip = c("TGV","TGNV")))

• Thank you very much for your answer, How do you know that these two options (NTG and TGNV) are dependent and not other two option? – Amir Hossein Oct 30 '17 at 11:03
• TGV in 'Mode' column has a different value, this is sufficient to be independent. The other two items have the exact same values across all columns – Pieter21 Oct 30 '17 at 11:36
• I apologize for the misunderstanding, the table in the question is just a small portion of the dataset. My dataset consist of 3600 rows, therefore, this should not be the problem. – Amir Hossein Oct 30 '17 at 11:42