Skip to content
Related Articles
Open in App
Not now

Related Articles

Linear Regression Formula

Improve Article
Save Article
  • Last Updated : 24 May, 2022
Improve Article
Save Article

Linear regression is defined as a data technique that determines the relationship between two variables by applying a linear equation to the given data. Here, one variable is supposed to be independent, while the other is supposed to be dependent. It is used with the help of a linear regression equation, which is similar to the slope-intercept form. To measure the strength of the relationship between two variables, we use a correlation coefficient which has a value range of -1 to +1. The slope of the regression line is calculated by putting the independent variable equal to zero in the equation and then solving for the dependent variable.

Linear regression formula

y = a + bx

Where,

  • y is the dependent variable that lies along the y-axis,
  • a is the y-intercept,
  • b is the slope of regression line,
  • x is the independent variable that lies along the x-axis,

The intercept value, a, and slope of the line, b, are evaluated using the formulas given below:

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\ \begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

Where,

  • x denotes the values of independent data set,
  • y denotes the values of dependent data set.

Sample Problems

Problem 1: Find the linear regression equation for the given data:

x

y

3

8

9

6

5

4

3

2

Solution:

Calculate the intercept and slope value.

x

y

x2

xy

3

9

9

27

5

3

25

15

8

6

64

48

4

2

16

8

∑x = 20

∑y = 20

∑x2 = 114

∑xy = 98

Using the formula we get,

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\

= (20 (114) – 20 (98)) / (4 (114) – 400)

= 320/56

= 5.71

\begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

= (4 (98) – 20 (20)) / (4 (114) – 400)

= -8/56

= -0.14

So, the linear regression equation is, 5.71 – 0.14 x.

Problem 2: Find the linear regression equation for the given data:

x

y

4

6

7

5

3

8

1

3

Solution:

Calculate the intercept and slope value.

x

y

x2

xy

4

6

16

24

7

5

49

35

3

8

9

24

1

3

1

3

∑x = 15

∑y = 22

∑x2 = 75

∑xy = 134

Using the formula we get,

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\

= (15 (75) – 15 (134)) / (4 (75) – 225)

= -885/75

= -11.8

\begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

= (4 (134) – 15 (22)) / (4 (75) – 225)

= -206/75

= -0.14

So, the linear regression equation is, -11.8 – 2.74 x.

Problem 3: Find the intercept of linear regression line if ∑x = 25, ∑y = 20, ∑x2 = 90, ∑xy = 150 and n = 5.

Solution:

Using the formula we get,

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\

= (20 (90) – 25 (150)) / (5 (90) – 625)

= -1950/-175

= 11.14

Problem 4: Find the intercept of linear regression line if ∑x = 30, ∑y = 27, ∑x2 = 110, ∑xy = 190 and n = 4.

Solution:

Using the formula we get,

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\

= (27 (110) – 25 (190)) / (5 (110) – 900)

= -1780/-350

= 5.08

Problem 5: Find the slope of linear regression line if ∑x = 10, ∑y = 16, ∑x2 = 60, ∑xy = 120 and n = 4.

Solution:

Using the formula we get,

\begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

= (4 (120) – 10 (16)) / (4 (60) – 100)

= 320/140

= 2.28

Problem 6: Find the slope of linear regression line if ∑x = 40, ∑y = 32, ∑x2 = 130, ∑xy = 210 and n = 4.

Solution:

Using the formula we get,

\begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

= (4 (210) – 40 (32)) / (4 (130) – 1600)

= -440/-1080

= 0.404

Problem 7. Find the slope of linear regression line if ∑x = 50, ∑y = 44, ∑x2 = 150, ∑xy = 230 and n = 4.

Solution:

Using the formula we get,

\begin{array}{l}\large a=\frac{\sum y \sum x^{2} - \sum x \sum xy} {n(\sum x^{2}) - (\sum x)^{2}}\end{array}\\

= (44 (150) – 50 (230)) / (4 (150) – 2500)

= -4900/-1900

= 2.57

\begin{array}{l}\large b=\frac{n\sum xy-\left(\sum x\right)\left(\sum y\right)}{n\sum x^{2}-\left(\sum x\right)^{2}}\end{array}

= (4 (230) – 50 (44)) / (4 (150) – 2500)

= -1280/-1900

= 0.67


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!