Chapter-4-Simple Linear Regression & Correlation
Chapter-4-Simple Linear Regression & Correlation
correlation
CHAPTER 9
9. SIMPLE LINEAR REGRESSION AND CORRELATION
Linear regression and correlation is studying and measuring the linear relation ship
among two or more variables. When only two variables are involved, the analysis is
referred to as simple correlation and simple linear regression analysis, and when there are
more than two variables the term multiple regression and partial correlation is used.
Correlation Analysis: deals with the measurement of the closeness of the relation ship
which are described in the regression equation.
We say there is correlation if the two series of items vary together directly or inversely.
The presence of correlation between two variables may be due to three reasons:
1. One variable being the cause of the other. The cause is called “subject” or
“independent” variable, while the effect is called “dependent” variable.
Page 1
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
2. Both variables being the result of a common cause. That is, the correlation
that exists between two variables is due to their being related to some third
force.
Example:
Let X1= ESLCE result
Y1= rate of surviving in the University
Y2= the rate of getting a scholar ship.
Both X1&Y1 and X1&Y2 have high positive correlation, likewiseY1 & Y2 have
positive correlation but they are not directly related, but they are related to each
other via X1.
Examples:
Price of teff in Addis Ababa and grade of students in USA.
Weight of individuals in Ethiopia and income of individuals in Kenya.
r
( X i X )(Yi Y ) and the short cut formula is
( X i X ) 2 (Yi Y ) 2
n XY ( X )( Y )
r
[n X 2 ( X ) 2 ] [n Y 2 ( Y ) 2
r
XY nXY
[ X 2 nX 2 ] [ Y 2 nY 2 ]
Remark: Always this r lies between -1 and 1 inclusively and it is also symmetric.
Interpretation of r
1. Perfect positive linear relationship ( if r 1)
2. Some Positive linear relationship ( if r is between 0 and
1)
3. No linear relationship ( if r 0)
4. Some Negative linear relationship ( if r is between -1 and
0)
5. Perfect negative linear relationship ( if r 1)
Examples:
Page 2
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
1. Calculate the simple correlation between mid semester and final exam scores of 10
students (both out of 50)
r
XY nXY
[ X nX 2 ] [ Y 2 nY 2 ]
2
10331 10(31.2)(32.9)
(9920 10(973.4)) (11003 10(1082.4))
66.2
0.363
182.5
This means mid semester exam and final exam scores have a slightly positive correlation.
Exercise The following data were collected from a certain household on the monthly
income (X) and consumption (Y) for the past 10 months. Compute the simple correlation
coefficient.
X: 650 654 720 456 536 853 735 650 536 666
Y: 450 523 235 398 500 632 500 635 450 360
The above formula and procedure is only applicable on quantitative data, but when
we have qualitative data like efficiency, honesty, intelligence, etc we calculate what is
called Spearman’s rank correlation coefficient as follows:
Steps
i. Rank the different items in X and Y.
ii. Find the difference of the ranks in a pair , denote them by Di
iii. Use the following formula
Page 3
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
2
6 Di
rs 1
n(n 2 1)
Where rs coefficient of rank correlatio n
D the difference between paired ranks
n the number of pairs
Example:
Aster and Almaz were asked to rank 7 different types of lipsticks, see if there is
correlation between the tests of the ladies.
Lipstick types A B C D E F G
Aster 2 1 4 3 5 7 6
Almaz 1 3 2 4 5 6 7
Solution:
X Y R1-R2 D2 6 Di
2
6(12)
(R1) (R2) (D) rs 1 2
1 0.786
n(n 1) 7(48)
2 1 1 1
1 3 -2 4
4 2 2 4 Yes, there is positive correlation.
3 4 -1 1
5 5 0 0
7 6 1 1
6 7 -1 1
Total 12 Simple Linear Regression
- Simple linear regression refers to the linear
relation ship between two variables
- We usually denote the dependent variable by Y and the independent variable by X.
- A simple regression line is the line fitted to the points plotted in the scatter diagram,
which would describe the average relation ship between the two variables. Therefore,
to see the type of relation ship, it is advisable to prepare scatter plot before fitting the
model.
Y X
Where :Y Dependent var iable
X independent var iable
Re gression cons tan t
- The linear model is: regression slope
random disturbance term
Y ~ N ( X , 2 )
~ N (0, 2 )
Page 4
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
Where a is a constant which gives the value of Y when X=0 .It is called the Y-
intercept. b is a constant indicating the slope of the regression line, and it gives a
measure of the change in Y for a unit change in X. It is also regression coefficient of Y
on X.
- a and b are found by minimizing SSE 2 (Yi Yˆi ) 2
Where : Yi observed value
Yˆi estimated value a bX i
b
( X i X )(Yi Y ) XY nXY
( X i X )2 X 2 nX 2
a Y bX
Example 1: The following data shows the score of 12 students for Accounting and Statistics
examinations.
Accounting Statistics
X2 Y2 XY
X Y
1 74.00 81.00 5476.00 6561.00 5994.00
2 93.00 86.00 8649.00 7396.00 7998.00
3 55.00 67.00 3025.00 4489.00 3685.00
4 41.00 35.00 1681.00 1225.00 1435.00
Page 5
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
The Coefficient of Correlation (r) has a value of 0.92. This indicates that the two
variables are positively correlated (Y increases as X increases).
b)
where:
Yˆ 7.0194 0.9560 X is the estimated regression line.
c) Insert X=85 in the estimated regression line.
Yˆ 7.0194 0.9560 X
7.0194 0.9560(85) 88.28
Page 6
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
Exercise: A car rental agency is interested in studying the relationship between the
distance driven in kilometer (Y) and the maintenance cost for their cars (X in birr). The
following summarized information is given based on samples of size 5.
2
i 1Yi
5
314
5 2
i 1 X i 147,000,000
i 1 X i 23,000 , i 1Yi 36 ,
5 5 5
i 1 X i Yi 212, 000
a) Find the least squares regression equation of Y on X
b) Compute the correlation coefficient and interpret it.
c) Estimate the maintenance cost of a car which has been driven for 6 km
- To know how far the regression equation has been able to explain the variation in Y we
use a measure called coefficient of determination ( r 2 )
i.e r2
(Yˆ Y ) 2
(Y Y ) 2
Where r the simple correlatio n coefficient.
SX Y
( X i X )(Yi Y ) XY nXY
n 1 n 1
bS X rS
ii. r b Y
SY SX
Page 7
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
Xˆ a1 b1Y
b1
XY nXY
Y nY
2 2
b1SY
a1 X b1Y , r
SX
Example: The regression line between height (X) in inches and weight (Y) in lbs of
male students are:
4Y 15 X 530 0 and
20 X 3Y 975 0
Determine which is regression of Y on X and X on Y
Page 8
Lecture notes on Introduction to Statistics IX: simple linear regression and
correlation
Solution
We will assume one of the equation as regression of X on Y and the other as Y on X
and calculate r
15 3 9
r 2 bYX * bXY 0,1
4 20 16
Page 9