Bug 14960 - Possible bug in anova.lmlist with test="Cp"
Summary: Possible bug in anova.lmlist with test="Cp"
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 2.15.x
Hardware: All All
: P5 normal
Assignee: R-core
Depends on:
Reported: 2012-06-26 15:49 UTC by Antonio Gasparrini
Modified: 2012-06-26 16:10 UTC (History)
0 users

See Also:


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

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)

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