# Is the final model of backward elimination with AIC ​always​ the same as the final model of forward elimination with AIC?

I have a question: is the final model of backward elimination with AIC ​always​ the same as the final model of forward elimination with AIC? I assume that it is the same result

• Your assumption reminds me of the proverbial frog in the gradually heated frying pan, who never leaps out because the incremental changes are never relatively so bad as to provoke a jump. The same frog, if introduced into an initially hot pan, would leap out immediately. – whuber Oct 29 at 19:16

No.

The simplest way to investigate such a question is to simulate. Here is R code with 100 observations and 20 predictors, and we compare forward and backward stepwise model building:

set.seed(1)
library(MASS)

dataset <- as.data.frame(matrix(rnorm(2100),nrow=100,dimnames=list(NULL,c("y",LETTERS[1:20]))))

stepAIC(lm(y~1,dataset),scope=y~.,direction="forward")
stepAIC(lm(y~.,dataset),scope=y~.,direction="backward")


The first one stays with the intercept-only model, and the second one picks a model with two predictors labeled P and S. So the results are different.

In any case, be very careful with stepwise model selection, whether based on p values or on AIC. The result can be useful for prediction, but any NHST inference on the selected model is invalid.