“ Equation of Linear Regression Line”
Presented by : Eng. Waleed Alzaghal
YouTube Channel: Waleed Alzaghal
Equation of a Straight Line
y = mx + b
y : the y-value for a given x-value
m : the slope of the line
b : the y-intercept
Equation of a Straight Line
Equation of a Straight Line
Equation of a Straight Line
The Equation of a Regression Line
ŷ = mx + b
ŷ : the predicted y-value for a given x-value
m : the slope of the line
b : the y-intercept
Obs. x i y j
1 x 1 y 1
2 x 2 y 2
3 x 3 y 3
… … …
… … …
… … …
… … …
… … …
n x n y n
Sum
ŷ = mx + b
m =
𝑛 𝑥𝑦 −( 𝑥)( 𝑦)
𝑛 𝑥2
−( 𝑥)2
𝑦 = m𝑥 + b
b = 𝑦 - m𝑥 where:
𝑥 : the mean of the x values.
𝑦 : the mean of the y values.
b =
𝑦
𝑛
- 𝑚
𝑥
𝑛
b =
𝑦 −𝑚 𝑥
𝑛
Obs. x i y j
1 x 1 y 1
2 x 2 y 2
3 x 3 y 3
… … …
… … …
… … …
… … …
… … …
n x n y n
Sum
For the following data:
1- Display the Scatter Plot.
2- Compute the Pearson’s Correlation Coefficient.
3- Find the Equation of the Regression Line.
4- Draw the Regression Line.
5- Predict the value of ŷ for x=14 and x=8
6- Compute the Error of Prediction for x=10
Obs. x y
1 1 1
2 2 3
3 3 2
4 3 3
5 5 3
6 5 5
7 7 4
8 7 7
9 9 7
10 10 5
11 11 7
12 11 8
13 13 8
14 13 9
Obs. x y
1 1 1
2 2 3
3 3 2
4 3 3
5 5 3
6 5 5
7 7 4
8 7 7
9 9 7
10 10 5
11 11 7
12 11 8
13 13 8
14 13 9
1- Display the scatter plot.
Obs. x y x 2
y 2
xy
1 1 1 1 1 1
2 2 3 4 9 6
3 3 2 9 4 6
4 3 3 9 9 9
5 5 3 25 9 15
6 5 5 25 25 25
7 7 4 49 16 28
8 7 7 49 49 49
9 9 7 81 49 63
10 10 5 100 25 50
11 11 7 121 49 77
12 11 8 121 64 88
13 13 8 169 64 104
14 13 9 169 81 117
Sum 100 72 932 454 638
𝑟 =
𝑛 𝑥𝑦 − ( 𝑥)( 𝑦)
(𝑛 𝑥2 − ( 𝑥)2). (𝑛 𝑦2 − ( 𝑦)2
𝑟 =
14 638 − (100)(72)
( 14 932 − 100 2)( 14 454 − 72 2)
𝑟 =
1732
(3048)(1172)
𝑟 =
1732
1890.04
r ≈ 0.92
(Interpretation: Strong Positive Correlation)
2- Compute the Pearson’s correlation coefficient.
ŷ = mx + b
m =
𝑛 𝑥𝑦 −( 𝑥)( 𝑦)
𝑛 𝑥2
−( 𝑥)2
m =
14 638 −(100)(72)
14 932 − 100 2
m =
1732
3048
m ≈ 0.57
3- Find the equation of the regression line.
Obs. x y x 2
y 2
xy
1 1 1 1 1 1
2 2 3 4 9 6
3 3 2 9 4 6
4 3 3 9 9 9
5 5 3 25 9 15
6 5 5 25 25 25
7 7 4 49 16 28
8 7 7 49 49 49
9 9 7 81 49 63
10 10 5 100 25 50
11 11 7 121 49 77
12 11 8 121 64 88
13 13 8 169 64 104
14 13 9 169 81 117
Sum 100 72 932 454 638
ŷ = mx + b
b =
𝑦 −𝑚 𝑥
𝑛
b =
(72) −(0.57)(100)
14
b =
15
14
b = 1.07
ŷ = 0.57 x + 1.07
Obs. x y x 2
y 2
xy
1 1 1 1 1 1
2 2 3 4 9 6
3 3 2 9 4 6
4 3 3 9 9 9
5 5 3 25 9 15
6 5 5 25 25 25
7 7 4 49 16 28
8 7 7 49 49 49
9 9 7 81 49 63
10 10 5 100 25 50
11 11 7 121 49 77
12 11 8 121 64 88
13 13 8 169 64 104
14 13 9 169 81 117
Sum 100 72 932 454 638
3- Find the equation of the regression line.
4- Draw the regression line.
5- Predict the value of ŷ for x=14 and x=8
For x=14 (Extrapolation)
ŷ = 0.57 x + 1.07
ŷ = (0.57)(14) + 1.07
ŷ = 9.05
For x=8 (Interpolation)
ŷ = 0.57 x + 1.07
ŷ = (0.57)(8) + 1.07
ŷ = 5.63
Predicted Value ŷ
ŷ = 0.57 x + 1.07
For x=10
ŷ = (0.57)(10) + 1.07 = 6.77
Actual Value = 5
Error of Prediction = Predicted Value – Actual Value
Error of Prediction = 6.77 – 5 = 1.77
6- Compute the Error of Prediction for x=10

Equation of linear regression straight line

  • 1.
    “ Equation ofLinear Regression Line” Presented by : Eng. Waleed Alzaghal YouTube Channel: Waleed Alzaghal
  • 2.
    Equation of aStraight Line y = mx + b y : the y-value for a given x-value m : the slope of the line b : the y-intercept
  • 3.
    Equation of aStraight Line
  • 4.
    Equation of aStraight Line
  • 5.
    Equation of aStraight Line
  • 6.
    The Equation ofa Regression Line ŷ = mx + b ŷ : the predicted y-value for a given x-value m : the slope of the line b : the y-intercept Obs. x i y j 1 x 1 y 1 2 x 2 y 2 3 x 3 y 3 … … … … … … … … … … … … … … … n x n y n Sum
  • 7.
    ŷ = mx+ b m = 𝑛 𝑥𝑦 −( 𝑥)( 𝑦) 𝑛 𝑥2 −( 𝑥)2 𝑦 = m𝑥 + b b = 𝑦 - m𝑥 where: 𝑥 : the mean of the x values. 𝑦 : the mean of the y values. b = 𝑦 𝑛 - 𝑚 𝑥 𝑛 b = 𝑦 −𝑚 𝑥 𝑛 Obs. x i y j 1 x 1 y 1 2 x 2 y 2 3 x 3 y 3 … … … … … … … … … … … … … … … n x n y n Sum
  • 8.
    For the followingdata: 1- Display the Scatter Plot. 2- Compute the Pearson’s Correlation Coefficient. 3- Find the Equation of the Regression Line. 4- Draw the Regression Line. 5- Predict the value of ŷ for x=14 and x=8 6- Compute the Error of Prediction for x=10 Obs. x y 1 1 1 2 2 3 3 3 2 4 3 3 5 5 3 6 5 5 7 7 4 8 7 7 9 9 7 10 10 5 11 11 7 12 11 8 13 13 8 14 13 9
  • 9.
    Obs. x y 11 1 2 2 3 3 3 2 4 3 3 5 5 3 6 5 5 7 7 4 8 7 7 9 9 7 10 10 5 11 11 7 12 11 8 13 13 8 14 13 9 1- Display the scatter plot.
  • 10.
    Obs. x yx 2 y 2 xy 1 1 1 1 1 1 2 2 3 4 9 6 3 3 2 9 4 6 4 3 3 9 9 9 5 5 3 25 9 15 6 5 5 25 25 25 7 7 4 49 16 28 8 7 7 49 49 49 9 9 7 81 49 63 10 10 5 100 25 50 11 11 7 121 49 77 12 11 8 121 64 88 13 13 8 169 64 104 14 13 9 169 81 117 Sum 100 72 932 454 638 𝑟 = 𝑛 𝑥𝑦 − ( 𝑥)( 𝑦) (𝑛 𝑥2 − ( 𝑥)2). (𝑛 𝑦2 − ( 𝑦)2 𝑟 = 14 638 − (100)(72) ( 14 932 − 100 2)( 14 454 − 72 2) 𝑟 = 1732 (3048)(1172) 𝑟 = 1732 1890.04 r ≈ 0.92 (Interpretation: Strong Positive Correlation) 2- Compute the Pearson’s correlation coefficient.
  • 11.
    ŷ = mx+ b m = 𝑛 𝑥𝑦 −( 𝑥)( 𝑦) 𝑛 𝑥2 −( 𝑥)2 m = 14 638 −(100)(72) 14 932 − 100 2 m = 1732 3048 m ≈ 0.57 3- Find the equation of the regression line. Obs. x y x 2 y 2 xy 1 1 1 1 1 1 2 2 3 4 9 6 3 3 2 9 4 6 4 3 3 9 9 9 5 5 3 25 9 15 6 5 5 25 25 25 7 7 4 49 16 28 8 7 7 49 49 49 9 9 7 81 49 63 10 10 5 100 25 50 11 11 7 121 49 77 12 11 8 121 64 88 13 13 8 169 64 104 14 13 9 169 81 117 Sum 100 72 932 454 638
  • 12.
    ŷ = mx+ b b = 𝑦 −𝑚 𝑥 𝑛 b = (72) −(0.57)(100) 14 b = 15 14 b = 1.07 ŷ = 0.57 x + 1.07 Obs. x y x 2 y 2 xy 1 1 1 1 1 1 2 2 3 4 9 6 3 3 2 9 4 6 4 3 3 9 9 9 5 5 3 25 9 15 6 5 5 25 25 25 7 7 4 49 16 28 8 7 7 49 49 49 9 9 7 81 49 63 10 10 5 100 25 50 11 11 7 121 49 77 12 11 8 121 64 88 13 13 8 169 64 104 14 13 9 169 81 117 Sum 100 72 932 454 638 3- Find the equation of the regression line.
  • 13.
    4- Draw theregression line.
  • 14.
    5- Predict thevalue of ŷ for x=14 and x=8 For x=14 (Extrapolation) ŷ = 0.57 x + 1.07 ŷ = (0.57)(14) + 1.07 ŷ = 9.05 For x=8 (Interpolation) ŷ = 0.57 x + 1.07 ŷ = (0.57)(8) + 1.07 ŷ = 5.63
  • 15.
    Predicted Value ŷ ŷ= 0.57 x + 1.07 For x=10 ŷ = (0.57)(10) + 1.07 = 6.77 Actual Value = 5 Error of Prediction = Predicted Value – Actual Value Error of Prediction = 6.77 – 5 = 1.77 6- Compute the Error of Prediction for x=10