The R-squared and adjusted R-squared statistics are not available in the ‘stats’ output of the programmatic STEPWISEFIT function. As a workaround, you can derive the values of the R-squared and adjusted R-squared statistics from other values that are in the output, by using the following commands
[b,se,pval,inmodel,stats,nextstep,history] = stepwisefit(XX,y);
n = length(y);
rsq = 1 - (history.rmse.^2/var(y)) .* ((n-1-history.df0)/(n-1))
adjrsq = 1 - history.rmse.^2/var(y)
Note that the RMSE field in "history" corresponds to the root mean square errors for the model at each step. Hence, "rsq" and "adjrsq" will be vectors, where the elements correspond to the R-squared values at different steps.
Best Answer