How to get all R squared values in Stepwise regression?

9 views (last 30 days)
Hello,
I have a dataset and I want to do some sensitivity analysis to rank my independent variables based on their effect on the output. I want to use Stepwise regression. However, it just shows the final and overall R squared value (for the final model) when it finishes its job. Is there any way to force Matlab to print R squared values in each step, while it's adding one new term to the model?
So, in each step, I will be able to measure the importance of each term.
Thank you,

Answers (1)

the cyclist
the cyclist on 19 Feb 2014
If you are using stepwisefit(), look at the "history" output, which has the RMSE value at each step. You can calculate R^2 from the RMSE.
If you are using stepwise(), which is the interactive version of stepwise regression, you can see the value of R^2 at each step.
  1 Comment
Ehsan
Ehsan on 19 Feb 2014
Hi,
Thanks for your answer. Would you please explain more? I found this, written by Tom Lane:
"R^2 = 1 - SSE/SST = 1 - DFE*RMSE^2/SST Here SSE is the error sum of squares, SST is the total sum of squares, and DFE is the degrees of freedom for error." http://www.mathworks.com/matlabcentral/answers/36351-relationship-between-rmse-and-r-2
How can I get all these values when I am using stepwisefit()? Would you please give me an example?
Thank you.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!