Skip to content
Prev 324946 / 398503 Next

glm.nb error

As Marc already pointed out, take a close look at this part of your loop:

R> i <- 6
R>
R> y <- as.numeric(data[i,-1])
R> y
[1] 3 3 3 3 4 4 4 4
R> group
[1] 1 1 1 1 0 0 0 0
R> fit <- glm.nb(y~group)
Error in while ((it <- it + 1) < limit && abs(del) > eps) { :
  missing value where TRUE/FALSE needed

What do you expect to happen there?

In general, it's a better practice to pre-specify the size of result
(eg matrix(NA, nrow=n, ncol=4) ) and fill it as you go, rather than
using rbind() within a loop. Much more memory-efficient.

Sarah
On Fri, Jun 7, 2013 at 11:58 AM, Daofeng Li <lidaof at gmail.com> wrote: