Linear regression in matlab

Get Matlab Help Now..!

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

The MATLAB® Basic Fitting UI helps to fit the required data, so to calculate model coefficients and plot the model on top of the data. MATLAB polyfit and polyval functions can be used to fit the required data to a model that is linear in the coefficients.

MATLAB can perform various operations like Perform simple linear regression using the \ operator, Use correlation analysis to determine whether two quantities are related to justify fitting the data, Fit a linear model to the dataset, calculates the goodness of fit by plotting residuals and looking for patterns, Calculate measures of goodness of fit R2 and adjusted R2. These are some very basic operations which can be made easy using MATLAB.

If data is needed to fit with a nonlinear model, the variables should be transformed to make the relationship linear. Alternatively, either the Statistics and Machine Learning Toolbox™ nlinfit function, the Optimization Toolbox™ lsqcurvefit function, or by applying functions in the Curve Fitting Toolbox™ can be used to fit data. Before modelling the relationship between pairs of quantities, it is a good idea to perform correlation analysis to establish if a linear relationship exists between these quantities. Be aware that variables may show nonlinear relationships, which correlation analysis cannot detect.