[R] stepAIC() that can use new extractAIC() function implementing AICc

Marc Girondot marc_grt at yahoo.fr
Thu Jun 8 10:34:16 CEST 2017

I have found the problem and a solution.

The problem comes from the functions addterm.glm() and dropterm.glm() 
from MASS package. They use extractAIC() without transmitting the ... 

aic <- aic + (extractAIC(object, k = k)[2L] - aic[1L])

I replace the call with:
aic <- aic + (extractAIC(object, k = k, ...)[2L] - aic[1L])

and I create dropterm.glm() and addterm.glm() in global environnement.
I add:
dropterm <- dropterm.lm <- dropterm.glm
addterm <- addterm.lm <- addterm.glm

I copy also stepAIC from MASS package to global environnement.
I detach MASS package, and it works:

 > stepAIC(G1, criteria="AICc", steps = 1)
Start:  AIC=70.06
x ~ A + B

        Df Deviance    AIC
- A     1   48.506 68.355
<none>      47.548 70.055
- B     1   57.350 70.867

Now stepAIC can use AICc


More information about the R-help mailing list