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
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.