# Least Squares Method: What It Means and How to Use It, With Examples

![Least Squares Methods](https://www.investopedia.com/thmb/00slg02wynhMgnRGGg8yhEYTNSA=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/LeastSquaresMethod-4eec23c588ce45ec9a771f1ce3abaf7f.jpg)

*Thos method provides simplicity and ease of calculation. — Investopedia / Xiaojie Liu*

> **Definition**
>
> The least squares method determines the line of best fit for a dataset represented on a graph.

## What Is the Least Squares Method?

The least squares method is a form of mathematical regression analysis used to select the trend line that best represents a set of data in a chart. That is, it is a way to determine the [line of best fit](https://www.investopedia.com/terms/l/line-of-best-fit.asp) for a set of data. Each point of data represents the relationship between a known independent variable and an unknown dependent variable.

This method is often used by stock analysts and traders who want to identify opportunities and trends.

### Key Takeaways

*   Least squares regression is used to predict the behavior of dependent variables.
*   The least squares method is used to find the best fit for a set of data points.
*   The method minimizes the sum of the offsets or residuals of points from the plotted curve.  
    
*   The least squares method provides the overall rationale for the placement of the line of best fit among the data points being studied.

## Understanding the Least Squares Method

The least squares method is a form of [regression analysis](https://www.investopedia.com/terms/r/regression.asp) that provides the overall rationale for the placement of the line of best fit among the data points being studied. It begins with a set of data points using two variables, which are plotted on a graph along the x- and y-axis. Traders and analysts can use this as a tool to pinpoint [bullish and bearish](https://www.investopedia.com/insights/digging-deeper-bull-and-bear-markets/) trends in the market along with potential trading opportunities.

The most common application of this method is sometimes referred to as linear or ordinary. It aims to create a straight line that minimizes the [sum of squares](https://www.investopedia.com/terms/s/sum-of-squares.asp) of the errors generated by the results of the associated equations, such as the squared residuals resulting from differences in the observed value and the value anticipated based on that model.

For instance, an analyst may use the least squares method to generate a line of best fit that explains the potential relationship between independent and dependent variables. The line of best fit determined from the least squares method has an equation that highlights the relationship between the data points.

If the data shows a lean relationship between two variables, it results in a least-squares regression line. This minimizes the vertical distance from the data points to the regression line. The term least squares is used because it is the smallest sum of squares of errors, which is also called the variance. A non-linear least-squares problem, on the other hand, has no closed solution and is generally solved by iteration.  

> **Important**
>
> Dependent variables are illustrated on the vertical y-axis, while independent variables are illustrated on the horizontal x-axis in regression analysis. These designations form the equation for the line of best fit, which is determined from the least squares method.

## Advantages and Disadvantages of the Least Squares Method

The best way to find the line of best fit is by using the [least squares](https://www.investopedia.com/terms/l/least-squares.asp) method. However, traders and analysts may come across some issues, as this isn't always a foolproof way to do so. Some of the pros and cons of using this method are listed below.

### Advantages

One of the main benefits of using this method is that it is easy to apply and understand. That's because it only uses two variables (one that is shown along the x-axis and the other on the y-axis) while highlighting the best relationship between them.

Investors and analysts can use the least square method by analyzing past performance and making predictions about future trends in the economy and stock markets. As such, it can be used as a decision-making tool.  

### Disadvantages

The primary disadvantage of the least square method lies in the data used. It can only highlight the relationship between two variables. As such, it doesn't take any others into account. And if there are any outliers, the results become skewed.  

Pros

*   Easy to apply and understand
    
*   Highlights relationship between two variables
    
*   Can be used to make predictions about future performance
    

Cons

*   Only highlights relationship between two variables
    
*   Doesn't account for outliers
    

> **Fast Fact**
>
> Equations from the line of best fit may be determined by computer software models, which include a summary of outputs for analysis, where the coefficients and summary outputs explain the dependence of the variables being tested.

## Example of the Least Squares Method

Here's a hypothetical example to show how the least square method works. Let's assume that an analyst wishes to test the relationship between a company’s [stock returns](https://www.investopedia.com/articles/investing/011416/how-evaluate-stock-performance.asp) and the returns of the index for which the stock is a component. In this example, the analyst seeks to test the dependence of the stock returns on the index returns.

To achieve this, all of the returns are plotted on a chart. The index returns are then designated as the independent variable, and the stock returns are the dependent variable. The line of best fit provides the analyst with a line showing the relationship between dependent and independent variables.  

## What Is the Least Squares Method?

The least squares method is a mathematical technique that allows the analyst to determine the best way of fitting a curve on top of a chart of data points. It is widely used to make scatter plots easier to interpret and is associated with regression analysis. These days, the least squares method can be used as part of most statistical software programs.

## How Is the Least Squares Method Used in Finance?

The least squares method is used in a wide variety of fields, including finance and investing. For financial analysts, the method can help quantify the relationship between two or more variables, such as a stock’s share price and its [earnings per share (EPS)](https://www.investopedia.com/terms/e/eps.asp). By performing this type of analysis, investors often try to predict the future behavior of stock prices or other factors.

## What Is an Example of the Least Squares Method?

Consider the case of an investor considering whether to invest in a gold mining company. The investor might wish to know how sensitive the company’s stock price is to changes in the market price of gold. To study this, the investor could use the least squares method to trace the relationship between those two variables over time onto a scatter plot. This analysis could help the investor predict the degree to which the stock’s price would likely rise or fall for any given increase or decrease in the price of gold.

## Who First Discovered the Least Squares Method?

Although the inventor of the least squares method is up for debate, the German mathematician Carl Friedrich Gauss claims to have invented the theory in 1795.

## The Bottom Line

Traders and analysts have a number of tools available to help make predictions about the future performance of the markets and economy. The least squares method is a form of regression analysis that is used by many technical analysts to identify trading opportunities and market trends. It uses two variables that are plotted on a graph to show how they're related.

> **Article Sources**
>
> 1.  Stigler, Stephen M. "[Gauss and The Invention of Least Squares](https://projecteuclid.org/journals/annals-of-statistics/volume-9/issue-3/Gauss-and-the-Invention-of-Least-Squares/10.1214/aos/1176345451.full)." _The Annals of Statistics_, vol. 9, no, 3, May 1981, pp. 465. Download PDF.