MATLAB: How to ensure that “stepwiselm” only removes terms from a model without ever adding any

penterpremoveStatistics and Machine Learning Toolboxstepwiselm

I am trying to do a stepwise regression in which I initially specify a regression model, and then remove insignificant terms from the pre-specified model, without adding any new terms. How can I do this using "stepwiselm"?

Best Answer

For "stepwiselm"s default SSE criterion, a term is added when the SSE is smaller than 'PEnter' and is removed when it is larger than 'PRemove'. You can therefore make sure that "stepwiselm" never adds a term when using the SSE criterion by setting the value of 'PEnter' to 0 (or less). You may need to specify a different value of 'PEnter' if using some other value of 'Criterion' - please refer to the following link for documentation on the behavior of 'PEnter' and 'PRemove' for different criteria:
You may, however, find that using the above method results in some desired terms not appearing in the computed model, since they may have been removed at some stage of the process without the ability to later add them back in. If this is the case, consider removing the PEnter = 0 property and instead use the 'Upper' input to "stepwiselm" to ensure that undesired terms are not added to the model. Details on how to supply the 'Upper' argument can also be found at the above link.