Least Squares Line

 

Videos

     Subscribe to me on YouTube

 

You can think of the least squares line, also referred to as the line of least squares, as the line that averages a given set of points. Given any number of coordinate points in a set, you can find the line that averages all of them by using the least squares method. The line might not intersect any of the points directly, but it will give you their average.

To find the least squares line, you can use the slope-intercept equation of the line, which we’ll write as y=ax+b, where a is the slope of the line, and b is the y-intercept. Just use the formulas below to find a and b.

a=\frac{n(x_1y_1+…+x_ny_n)-(x_1+…+x_n)(y_1+…+y_n)}{n(x_1^2+…+x_n^2)-(x_1+…+x_n)^2}

b=\frac{(y_1+…+y_n)-a(x_1+…+x_n)}{n}

These least squares line formulas seem complicated, but they’re actually very simple. I like to summarize them in my head like this:

a=\frac{n(\mbox{sum }xy)-(\mbox{sum }x)(\mbox{sum }y)}{n(\mbox{sum }x^2)-(\mbox{sum }x)^2}

b=\frac{(\mbox{sum }y)-a(\mbox{sum }x)}{n}

If you’re given a set of 5 coordinate points, x in the formulas above will come from the x-coordinates, y will come from the y-coordinates, and n is the number of points in your set, in this case, 5.

As you can see from above, a is included in the formula for b, which means you’ll have to compute a first, then b.

In summary, follow these steps to find the equation of the least squares line:

  1. Compute a
  2. Compute b
  3. Plug a and b into the formula for the slope-intercept equation of the line
  4. Simplify the equation as much as possible
 

 

 

 

 

 

© 2012 integralCALC
Privacy Policy