Rでライブラリ(mlogit)を使用していますが、このような特定のデータセットで立ち往生しています
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
全部で 187 個のアイテムと 4 つの customerID (1、2、3、および 4) があります。各顧客には、価格とカロリーに基づいて 1 つを選択する 187 品目の選択セットが提示されます。4名様でも価格・カロリーは変わりません。
> 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 ...
以下の方法で、mlogit コマンドに従ってデータをフォーマットします。
m<- mlogit.data(data, choice="Choice", shape="long", alt.levels=c("200", "231", "232", "240",.....(*all the 187 'Item' here)*))
これは私にこれを与えます:-
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
私のデータセットは、以前の質問で問題を引き起こす可能性があることを読んだように、CutomerID と Item によって並べ替えられています。
いくつかの式を試しましたが、どれも実行されません
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)
価格とカロリーの相関は約43%
cor(m$Price,m$Calories)
[1] 0.429796
私もこれを試しました: -
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)
このエラーを解決するための考えを誰か提供できますか? 私は今2週間それをしています。