[R] Bug in stepAIC?

From: Martin C. Martin <martin_at_martincmartin.com>
Date: Wed 11 Oct 2006 - 16:30:56 GMT


Hi,

First of all, thanks for the great work on R in general, and MASS in particular. It's been a life saver for me many times.

However, I think I've discovered a bug. It seems that, when I use weights during an initial least-squares regression fit, and later try to add terms using stepAIC(), it uses the weights when looking to remove terms, but not when looking to add them:

hills.lm <- lm(time ~ dist + climb, data = hills, weights = 1/dist2) small.hills.lm <- stepAIC(hills.lm)
stepAIC(small.hills.lm, time ~ dist + climb)

In the first stepAIC(), it says that the AIC for the full "time ~ dist + climb" is 94.41. Yet, during the second stepAIC, it says adding climb would produce an AIC of 212.1 (and an RSS of 12633.3). Is this a bug?

Best,
Martin



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Oct 12 02:35:09 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 12 Oct 2006 - 13:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.