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 <
lid...@gmail.com> wrote:
> Sorry Sarah.
>
>> dput(dat)
> structure(list(gene = structure(c(1L, 3L, 4L, 5L, 6L, 7L, 8L,
> 9L, 10L, 2L), .Label = c("gene1", "gene10", "gene2", "gene3",
> "gene4", "gene5", "gene6", "gene7", "gene8", "gene9"), class = "factor"),
> b1 = c(18L, 15L, 10L, 4L, 0L, 3L, 0L, 4L, 11L, 6L), b2 = c(15L,
> 8L, 9L, 0L, 1L, 3L, 4L, 4L, 6L, 3L), b3 = c(13L, 8L, 8L,
> 4L, 0L, 3L, 0L, 7L, 13L, 6L), b4 = c(13L, 7L, 12L, 3L, 0L,
> 3L, 2L, 3L, 10L, 3L), c1 = c(16L, 0L, 9L, 0L, 1L, 4L, 2L,
> 0L, 13L, 4L), c2 = c(9L, 12L, 11L, 5L, 5L, 4L, 2L, 6L, 7L,
> 7L), c3 = c(20L, 18L, 12L, 0L, 1L, 4L, 0L, 6L, 12L, 6L),
> c4 = c(24L, 4L, 12L, 0L, 0L, 4L, 0L, 12L, 9L, 3L)), .Names = c("gene",
> "b1", "b2", "b3", "b4", "c1", "c2", "c3", "c4"), class = "data.frame",
> row.names = c(NA,
> -10L))
>
> above was the dput(dat). Thanks.