Correlation and Regression 2 1
Correlation and Regression 2 1
(GSU 07204)
1 CORRELATION
2 REGRESSION
CORRELATION
What is Correlation
correlation Coefficient
Types of Correlation
Types of Correlation
Types of Correlation
S/No x y xy x2 y2
1 14.2 215 3,053.0 201.64 46,225
2 16.4 325 5,330.0 268.96 105,625
3 11.9 185 2,201.5 141.61 34,225
4 15.2 332 5,046.4 231.04 110,224
5 18.5 406 7,511.0 342.25 164,836
6 22.1 522 11,536.2 488.41 272,484
7 19.4 412 7,992.8 376.36 169,744
8 25.1 614 15,411.4 630.01 376,996
9 23.4 544 12,729.6 547.56 295,936
10 18.1 421 7,620.1 327.61 177,241
11 22.6 445 10,057.0 510.76 198,025
12 17.2 408 7,017.6 295.84 166,464
Total 224.1 4,829 95,506.6 4,362.05 2,118,025
MR. MOHAMED K. MWANGA ([email protected]) IAA April 18, 2023 11 / 30
CORRELATION
From P P P
xy − x y n
r=q P
[n x2 − ( x)2 ][n y 2 − ( y)2 ]
P P P
n = 12
(12 × 95, 506.6) − (224.1 × 4, 829)
r=q
[(12 × 4, 362.05) − (224.1)2 ][(12 × 2, 118, 025) − (4, 829)2 ]
r = 0.958
This means there is a strong positive correlation between
temperature and icecream sales. Increase in temperature
lead to increase icecream sales.
Quiz
Quiz
It is given as
6 di 2
P
rs = 1 −
n(n2 − 1)
n =number of data points of the two variables
di = difference in ranks of the “ith” element
Examples
The following are the marks of students for the two subjects
(History and Geography). Obtain a spearman correlation
coefficient.
History Geography
35 30
23 33
47 45
17 23
10 8
43 49
9 12
6 4
28 31
Examples
from
6 di 2
P
rs = 1 −
n(n2 − 1)
History Rx Geography Ry di = Rx − Ry di 2
35 3 30 5 2 4
23 5 33 3 2 4
47 1 45 2 1 1
17 6 23 6 0 0
10 7 8 8 1 1
43 2 49 1 1 1
9 8 12 7 1 1
6 9 4 9 0 0
28 4 31 4 0 0
Total 12
MR. MOHAMED K. MWANGA ([email protected]) IAA April 18, 2023 17 / 30
CORRELATION
Examples
So,
6 × 12
rs = 1 −
9(92 − 1)
6 × 12
rs = 1 −
9 × 80
rs = 1 − 0.1
rs = 0.9
There is a strong positive correlation between the
marks of two subjects.
MR. MOHAMED K. MWANGA ([email protected]) IAA April 18, 2023 18 / 30
CORRELATION
Question
REGRESSION
What is Regression
It is written as
y = ax + b
MR. MOHAMED K. MWANGA ([email protected]) IAA April 18, 2023 21 / 30
REGRESSION
It is written as
y = ax + b
Where P P P
n (xy) − x y
a= P P
n (x2 ) − ( x)2
And P P
y−a x
b=
n
Example
Example
Example
S/No x y xy x2
1 6 1 6 36
2 6.1 6 36.6 37.21
3 6.2 8 49.6 38.44
4 6.3 10 63 39.69
5 6.5 11 71.5 42.25
6 7.1 20 142 50.41
7 7.6 21 159.6 57.76
8 7.8 22 171.6 60.84
9 8 23 184 64
10 8.1 25 202.5 65.61
Total 69.7 147 1,086.4 492.21
Example
Where P P P
n (xy) − x y
a= P P
n (x2 ) − ( x)2
So P P
y−a x
b=
P P n P
Then
P 2 xy = 1086.4, x = 69.7, y = 147,
x = 492.21, n = 10
Example
Where
(10 × 1086.4) − (69.7 × 147)
a= = 9.656
(10 × 492.21) − (69.7)2
So
147 − 9.656 × 69.7
b= = −52.6
10
So Regression line become
y = 9.656x − 52.6
QUIZ
QUIZ
Thank you!