Least Squares Method

Categories: Metrics

When you’re looking for a great place to go with the fam, you head to Disney. When you’re looking for a linear equation to help you predict how your bivariate (or two-variable) data relating consumer confidence to profit shakes down for different consumer confidence ratings...you use the least squares method. And then go to Disney.

The least squares method is the method that produces the equation of the best-fit line, which is the line that, well, best fits (or represents) a set of linear-ish looking data on a scatter plot. Some people call the process linear regression, while others more familiar with the process call it...Steve.

The idea is to reduce the vertical, squared distances from each data point to the perfect line as much as possible, thereby getting the line that fits the data the best.

Imagine a set of data points scattered both above and below a line. Draw lines straight up to the line from points below and straight down to the line from points above. If we can locate a line such that all of those distances are as small as possible, we have our best-fit line. We introduce the whole “squared” thing to make all the distances positive, so that negative distances don’t cancel out positive ones.

The process requires finding the mean of both the x-data and y-data. Then we subtract the mean of the x’s from each x value. We do the same with the y mean and each y data point. We multiply those differences together for each data point and then sum up those values. This sum goes on top of a fraction. We take the x-differences, square them, and sum those values up, and that goes on the bottom of the same fraction.

Boom...instant slope of a best-fit line. Then, using a coordinate made up of the mean x and mean y, our newly minted slope, we can calculate the y-intercept of our best-fit line.

If this sounds like too much, just grab a graphing calculator, fire up a spreadsheet, or visit a website dedicated to finding best-fit lines. That’s what literally everyone else on Earth does.

Find other enlightening terms in Shmoop Finance Genius Bar(f)