[R] anova.mlm for single model (one-way repeated measured anova)

From: takahashi kohske <talepanda_at_gmail.com>
Date: Sat 12 Aug 2006 - 14:36:23 EST


Dear list members:

I'd like to one-way repeated measured anova by using mlm. I'm using R-2.3.1 and my code is:

dat<-matrix( c(9,7,8,8,12,11,8,13,     6,5,6,3,6,7,10,9,
               10,13,8,13,12,14,14,16, 9,11,13,14,16,12,15,14),
            ncol=4, dimname=list(s=1:8, c=1:4))
mlmfit<-lm(dat~1)
anova(mlmfit, X=~1)
Error: ceiling(length.out) : Non-numeric argument to mathematical function

this error occurs in anova.mlm

        if (rk > 0) {
            p1 <- 1:rk
            comp <- object$effects[p1, ]
            asgn <- object$assign[object$qr$pivot][p1]
            nmeffects <- c("(Intercept)", attr(object$terms,
                "term.labels"))
            tlabels <- nmeffects[1 + unique(asgn)]
             ix <- split(seq(length = nrow(comp)), asgn)  #HERE
            ss <- lapply(ix, function(i) crossprod(comp[i, ,
                drop = FALSE]))
            df <- sapply(split(asgn, asgn), length)
        }

because nrow(comp) returns NULL.

in my memory, R-2.2.* ( or may be R-2.3.0) can correctly handle this code. so, I think this is a kind of side-effect of fixing PR#8679.

currently, i can workaround as follows:

anova(mlmfit, update(mlmfit, ~0), X=~1)

this code returns correct answer.

I don't know whether this behavior is correct or bug. Please give me suggesion.

thanks in advance.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Aug 12 14:41:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 12 Aug 2006 - 18:18:14 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.