Hello,
while trying to define another anova method for a particular class, I noticed some problems with the method function for "lm" objects. When called on multiple models with test="Cp", R returns the error message:
Error in `[.data.frame`(table, , "Resid. Dev") :
undefined columns selected
An example:
y <- rnorm(20)
x <- rnorm(20)
f <- factor(rep(letters[1:2],each=10))
model1 <- lm(y~x)
model2 <- lm(y~x+f)
anova(model1,model2,test="Cp")
I believe there is an error in the anova.lmlist function.
At the fifth from the last line, I think:
n = length(objects[bigmodel$residuals])
should be replaced with:
n = length(objects[[bigmodel]]$residuals)
My apologies if this is not a bug.
With best wishes,
Antonio Gasparrini