|
Brighton Webs Ltd. Data Analysis and Database Services for Industry & Education
|
||||||||||||||||||||||||||||
|
Home Index Feedback |
Linear Regression Linear regression is one of the basic tools of modelling. It creates a linear relationship between an independent variable (i.e. x) and a dependent one (i.e. y) in the form: The assumption is that the error (i.e. e): is normally distributed. These two formula are illustrated on the graphic below: Related Topics A.KA. (Also known As) The method is also referred to as "least squares", "line of best fit" and "curve fitting". Calculation of A and B The formulae for for calculating A and B are often referred to as the "Normal Equations", they are set out in many ways, the sum of squares notation used below, can be adapted for computer programs and manual computation:
Example The price of independently branded, non-organic flour in a supermarket is related to its protein content. In the page on correlation, it was established that the relationship between price and protein content was significant, this example attempts to quantify that relationship. The data is shown in tabular form below:
The sum of squares values are:
The final step is the calculation of the gradient (b) and the intercept (a)
The graph shows the data points in relationship to the regression parameters: Psuedo Code The psuedo code is in the style of MS Visual Basic. It is assumed that N pairs of X and Y values are stored in arrays (base index zero)
''*************************************************************** 'Calculation of Mean
'Sum of Squares
'Slope and Intercept
Page modified: 04-Mar-2008 |
||||||||||||||||||||||||||||
|
For more information: info@brighton-webs.co.uk |
|||||||||||||||||||||||||||||