Stepwise Regression

Stepwise Regression to Select Appropriate Models

stepwiselm creates a linear
model and automatically adds to or trims the model. To create a small
model, start from a constant model. To create a large model, start
with a model containing many terms. A large model usually has lower
error as measured by the fit to the original data, but might not have
any advantage in predicting new data.

stepwiselm can use all the name-value options
from fitlm, with additional options
relating to the starting and bounding models. In particular:

For a small model, start with the default lower bounding
model: 'constant' (a model that has no predictor
terms).

The default upper bounding model has linear terms
and interaction terms (products of pairs of predictors). For an upper
bounding model that also includes squared terms, set the Upper name-value
pair to 'quadratic'.