From Yves.Rosseel at UGent.be  Mon Mar 13 15:24:44 2006
From: Yves.Rosseel at UGent.be (Yves.Rosseel@UGent.be)
Date: Mon, 13 Mar 2006 15:24:44 +0100 (CET)
Subject: [Rd] anova.mlm (single-model case) does not handle factors?
	(PR#8679)
Message-ID: <20060313142444.8D92C10401@slim.kubism.ku.dk>

Full_Name: Yves Rosseel
Version: 2.2.1
OS: i686-pc-linux-gnu
Submission from: (NULL) (157.193.116.152)


Dear developers,

For the single-model case, the anova.mlm() function does not seem to handle
multi-parameter predictors (eg factors) correctly. A toy example illustrates the
problem:

Y <- cbind(rnorm(100),rnorm(100),rnorm(100))
A <- factor(rep(c(1,2,3,4), each=25))
fit <- lm(Y ~ A)
anova.mlm(fit)

gives

Error in T %*% ss[[i]] : non-conformable arguments

I think the problem lies in the computation of the 'ss' terms (line 237 in the
file mlm.R in the source code). Changing this (and the following line) by
something similar to what is done in summary.manova seems to resolve the
problem:

 comp <- as.matrix(fit$effects)[seq(along=asgn), ,drop=FALSE]
 uasgn <- unique(asgn)
 nterms <- length(uasgn)
 ss <- list(nterms)
 df <- numeric(nterms)
 for(i in seq(nterms)) {
    ai <- (asgn == uasgn[i])
    ss[[i]] <- crossprod(comp[ai, ,drop=FALSE])
    df[i] <- sum(ai)
 }



[Rd] anova.mlm (single-model case) does not handle factors? (PR#8679)
Yves.Rosseel@UGent.be