Stepwise Regression In R software - Part I

Описание к видео Stepwise Regression In R software - Part I

Cautions!!!!!!!!
Here are some things to keep in mind concerning the stepwise regression procedure:
1.The final model is not guaranteed to be optimal in any specified sense.
The procedure yields a single final model, although there are often several equally good models.
2. Stepwise regression does not take into account a researcher's knowledge about the predictors. It may be necessary to force the procedure to include important predictors.
3.One should not over-interpret the order in which predictors are entered into the model.
4. One should not jump to the conclusion that all the important predictor variables for predicting y have been identified, or that all the unimportant predictor variables have been eliminated. It is, of course, possible that we may have committed a Type I or Type II error along the way.
5. Many t-tests for testing βk=0 are conducted in a stepwise regression procedure. The probability is therefore high that we included some unimportant predictors or excluded some important predictors.
6. It's for all of these reasons that one should be careful not to overuse or overstate the results of any stepwise regression procedure.
##################
code for stepwise regression
#Stepwise regression
#define intercept-only model
intercept_only=lm(GY ~ 1, data=RR)
#define model with all predictors
all=lm(GY~., data=RR)
summary(all)
#perform forward stepwise regression
forward=step(intercept_only, direction='forward', scope=formula(all), trace=1)
#view results of forward stepwise regression
forward$anova
#view final model
forward$coefficients
summary(forward)
###################################
#perform backward stepwise regression
backward=step(all, direction='backward', scope=formula(all), trace=1)
summary(backward)
#view results of backward stepwise regression
backward$anova
#view final model
backward$coefficients
both=step(intercept_only, direction='both', scope=formula(all), trace=1)
summary(both)
both$coefficients
both$anova
#############

Комментарии

Информация по комментариям в разработке