cliu
cliu

Reputation: 965

StepAIC() stopping point

I am trying to understand the stopping point of StepAIC(). When using direction = 'backward', does it stop if any further deletion of the terms no longer decreases model AIC? Example as follows:

fm<- lm(mpg ~ ., data = mtcars)
require(MASS)
fit_fm <- stepAIC(fm, direction = 'backward')
#The final step stopped at:
Step:  AIC=61.31
mpg ~ wt + qsec + am

       Df Sum of Sq RSS  AIC
<none>              169 61.3
- am    1      26.2 195 63.9
- qsec  1     109.0 278 75.2
- wt    1     183.3 353 82.8

Does this mean deleting any of the terms wt, qsec, or am will not decrease model AIC at all (i.e., all AICs=61.31)?

Upvotes: 0

Views: 930

Answers (2)

Gregor Thomas
Gregor Thomas

Reputation: 145775

       Df Sum of Sq RSS  AIC
<none>              169 61.3
- am    1      26.2 195 63.9
- qsec  1     109.0 278 75.2
- wt    1     183.3 353 82.8

This table is showing you the AIC if you delete any more terms, with the <none> row being the current model.

If you keep the model as-is, the additional terms deleted are <none>, and the AIC is 61.3. Each other row shows the AIC if you delete those terms, (remove am, get AIC of 63.9, etc.). So you are correct, deleting any of the remaining terms will raise the AIC - you are at a (local) minimum for AIC.

Upvotes: 2

Ben Bolker
Ben Bolker

Reputation: 226182

Yes, that's right. You can check this yourself (the second value from extractAIC() is the AIC):

extractAIC(fm_nowt <- update(fit_fm, . ~ . -wt))
## [1]  3.00000 82.79016
extractAIC(fm_noqsec <- update(fit_fm, . ~ . -qsec))
## [1]  3.00000 75.21711
extractAIC(fm_noam <- update(fit_fm, . ~ . -am))
## [1]  3.00000 63.90843

Note that the values returned by extractAIC() are different from those returned by AIC() in base R, but the differences between model AICs (which is all we really care about) are the same:

 AIC(fm_nowt)- AIC(fit_fm)
[1] 21.48286
> extractAIC(fm_nowt)- extractAIC(fit_fm)
[1] -1.00000 21.48286

Upvotes: 1

Related Questions