Documentation |
Create linear regression model using stepwise regression
mdl = stepwiselm(tbl,modelspec) returns a linear model for the variables in the table or dataset array tbl using stepwise regression to add or remove predictors. stepwiselm uses forward and backward stepwise regression to determine a final model. At each step, the function searches for terms to add to or remove from the model based on the value of the 'Criterion' argument. modelspec is the starting model for the stepwise procedure.
mdl = stepwiselm(X,y,modelspec) creates a linear model of the responses y to the predictor variables in the data matrix X, using stepwise regression to add or remove predictors. modelspec is the starting model for the stepwise procedure.
mdl = stepwiselm(___,Name,Value) creates a linear model for any of the inputs in the previous syntaxes, with additional options specified by one or more Name,Value pair arguments.
For example, you can specify the categorical variables, the smallest or largest set of terms to use in the model, the maximum number of steps to take, or the criterion stepwiselm uses to add or remove terms.
You can construct a model using fitlm, and then manually adjust the model using step, addTerms, or removeTerms.
fitlm | LinearModel | step