2012-11-18 32 views
1

我從一組相互作用係數估計泊松模型,BMA包的bic.glm有助於導航模型空間。我一直在使用它,但是當我昨晚從2.10.x更新到2.14.2時,它停止工作。這裏的錯誤:第一,一個可行的呼叫:BMA包中的bic.glm數據錯誤,但不包含glm

> glm(formula(Y~.), data=XY5, family=poisson) 

Call: glm(formula = formula(Y ~ .), family = poisson, data = XY5) 

Coefficients: 
<results, etc> 

現在bic.glm失敗:

> bic.glm(formula(Y~.), data=XY5, glm.family=poisson, model=TRUE) 
Error in terms.formula(formula, data = data) : 
    '.' in formula and no 'data' argument 

同樣,這個確切的代碼中R的早期版本曾與五大系統。當我使用4個交互系統運行bic.glm而不是5(即,放下x5並摺疊交互)時,bic.glm運行良好。我將在下面列出五個系統數據。提前致謝。

> XY5 
    x1 x2 x3 x4 x5 x12 x13 x14 x15 x23 x24 x25 x34 x35 x45 x123 x124 x125 x134 x135 x145 
2 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
3 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
4 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 
5 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
6 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 
7 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 
8 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 
9 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
10 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 
11 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 
12 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 
13 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 
14 0 1 1 0 1 0 0 0 0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0  0  0  0 1343 
9  0 0 0 0  0  0  0  0  0 1348 
10 0 0 0 0  0  0  0  0  0 161 
11 0 0 0 0  0  0  0  0  0 266 
12 0 0 1 0  0  0  0  0  0 239 
13 0 0 0 0  0  0  0  0  0 144 
14 0 1 0 0  0  0  0  0  0 135 
15 1 0 0 0  0  0  0  0  0 469 
16 1 1 1 1  0  0  0  0  1 1356 
17 0 0 0 0  0  0  0  0  0 594 
18 0 0 0 0  0  0  0  0  0 431 
19 0 0 0 0  0  0  0  0  0 18 
20 0 0 0 0  0  0  0  0  0 83 
21 0 0 0 0  0  0  0  0  0 22 
22 0 0 0 0  0  0  0  0  0 16 
23 0 0 0 0  0  0  0  0  0 12 
24 0 0 0 1  0  0  0  1  0 29 
25 0 0 0 0  0  0  0  0  0 16 
26 0 0 0 0  0  0  0  0  0 3 
27 0 0 0 0  0  0  0  0  0 2 
28 0 0 1 0  0  0  1  0  0 3 
29 0 0 0 0  0  0  0  0  0 6 
30 0 1 0 0  0  1  0  0  0 0 
31 1 0 0 0  1  0  0  0  0 11 
32 1 1 1 1  1  1  1  1  1 9 
+0

開啓後跟蹤和關閉,錯誤更改爲「錯誤as.environment(其中):無效的POS'的說法」我不覺得更接近,但我想,能夠影響錯誤總是很好的。 – wylbur

回答

1

我代表BMA團隊回答問題,我非常感謝他。下面是他們說的話:

I think there may be some unanticipated degeneracy due to the discrete nature of the data that is causing this problem to surface. I will update the package accordingly, but you should be able to fix it by adding the line indicated below to bic.glm.data.frame (and bic.glm.matrix)

while (length(glm.out$coefficients) > maxCol) { 
      any.dropped <- TRUE 
      dropglm <- drop1(glm.out, test = "Chisq") 
      dropped <- which.max(dropglm$"Pr(Chi)"[-1]) + 1 
# 
      if (length(dropped) == 0) break #### add to prevent bug 
# 
      x.df <- x.df[, -(dropped - 1)] 
      designx.levels <- designx.levels[-dropped] 
      designx <- designx[-dropped] 
+0

順便說一句,我檢查了,它適用於我:) – wylbur