2012-02-15 59 views
1

我試圖擬合模型錯誤glmer:NA/NaN的/ INF國外函數調用(ARG 1)

glmer(trans.dummy ~ pop + year + (year | munname), 
     data=pool, family=binomial(link = "logit"), REML=T, verbose=T) 

,但我不斷收到以下錯誤:

Error in glm.fit(fr$X, fr$Y, weights = wts, offset = offset, family = family, : 
NA/NaN/Inf in foreign function call (arg 1) 

我省略了NAs,更改了模型規範,將流行音樂轉換爲日誌(流行音樂),但沒有解決問題。我認爲問題在於變量'流行',因爲這是唯一導致該問題的原因。當我運行時

mod6 <- glmer(trans.dummy ~ constituency.coa + I(governat.part) + I(district2) + 
         gdp.cap + year + ifdm + year + (year | munname) + (year | uf), 
       data=pool, family=binomial(link = "logit"), REML=T, verbose=T) 

我沒有任何問題。

有關發生了什麼的任何想法?

編輯:

這是我的數據結構:

'data.frame': 41484 obs. of 50 variables: 
$ munname   : Factor w/ 5392 levels "ACACRELANDIA",..: 1 2 3 4 5 6 7 8 9 10 ... 
$ uf    : Factor w/ 26 levels "AC","AL","AM",..: 1 1 1 1 1 1 1 1 1 1 ... 
$ year   : int 2003 2003 2003 2003 2003 2003 2003 2003 2003 2003 ... 
$ party   : Factor w/ 30 levels "DEM","PAN","PC do B",..: 21 25 25 8 21 10 10 25 10 10 ... 
$ candidate  : Factor w/ 12600 levels "AARAO CRUZ MENDES",..: 11452 8535 6389 5910 8095 1995 6087 3996 4313 8417 ... 
$ may.coalit  : Factor w/ 10442 levels "DEM","DEM/PC do B/PRB/PRP/PTN/PSL",..: 7987 10118 10119 4023 8004 10442 4023 10114 4023 3945 ... 
$ governat.part : Factor w/ 9 levels "PDT","PFL","PMDB",..: 9 9 9 9 9 9 9 9 9 9 ... 
$ transfers  : num 920 100920 183698 200920 919 ... 
$ pop    : num 8695 3667 17944 6641 6096 ... 
$ gdp    : num 68507 17492 101626 47936 37903 ... 
$ bf    : num 703 330 1339 335 455 ... 
$ ifdm   : num 0.422 0.442 0.404 0.511 0.396 ... 
$ elec.num  : int 45 13 13 15 45 11 11 13 11 11 ... 
$ may.votes  : int 2394 1345 3864 1415 1434 9422 2313 5423 1078 3348 ... 
$ may.round  : int 1 1 1 1 1 1 1 1 1 1 ... 
$ may.perc.votes : num 0.59 0.586 0.441 0.544 0.615 ... 
$ pt.position  : Factor w/ 5 levels "0.No PT","1.PT mayor winner",..: 4 2 2 3 4 5 5 2 3 5 ... 
$ numb.cand  : int 2 2 3 3 2 4 3 2 2 2 ... 
$ runup   : Factor w/ 3 levels "1.PT","2.Coalition",..: 3 3 2 1 3 2 2 3 1 2 ... 
$ voters   : num 6422 3158 12234 3721 3682 ... 
$ nation.turnout : num 4282 2150 7989 2624 2138 ... 
$ lula.vote  : num 2202 1197 4579 1431 1138 ... 
$ lula.perc.vote : num 0.514 0.557 0.573 0.545 0.532 ... 
$ reelec   : Factor w/ 2 levels "Able to Run",..: 1 1 1 2 2 1 1 1 1 1 ... 
$ constituency.pt : num 9.37e-05 9.41e-05 3.83e-04 4.92e-05 5.38e-05 ... 
$ constituency.coa: num 4.10e-05 1.64e-05 6.87e-05 2.88e-05 1.34e-05 ... 
$ constituency.opp: num 4.81e-05 1.16e-05 2.47e-05 2.41e-05 3.55e-05 ... 
$ transfers.cap : num 0.106 27.521 10.237 30.254 0.151 ... 
$ gdp.cap   : num 7.88 4.77 5.66 7.22 6.22 ... 
$ bf.cap   : num 0.0808 0.0899 0.0746 0.0504 0.0747 ... 
$ lula.power  : num 1.32e-64 7.16e-65 2.74e-64 8.56e-65 6.80e-65 ... 
$ mun.vote  : int 1 1 1 1 1 0 1 1 1 0 ... 
$ mun.vote2  : Factor w/ 2 levels "PSDB","PT": 2 2 2 2 2 1 2 2 2 1 ... 
$ mun.vote3  : Factor w/ 2 levels "0.PT","1.PSDB": 1 1 1 1 1 2 1 1 1 2 ... 
$ core   : Factor w/ 3 levels "Lula Core Municipality",..: 3 3 3 3 3 3 3 1 3 3 ... 
$ mayor.party.r : int 0 2 2 1 0 0 0 2 0 0 ... 
$ mayor.party.r2 : Factor w/ 3 levels "0.PT","1.Coalition",..: 3 1 1 2 3 3 3 1 3 3 ... 
$ pt.dummy  : int 0 1 1 0 0 0 0 1 0 0 ... 
$ trans.dummy  : int 1 1 1 1 1 1 1 0 1 1 ... 
$ year2   : Factor w/ 4 levels "2003-2004","2005-2006",..: 1 1 1 1 1 1 1 1 1 1 ... 
$ district  : Factor w/ 6 levels "PSDB/Coal","PSDB/Opo",..: 5 6 6 4 5 2 5 6 5 2 ... 
$ term   : int 0 0 0 0 0 0 0 0 0 0 ... 
$ time   : int 1 1 1 1 1 1 1 1 1 1 ... 
$ pt.pt   : int 0 1 1 0 0 0 0 1 0 0 ... 
$ pt.coa   : int 0 0 0 1 0 0 0 0 0 0 ... 
$ pt.opp   : int 1 0 0 0 1 0 1 0 1 0 ... 
$ psdb.pt   : int 0 0 0 0 0 0 0 0 0 0 ... 
$ psdb.coa  : int 0 0 0 0 0 0 0 0 0 0 ... 
$ psdb.opp  : int 0 0 0 0 0 1 0 0 0 1 ... 
$ district2  : Factor w/ 5 levels "Coal/Coal","Opp/Opp",..: 2 4 4 5 2 3 3 4 5 3 ... 
- attr(*, "na.action")=Class 'omit' Named int [1:1316] 59 235 242 409 437 555 588 594 645 673 ... 
    .. ..- attr(*, "names")= chr [1:1316] "59" "235" "242" "409" ... 
+3

如果您向我們顯示數據,此問題將更容易解決。 「pool $ pop」是什麼樣的?它是否包含'NaN'或'Inf'值? – 2012-02-15 10:08:41

+0

R有一個活動的混合模型郵件列表:https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models如果您沒有得到您需要的確切答案,請嘗試在那裏。 – 2012-02-15 10:13:29

+0

@tim謝謝!我也會在列表中發佈我的問題。 – user1172558 2012-02-15 17:32:33

回答

1

它看起來像(至少)你的類別之一是嚴重失衡,有可能在所有「trans.dummies」您的模型規範創建的一個或多個隱式交叉分類中的同一級別。解決這個問題的方法是顯示錶格。您可以從以下開始:

with(pool, table(trans.dummy, year ,munname)) 
+0

有沒有更簡單的方法來檢查數據是否巨大?我有43000觀察。 5000個科目(姓名)重複8年。桌子沒有幫助。但謝謝你的回答。 – user1172558 2012-02-15 17:34:21