FUNCTION REFERENCE
stepwiselm
Select a numeric linear model by forward and backward partial F tests.
Select a numeric linear model by forward and backward partial F tests.
Syntax
mdl = stepwiselm(X,y); mdl = stepwiselm(...,'PEnter',0.05,'PRemove',0.10); mdl = stepwiselm(...,'Upper','linear')Starts from an intercept-only model and considers main effects and two-way interactions by default. Additions use the smallest partial F-test p-value below PEnter; removals use the largest p-value above PRemove. Lower-order terms remain while their interactions are present. Prints each accepted adding/removing step and returns a LinearModel. Optional initial model specifications and numeric tables follow fitlm. All candidates use the same complete observations from the upper model.
Example
mdl=stepwiselm([0;1;2;3;4;5],[1;3;4;7;9;10]); mdl.CoefficientsDifferences from MATLAB: numeric predictors only; selection supports the F-test criterion, PEnter, PRemove and Upper. Requires 0 < PEnter < PRemove < 1 and an intercept. At most 16 predictors and 1024 candidate fits are allowed; fitlm workspace limits also apply. Other selection criteria and Lower are unsupported.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.