best subset regression / all-possible regression

15 views (last 30 days)
Hi all,
I have a large number of regressor and I need to select which ones are the best to fit the linear regression model of the form: y=b0+b1*x1+...+bn*xn+e
I performed a stepwise regression to select a first subset of rergessor but now I need to go for the finer details, so I would like to perform a best subset regressor (or an all-possible regression) in order to select the actual regressors.
I would like to know wether there is an in-built function to do this, like the "stepwiselm" function to perform the stepwise regression. If not, has anyone developed his own code to do the all-possible/best subset regression? Could he give me the code?
thank you in advance for your help!
  1 Comment
Ethan Duckworth
Ethan Duckworth on 2 Jan 2024
There is a good Mathworks blog post about this. There is not a single command to do it, but the example shows relatively short combination of commands to look at all possible subsets with 8 predictors

Sign in to comment.

Answers (1)

Firat Soylu
Firat Soylu on 27 Mar 2022
I found this question while looking for the same thing (best subsets regression). It is an old question, but just in case others end up here with the same question: It doesn't seem like there is a best subsets regression function in Matlab that exhaustively considers all possible models. However if you are in need of trying many different models (linear regression or other types) then the regression learner ('regressionLearner') might possibly help.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!