I am using library(mlogit) in R and I am stuck at this particular data set which looks like this
CustomerID Item Price Calories Choice
1 200 1.99 490 NO
1 312 4.99 887 NO
1 560 5.19 910 NO
1 700 4.79 690 NO
1 909 4.89 660 NO
1 1705 4.00 840 NO
There are 187 items in total and 4 customerID(1,2,3 and 4). Each customer is presented with a choice set of 187 items from which he selects one based on Price and Calories. The price and calories remain the same for 4 customers.
> str(data)
'data.frame': 748 obs. of 5 variables:
$ CustomerID: int 1 1 1 1 1 1 1 1 1 1 ...
$ Item : Factor w/ 187 levels "200","231","232",..: 1 11 14 15 18 25 33 34 36 39 ...
$ Price : num 1.99 4.99 5.19 4.79 4.89 4 4 4 4 6.21 ...
$ Calories : int 490 887 910 690 660 840 1638 1559 1530 1559 ...
$ Choice : Factor w/ 2 levels "NO ","YES": 1 1 1 1 1 1 1 1 1 1 ...
I format the data according to mlogit command in the manner below:-
m<- mlogit.data(data, choice="Choice", shape="long", alt.levels=c("200", "231", "232", "240",.....(*all the 187 'Item' here)*))
which gives me this:-
head(m)
CustomerID Item Price Calories Choice
1.200 1 200 1.99 490 NO
1.231 1 231 1.19 320 YES
1.232 1 232 1.49 320 NO
1.240 1 240 4.79 590 NO
1.250 1 250 2.39 490 NO
1.253 1 253 4.49 691 NO
My dataset is ordered by CutomerID and Item as I had read in a previous question that it might cause an issue.
I try several formulas but none of them runs
Tr.ml <- mlogit(Choice ~0|Price+Calories|0,m)
Error in solve.default(H, g[!fixed]) :
Lapack routine dgesv: system is exactly singular: U[548,548] = 0
In addition: There were 50 or more warnings (use warnings() to see the first 50)
The correlation between Price and Calories is about 43%
cor(m$Price,m$Calories)
[1] 0.429796
I also tried this:-
Tr.ml <- mlogit(Choice ~Price+Calories,m)
Error in solve.default(H, g[!fixed]) :
system is computationally singular: reciprocal condition number = 1.06243e-23
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Can anyone provide some thoughts on resolving this error? I have been at it for 2 weeks now.