Find Linear Regression Equation

Linear regression is a statistical method used to find the line of best fit for a given data set. It is used to predict the value of a dependent variable based on the values of one or more independent variables. The linear regression equation is a mathematical equation that takes the form y = ax + b, where y is the dependent variable, x is the independent variable, and a and b are constants. The values of a and b can be determined using the least squares method, and can be used to predict the value of y for any given value of x.


Often you may want to find a linear regression equation from a table of data.

For example, suppose you are given the following table of data:

The following step-by-step example explains how to find a linear regression equation from this table of data.

Step 1: Calculate X*Y, X2, and Y2

First, we’ll calculate the following metrics for each row:

  • x*y
  • x2
  • y2

The following screenshot shows how to do so:

Step 2: Calculate ΣX, ΣY, ΣX*Y, ΣX2, and ΣY2

Next, we’ll calculate the sum of each column:

Step 3: Calculate b0

The formula to calculate the intercept of the regression equation, b0, is as follows:

  • b0 = ((Σy)(Σx2) – (Σx)(Σxy))  /  (n(Σx2) – (Σx)2)
  • b0 = ((128)(831) – (85)(1258))  /  (10(831) – (85)2)
  • b0 = -0.518

Note: In the formula, n represents the total number of observations. In this example, there were 10 total observations.

Step 4: Calculate b1

  • b1 =  (n(Σxy) – (Σx)(Σy))  /  (n(Σx2) – (Σx)2)
  • b1 = (10(1258) – (85)(128))  /  (10(831) – (85)2)
  • b1 = 1.5668

Step 5: Write Linear Regression Equation

The final linear regression equation can be written as:

  • ŷ = b0 + b1x

Thus, our linear regression equation would be written as:

  • ŷ = -0.518 + 1.5668x

We can double check that this answer is correct by plugging in the values from the table into the :

We can see that the linear regression equation from the calculator matches the one that we calculated by hand.

The following tutorials provide additional information about linear regression:

x