Least-squares regression seeks to minimze the residual (or error) between data points and corresponding points on the curve (trend line).
Consider the equation of a straight line:
Rearranging, we would have:
A common strategy would be to minimize the sum of squares of the residuals, such as:
Least Squares Regression Formulation
We differentiate the sum of residuals with respect to the coefficients:
Setting the derivatives equal to zero will minimize :
Since , where is the number of data points, we can express the equations as a set of simultaneous linear equations with two unknowns:
\Thus, we can solve for :
Least Square Regression Equations
where are the means of