There is a bug in AIC.default and AIC.lm, as illustrated below.
(I've only checked this under 1.6.1, and can't easily check if it has
already been reported since the site is down.)
Error in "row.names<-.data.frame"(*tmp*, value =
as.character(match.call()[-1])) :
invalid row.names length
The offending line is
row.names(val) <- as.character(match.call()[-1])
One possible (but probably overly complicated) solution is
AIC.default
function (object, ..., k = 2)
{
if (length(list(...))) {
dots <- as.list(substitute(list(...)))[-1] ## added
dots <- sapply(dots, function(x) deparse(x)) ## added
rnm <- c(deparse(substitute(object)), dots) ## added
object <- list(object, ...)
val <- lapply(object, logLik)
val <- as.data.frame(t(sapply(val, function(el) c(attr(el,
"df"), AIC(el, k = k)))))
names(val) <- c("df", "AIC")
row.names(val) <- rnm ## altered
val
}
else {
AIC(logLik(object), k = k)
}
}
Alec Stephenson tel +44 (0) 1524 593950
Department of Mathematics and Statistics fax +44 (0) 1524 592681
Lancaster University a.stephenson@lancaster.ac.uk
Lancaster LA1 4YF http://www.maths.lancs.ac.uk/~stephena/