O'Reilly logo

MATLAB for Machine Learning by Giuseppe Ciaburro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to create a linear regression model

More generally, to create a linear regression model, use the fitlm() function. This function creates a LinearModel object. The object in the workspace has a series of properties that can be immediately viewed by simply clicking on it. Methods such as plot, plotResiduals, and plotDiagnostics are available if you want to create plots and perform a diagnostic analysis.

LinearModel is an object comprising training data, model description, diagnostic information, and fitted coefficients for a linear regression.

By default, fitlm() takes the last variable in the table or dataset array as the response. Otherwise, we have to specify predictors and response variables, for example, as a formula. In addition, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required