本文介绍了BMA软件包的bic.glm中出现数据错误,但没有glm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从一组相互作用系数中估计一个泊松模型,而BMA软件包的bic.glm有助于导航模型空间.我已经使用了多年,但是昨晚我将R从2.10.x更新到2.14.2时,它停止工作了.这是错误:首先,一个可以正常工作的呼叫:

I am estimating a poisson model from a set of interaction coefficients, and the BMA package's bic.glm helps navigate the model space. I've been using it for years, but when I updated R from 2.10.x to 2.14.2 last night, it stopped working. Here's the error: first, a call that works:

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

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

Coefficients:
<results, etc>

现在bic.glm失败了:

Now bic.glm failing:

> 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个交互系统而不是5个交互系统运行bic.glm时(即放下x5并折叠交互),bic.glm运行良好.我将在下面包括五个系统数据.提前致谢.

Again, this exact code worked in the earlier version of R with five systems. When I run bic.glm with 4 interacting systems instead of 5 (i.e., drop x5 and collapse the interactions), bic.glm runs fine. I'll include the five system data below. Thanks in advance.

> 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   1   0   1   0   1   0    0    0    0    0    0    0
15  0  1  1  1  0   0   0   0   0   1   1   0   1   0   0    0    0    0    0    0    0
16  0  1  1  1  1   0   0   0   0   1   1   1   1   1   1    0    0    0    0    0    0
17  1  0  0  0  0   0   0   0   0   0   0   0   0   0   0    0    0    0    0    0    0
18  1  0  0  0  1   0   0   0   1   0   0   0   0   0   0    0    0    0    0    0    0
19  1  0  0  1  0   0   0   1   0   0   0   0   0   0   0    0    0    0    0    0    0
20  1  0  0  1  1   0   0   1   1   0   0   0   0   0   1    0    0    0    0    0    1
21  1  0  1  0  0   0   1   0   0   0   0   0   0   0   0    0    0    0    0    0    0
22  1  0  1  0  1   0   1   0   1   0   0   0   0   1   0    0    0    0    0    1    0
23  1  0  1  1  0   0   1   1   0   0   0   0   1   0   0    0    0    0    1    0    0
24  1  0  1  1  1   0   1   1   1   0   0   0   1   1   1    0    0    0    1    1    1
25  1  1  0  0  0   1   0   0   0   0   0   0   0   0   0    0    0    0    0    0    0
26  1  1  0  0  1   1   0   0   1   0   0   1   0   0   0    0    0    1    0    0    0
27  1  1  0  1  0   1   0   1   0   0   1   0   0   0   0    0    1    0    0    0    0
28  1  1  0  1  1   1   0   1   1   0   1   1   0   0   1    0    1    1    0    0    1
29  1  1  1  0  0   1   1   0   0   1   0   0   0   0   0    1    0    0    0    0    0
30  1  1  1  0  1   1   1   0   1   1   0   1   0   1   0    1    0    1    0    1    0
31  1  1  1  1  0   1   1   1   0   1   1   0   1   0   0    1    1    0    1    0    0
32  1  1  1  1  1   1   1   1   1   1   1   1   1   1   1    1    1    1    1    1    1
   x234 x235 x245 x345 x1234 x1235 x1245 x1345 x2345    Y
2     0    0    0    0     0     0     0     0     0 1276
3     0    0    0    0     0     0     0     0     0  714
4     0    0    0    0     0     0     0     0     0  481
5     0    0    0    0     0     0     0     0     0  628
6     0    0    0    0     0     0     0     0     0  365
7     0    0    0    0     0     0     0     0     0  836
8     0    0    0    1     0     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

推荐答案

我代表BMA软件包团队对此表示感谢,非常感谢.他们是这样说的:

I'm answering on behalf of the BMA package team, to whom I'm very grateful. Here's what they said:

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]

这篇关于BMA软件包的bic.glm中出现数据错误,但没有glm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 05:40