linear regression line of best fit. gradient = intercept =
DESCRIPTION
Consider the following graphTRANSCRIPT
![Page 1: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/1.jpg)
Linear Regression
Line of Best Fit
![Page 2: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/2.jpg)
22 )( xxnyxxyn
a
22
2
)( xxnxyxxy
b
Gradient =
Intercept =
![Page 3: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/3.jpg)
Consider the following graph
![Page 4: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/4.jpg)
![Page 5: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/5.jpg)
![Page 6: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/6.jpg)
d1
d2d3
d4
d6
d5
d8d7
![Page 7: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/7.jpg)
We want a Line where d1 - d7 has the minimum distance
d1
d2d3
d4
d6
d5
d8d7
![Page 8: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/8.jpg)
Just adding will not do it
A better method is to square the error
S = d21 + d2
2 + d23 + d2
5+ d24 + d2
6
We now need to find when ‘S’ is a ‘minimum’
![Page 9: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/9.jpg)
S = d2i
= y – (ax + b)2
= y – ax - b2
![Page 10: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/10.jpg)
= y – ax - b2
S
Ignoring the summation sign
=dsda
2(y – ax – b) . (-x)
=dsdb
2(y – ax – b) . (-1)
![Page 11: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/11.jpg)
We need to find when these are = zero
=dsda
2(y – ax – b) . (-x)
0 = (y – ax – b) . (-x)
0 = (-yx + ax2 + bx) .
![Page 12: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/12.jpg)
We need to find when these are = zero
=dsdb
2(y – ax – b) . (-1)
0 = (y – ax – b) . (-1)
0 = (- y + ax + b) .
![Page 13: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/13.jpg)
This this gives us two equations
0 = (- y + ax + b)
0 = (-yx + ax2 + bx)
Rearranging gives
y = + ax + b
yx = + ax2 + bx
This is a set of simultaneous equations and can be solved for ‘a’ and ‘b’
![Page 14: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/14.jpg)
Put back the Summation signs
y = ax + b
yx = ax2 + bx
This can be rearranged
yx = a. x2 + b.x
y = a. x + bn
Now solve for ‘a’ and ‘b’
![Page 15: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/15.jpg)
22 )( xxnyxxyn
a
22
2
)( xxnxyxxy
b
Gradient =
Intercept =
![Page 16: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/16.jpg)
Easy
Try an Example
![Page 17: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/17.jpg)
n x y
Freq Inductive reactance
1 50 30
2 100 65
3 150 90
4 200 130
5 250 150
6 300 190
7 350 200 0
50
100
150
200
250
0 100 200 300 400
FrequencyIn
duct
ive
Rea
ctan
ce
Plot your data
Consider the following data
Not very straight
![Page 18: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/18.jpg)
Make two new columns
Use Method of Least Squares
xy x2
1500 2500
6500 10000
13500 22500
26000 40000
37500 62500
57000 90000
70000 122500
n x y
Freq Inductive reactance
1 50 30
2 100 65
3 150 90
4 200 130
5 250 150
6 300 190
7 350 200
1400 855 212000 350000
22 )( xxnyxxyn
a
22
2
)( xxnxyxxy
b
Now for y = a.x + b
where
![Page 19: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/19.jpg)
Use Method of Least Squares
xy x2
1500 2500
6500 10000
13500 22500
26000 40000
37500 62500
57000 90000
70000 122500
n x y
Freq Inductive reactance
1 50 30
2 100 65
3 150 90
4 200 130
5 250 150
6 300 190
7 350 200
1400 855 212000 350000
22 )( xxnyxxyn
a
Find ‘ a ‘
a = 7 x 212000 - 1400 x 855
7 x 350000
- (1400)2
a = 0.5857
![Page 20: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/20.jpg)
Use Method of Least Squares
xy x2
1500 2500
6500 10000
13500 22500
26000 40000
37500 62500
57000 90000
70000 122500
n x y
Freq Inductive reactance
1 50 30
2 100 65
3 150 90
4 200 130
5 250 150
6 300 190
7 350 200
1400 855 212000 350000
Find ‘ b ‘
b = 855 x 350000 - 1400 x 212000
7 x 350000
- (1400)2
b = 5
22
2
)( xxnxyxxy
b
![Page 21: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/21.jpg)
Use Method of Least Squares
xy x2
1500 2500
6500 10000
13500 22500
26000 40000
37500 62500
57000 90000
70000 122500
n x y
Freq Inductive reactance
1 50 30
2 100 65
3 150 90
4 200 130
5 250 150
6 300 190
7 350 200
1400 855 212000 350000
Line of best fit
50 34.29
100 63.57
150 92.86
200 122.14
250 151.43
300 180.71
350 210.00
Make two more columns
y = a.x + b
New values for ‘y’ are found from
Plot this new data on the original graph
![Page 22: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/22.jpg)
0
50
100
150
200
250
0 50 100 150 200 250 300 350 400
![Page 23: Linear Regression Line of Best Fit. Gradient = Intercept =](https://reader035.vdocuments.net/reader035/viewer/2022062317/5a4d1b747f8b9ab0599b6a57/html5/thumbnails/23.jpg)
Easy