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

%%  Load the dataset

% Boston Housing Dataset taken from the CMU StatLib archive:  

% Import the file into Excel using Tab deliminated format.
% Use the first row of information to define column headers from the list
% provided

% The dataset command will work fine without column headers, but
% easy-to-remember variable names make it much easier to understand what's
% happening during the analysis.

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