function [swregdataset] = mySWReg(dataset) % apply stepwise regression beginning with no terms in the model and using % entrance/exit tolerances of 0.05/0.10 on the p-values: [myCoefficients,se,pval,selectedColumns,stats] = stepwisefit(trainSet(:,1:(size(dataset,2)-1)),trainSet(:,size(dataset,2)),'penter',0.05,'premove',0.10,'display','off'); % copy the selected columns swregdataset = []; for i =1:size(selectedColumns,1) if selectedColumns(i) == 1 swregdataset = [swregdataset,dataset(:,i)]; end end end