Step(intercept-only model, direction, scope) We will fit a multiple linear regression model using mpg (miles per gallon) as our response variable and all of the other 10 variables in the dataset as potential predictors variables.įor each example will use the built-in step() function from the stats package to perform stepwise selection, which uses the following syntax: Mpg cyl disp hp drat wt qsec vs am gear carb This tutorial explains how to perform the following stepwise regression procedures in R:įor each example we’ll use the built-in mtcars dataset: #view first six rows of mtcars The goal of stepwise regression is to build a regression model that includes all of the predictor variables that are statistically significantly related to the response variable. Stepwise regression is a procedure we can use to build a regression model from a set of predictor variables by entering and removing predictors in a stepwise manner into the model until there is no statistically valid reason to enter or remove any more.
0 Comments
Leave a Reply. |