Bug 14960 - Possible bug in anova.lmlist with test="Cp"
Possible bug in anova.lmlist with test="Cp"
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Misc
R 2.15.0 patched
All All
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-26 15:49 UTC by Antonio Gasparrini
Modified: 2012-06-26 16:10 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Gasparrini 2012-06-26 15:49:31 UTC
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