Code covered by the BSD License  

Highlights from
New Regression Capabilities in r2012a

image thumbnail

New Regression Capabilities in r2012a


Richard Willey (view profile)


Example code to accompany the "New Regression Capabilities" presentation

%% Using LinearModel for Stepwise Regression
% Copyright (c) 2012, The MathWorks, Inc.

%%  Load the dataset

% Boston Housing Dataset taken from the CMU StatLib archive:  

Housing = dataset('xlsfile', 'Housing.xlsx');

%% Convert CharlesRiver to a nominal variable
Housing.CharlesRiver = nominal(Housing.CharlesRiver);

%% Generate a regression
myFit =;

%% Apply stepwise regression

myFit2 = LinearModel.stepwise(Housing);

%% Stepwise regression options
myFit3 = LinearModel.stepwise...
    (Housing, 'Upper', 'linear', 'Criterion', 'aic')

Contact us