Simple Linear Regression in Matlab Programming

Get Matlab Help Now..!

A data model distinctly defines a relationship between predictor and response variables. Linear regression fits a data model that has linear model coefficients. The most common type of linear regression is the method of least-squares fit, which is able to fit both lines and polynomials, among other linear models.

Before modelling the relationship among pairs of quantities, it will be a good idea to perform correlation analysis to check if a linear relationship exists between these quantities. Users should be aware that variables can have nonlinear relationships, which correlation analysis cannot detect this. The MATLAB Basic Fitting UI helps to fit the data, so user can calculate model coefficients and plot the model on top of this data. The MATLAB polyfit and polyval functions helps to fit data to a model that is linear in the coefficients.

If the data is required to fit data with a nonlinear model, transformation of the variables should be done to make the relationship linear. Alternatively,user may attempt to fit a nonlinear function directly using either of the Statistics and Machine Learning Toolbox™ nlinfit function, the Optimization Toolbox™ lsqcurvefit function, or by using functions in the Curve Fitting Toolbox™.

Fundamentals of MATLAB Classes

Linear regression models the relation among a dependent, or response, variable and one or more independent, or predictor, variables . Simple linear regression takes only one independent variable using the relation

where is the y-intercept, is the slope (or regression coefficient), and is the error term.