簡體   English   中英

mlogit中的錯誤:solve.default中的錯誤(H,g [!fixed]):系統是計算奇異的:倒數條件數= 3.4767e-18

[英]Error in mlogit: Error in solve.default(H, g[!fixed]) : system is computationally singular: reciprocal condition number = 3.4767e-18

我有一個長格式的聯合調查數據。 前幾行看起來像這樣:

 ID alt choice size tar length brand flavor gender age yr_smoke num_smoke job
 1  1   1     no    1   1      1     1      1      2  35       10        20   1
 2  1   2     no    1   1      1     1      1      2  35       10        20   1
 3  1   3     no    1   1      1     1      1      2  35       10        20   1
 4  1   4     no    1   1      1     1      1      2  35       10        20   1
 5  1   5     no    1   1      1     1      1      2  35       10        20   1
 6  1   6     no    1   1      1     1      1      2  35       10        20   1

我用mlogit.data作為:

data_mlogit_ct1_test2 <- mlogit.data(data_mlogit_ct1_test1,choice="choice",
shape="long",alt.var="alt")

轉換后的數據的前幾行如下所示:

   ID alt choice size tar length brand flavor gender age yr_smoke num_smoke job
   1.1  1   1  FALSE    1   1      1     1      1      2  35       10        20   1
   1.2  1   2  FALSE    1   1      1     1      1      2  35       10        20   1
   1.3  1   3  FALSE    1   1      1     1      1      2  35       10        20   1
   1.4  1   4  FALSE    1   1      1     1      1      2  35       10        20   1
   1.5  1   5  FALSE    1   1      1     1      1      2  35       10        20   1
   1.6  1   6  FALSE    1   1      1     1      1      2  35       10        20   1

現在我正在努力使mlogit適合:

 fit_mlogit_ct11 <- mlogit(choice~size+tar+length+brand+flavor, 
                           data_mlogit_ct1_test1,shape="long",chid.var="ID",
                           alt.var="alt",method="bfgs",heterosc=TRUE,tol=10)

我收到了這個錯誤:

solve.default中的錯誤(crossprod(attr(x,“gradi”)[,!fixed])):Lapack例程dgesv:系統是完全奇異的

然后我做了:

  fit_mlogit_ct11 <- mlogit(choice~size+tar+length+brand+flavor, data_mlogit_ct1_test2)

現在我得到了:

solve.default(H,g [!fixed])出錯:系統計算奇異:倒數條件數= 3.4767e-18

有人能幫幫我嗎?

我認為問題是因為你沒有正確定義你的個別特定變量。 根據包裝手冊,當您使用mlogit功能構建模型時,您可以使用:| 將具體的替代方案與個別特定變量分開。 例如:

fit_mlogit_ct11 <- mlogit(choice~1|size+tar+length+brand+flavor, 
                           data_mlogit_ct1_test1,shape="long",chid.var="ID",
                           alt.var="alt",method="bfgs",heterosc=TRUE,tol=10)

這只是說你的所有變量都是個別特定的,而你只接受特定替代的截距。 但事實上,正如上面已經提到的那樣,您的數據看起來很奇怪,因為它們看起來一樣,因為您只有個別的特定變量。 這最終導致奇點(你的變量與1相互關聯)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM