Unit-V
Unit-V
5.1 Regression
In the regression analysis we study aspects of statistical relationship between two or more
random variables. For example, in a computer system the throughput ‘Y’ and the degree of
multiprogramming ‘X’ might will be related to each other. One indicator of the association
between two random variables is their correlation coefficient 𝜌 (X, Y) that we will study in
section 5.2.
A related problem is that of predicting a value of system throughput ‘y’ at a given degree
of multiprogramming ‘x’. The problem then is to find a regression line or a regression curve
that describe the dependence of ‘Y’ on ‘X’. Also, we may study the inverse regression
problem of dependence of ‘X’ on ‘Y’,
Regression Lines:
The regression line can be best appreciated with the help of the following example:
X: height of 65 63 67 64 68 62 70 66 68 67
father(inches)
Y: height of 68 66 68 65 69 66 68 65 71 67
son(inches)
The two-regression lines corresponding to these variables are:
X = -3.38 + 1.036 Y
Y = 35.82 + 2.476 X
For example, if Y = 65, X would be -3.38 + 1.036 * 65 = 63.96
Y = 70, X would be -3.38 + 1.036 * 70 = 69.14
Now an important question is coming to my mind i.e., how to obtain these two lines from
the given data.
It is important to note that the regression lines are drawn on least sequences assumption
which stipulates that of the sum of squares of the deviations of the observed ‘Y’ values
from the fitted line shall be minimum.
The total of the squares of the deviations of the various point is minimum only from the
line of best fit. The deviation from the point from the line of best fit can be measured in
two ways – vertical i.e., parallel to Y-axis, and horizontal i.e. parallel to X-axis.
The regression line of Y on X is drawn in such a way that it minimizes total of squares of
the vertical deviations.
To be more specific if our points are {(𝑥 , 𝑦 )|𝑖 = (1)𝑛} then we choose ‘a’ and ‘b’ so as to
minimize.
𝐸= y − (𝑎 + 𝑏𝑥 )
= (y − 𝑎 − 𝑏𝑥 )
Taking partial derivatives w.r.t. ‘a’ and ‘b’ and setting them equal to ‘0’ we obtain
= 2∑ (𝑦 − 𝑎 − 𝑏𝑥 )(−1) = 0 (1)
= 2∑ (𝑦 − 𝑎 − 𝑏𝑥 )(−𝑥 ) = 0 (2)
2 (𝑦 − 𝑎 − 𝑏𝑥 )(−1) = 0
=> 𝑦 − 𝑎− 𝑏𝑥 = 0
=> 𝑦 − 𝑛𝑎 − 𝑏 𝑥
=> ∑ 𝑦 −𝑎− ∑ 𝑥 =0
1 1
=> 𝑦 =𝑎+𝑏 𝑥
𝑛 𝑛
Where 𝑦 = ∑ 𝑦 , 𝑥̅ = ∑ 𝑥
2 (𝑦 − 𝑎 − 𝑏𝑥 )(−𝑥 ) = 0
=> − 𝑥 𝑦 +𝑎 𝑥 +𝑏 𝑥 =0
=> 𝑥𝑦 =𝑎 𝑥 +𝑏 𝑥 =0
From equations (3) and (4), we get the value of ‘a’ and ‘b’ as follows.
𝑎 = 𝑦 − 𝑏𝑥̅ (5)
Now substitute the value of ‘a’ in equation (4), We get
1 1
𝑥 𝑦 = (𝑦 − 𝑏𝑥̅ ) + 𝑏. 𝑥
𝑛 𝑛
1
=> 𝑥 𝑦 = 𝑥̅ 𝑦 − 𝑏𝑥̅ + 𝑏 𝑥
𝑛
∑ 𝑥 𝑦 − 𝑛𝑥̅ 𝑦
=> 𝑏 =
∑ 𝑥 − 𝑛𝑥̅
This value of ‘b’ can be substituted in equation (5), we get,
∑ 𝑥 𝑦 − 𝑛𝑥̅ 𝑦
𝑎=𝑦− . 𝑥̅
∑ 𝑥 − 𝑛𝑥̅
Now using the value of ‘a’ and ‘b’, We can get the line of regression of x and y.
Example:
1. From the following data obtain the regression equa on of y on x.
x 6 2 10 4 8
y 9 11 5 8 7
𝑋=6
𝑌=8
∗ ∗
b= = = = -0.65
∗
a = 8—(−0.65)6 = 11.9
Hence, y = 11.9 + ( -0.65) X
Y = 11.9 – 0.65X
The above method of finding out regression equation is tedious. The equation is very much
be simplified if instead of dealing with actual values of x and y we take deviations of x and
y series from respective means. In such a case the two regression equations are written as
follows:
Regression Equa on of x on y:
𝑥 − 𝑥̅ = 𝜌 (𝑦 − 𝑦),
𝑤ℎ𝑒𝑟𝑒 𝑥̅ and 𝑦 are the means of x and y series, respec vely.
𝜌 is known as the regression coefficient of x on y.
The coefficient can also be denoted as ′𝑏𝑥𝑦′.
𝜎𝑥 𝑐𝑜𝑣(𝑥, 𝑦) 𝜎𝑥 𝑐𝑜𝑣(𝑥, 𝑦)
𝑏𝑥𝑦 = 𝜌 = ∗ =
𝜎𝑦 𝜎𝑥. 𝜎𝑦 𝜎𝑦 𝜎𝑦
Similarly,
Regression Equa on of y on x:
𝜎𝑦
𝑦−𝑦 =𝜌 = (𝑥 − 𝑥̅ )
𝜎𝑥
=> 𝑦 − 𝑦 = 𝑏𝑦𝑥(𝑥 − 𝑥̅ )
( , )
Where 𝑏𝑥𝑦 = 𝜌. = is known as regression coefficient of y on x.
Note: 𝑏𝑦𝑥 ∗ 𝑏𝑥𝑦 = 𝜌 ∗ ∗ 𝜌 =𝑦
Exercise:
1. The following table shows the ages (x) and blood pressure (y)of 8 persons:
X 52 63 45 36 72 65 47 25
Y 62 53 51 25 79 43 60 33
Obtain the equation of Y and X and find the expected blood pressure of a person who
is 49 years old.
2. In a correla on study the following values are obtained:
X Y
Mean 65 67
Standard deviation (σ) of coefficient of Correlation 2.5 3.5
Find the two regression equations that are associated with the above values.
X Y
Arithmetic mean 36 85
Standard deviations 11 8
Correction coefficient between x and y =0.66
(i) Find the two regression equation.
(ii) Estimate the value of x when y=75.
4. Write a program in any computer programming language to es mate the value of
unknown variable based on thevalue of other known variable.
More on Regression:
Regression problem is defined as that of predefined continuous value rather than a nominal
or discrete value.
In linear regression data are modelled using a straight line. Linear regression is the simplest
form of regression. The linear regression models a random variable, Y (called a response
variable) as a linear function of another random variables, X (called a predicator variable)
that is
Y = 𝛼 + 𝛽𝑋
Where 𝛼 𝑎𝑛𝑑 𝛽 are regression coefficients specifying the Y-intercept and slope of the line,
respectively. These coefficients can be obtained by the method of t least squares which
minimizes the error between the actual data and the estimate of the line.
Given n samples or data points of the form (x1,y1), (y1,y2)…….(xn,yn) then the regression
coefficients can be estimated as follows:
∑ 𝑦 = 𝑛𝛼 + 𝛽 ∑ 𝑥 (6)
⟹∑ 𝑥 𝑦 = 𝛼∑ 𝑥 +∑ 𝑥 (7)
From (6) on dividing by n, we get
𝑦 = 𝛼 + 𝛽𝑥̅ (8)
We know that
Cov(X,Y) = E[XY] = E[x].E[Y]
= ∑ 𝑥 𝑦 − 𝑥̅ 𝑦
⟹ ∑ 𝑥 𝑦 = 𝑐𝑜𝑣(𝑥, 𝑦) + 𝑥̅ 𝑦 (9)
Similarly,
𝜎 = 𝐸[𝑥 ] − (𝐸[𝑥]) (Variance)
⟹ 𝜎 = ∑ 𝑥 − ( ∑ 𝑥)
⟹ ∑ 𝑥 = 𝜎 + 𝑥̅ (10)
∑ ̅
𝛽=
∑ ̅
∑ ̅
𝛽 = ∑ ̅
∑ ( ̅ )( )
𝛽 = ∑ ̅)
(
Here the linear regression equation is
∑ ( ̅ )( )
Y = 𝑦 − 𝛽𝑥̅ + ∑ ̅)
.𝑋
(
Alternatively,
Minimize E = ∑ (𝑦 − (𝑎 + 𝑏𝑥 )) (𝐿𝑒𝑎𝑠𝑡 𝑠𝑞𝑢𝑎𝑟𝑒 𝑓𝑖𝑡)
Taking partial derivative of a and setting then equal to 0, we obtain
𝜕𝐸
= 0
𝜕𝑎
2∑ (𝑦 − (𝑎 + 𝑏𝑥 ))(−1) = 0
∑ 𝑦 = 𝑛𝑎 + 𝑏 ∑ 𝑥 (13)
𝜕𝐸
= 0
𝜕𝑎
2 ∑ (𝑦 − (𝑎 + 𝑏𝑥 ))(−𝑥 ) = 0
∑ 𝑥 𝑦 = 𝑎 ∑ 𝑥 + 𝑏. ∑ 𝑥 (14)
Hence, the line of best fit can be obtained by solving the following determinants
𝑌 𝑋 1
∑ 𝑦 ∑ 𝑥 𝑛
∑ 𝑥𝑦 ∑ 𝑥 ∑ 𝑥
𝑥 𝑛 𝑦 𝑛 𝑦 𝑥
⟹ 𝑌. − 𝑋 + =0
𝑥 𝑥 𝑥𝑦 𝑥 𝑥𝑦 𝑥
Multiple Regression:
Multiple regression is an extension of linear regression involving more than one predicator
variable. It allows response variable Y to be modelled as a linear function of a
multidimensional feature vector e.g.,
Y = 𝜶 + 𝜷𝑿𝟏 + 𝜸𝑿𝟐
Here is to minimize,
E = 𝐘 − (𝜶 + 𝜷𝑿𝟏 + 𝜸𝑿𝟐 )
Regression can act as a classifies
Classification
𝑌∁ = 𝛼∁ + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋
𝑌∁ = 𝛼∁ + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋
𝑌∁ = 𝛼∁ + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋 + 𝛽 ∁
.𝑋
Max { 𝑌∁ , 𝑌∁ , 𝑌∁ }
𝜕𝐸
= 0
𝜕𝛼
𝜕𝐸
= 0
𝜕𝛽
⇒ 2∑ 𝒚𝒊 − (𝜶 + 𝜷𝑿𝒊𝟏 + 𝜸𝑿𝒊𝟐 ) (−𝑥 ) = 0
=> 2 ∑ 𝑦 𝑥 = 𝛼. ∑ 𝑥 + 𝛽. ∑ 𝑥 + 𝛾. ∑ 𝑥 𝑥 (16)
𝜕𝐸
= 0
𝜕𝛾
𝑦 𝑥 𝑥 𝑛
=0
𝑦𝑥 𝑥 𝑥 𝑥 𝑥
𝑦𝑥 𝑥 𝑥 𝑥 𝑥
Non-Linear Regression:
Polynomial regression can be modelled by adding polynomial terms to the basic linear
model. By applying transformations to the variables, we can convert the non-linear model
into a linear once that can then be solved by the method of least squares.
Ex: -
Y=𝛼 + 𝛽 𝑋 + 𝛽 𝑋 + 𝛽 𝑋 (18)
After transformation:
Y=𝛼 + 𝛽 𝑋 + 𝛽 𝑋 + 𝛽 𝑋
i.e., let X1 = X
X2 = X2, X3 = X3
Now this can be solved by the method of least squares.
NOTE: Some models are intractably non-linear (such as the term of exponential terms for
example) and cannot be converted to a linear model.
Example: Y = aebx
Taking logarithm both side
Log10Y = log10a + bx log10 e
= > log10Y = log10a + bx
= > U = A + BX
Now this is a linear equation in X and U.
Thus the normal equivalence
∑ 𝑈 = 𝑛𝐴 + 𝐵 ∑ 𝑋 (19)
∑ 𝑋𝑈 = 𝐴 ∑ 𝑋 + 𝐵 ∑ 𝑋 (20)
𝑈 𝑋 1
∑𝑈 ∑𝑋 𝑛 = 0
∑ 𝑋𝑈 ∑𝑋 ∑𝑋
From these we find A and B and consequently
a = antilog(A)
b = B/loge
5.2 Correlation Analysis
Let us learn the theory of correlation analysis by putting a question "Uncover the hidden
relationship between income and expenditure of the employees of fakir Mohan
University."
Attempting to uncovering the hidden relationship between two variable like "income" and
"expenditure" or more variables is known as correlation analysis.
Over the years many definitions for correlation analysis have been defined by potential
statisticians/ mathematicians:
Some of the definitions of correlation is given below.
"Correla on Analysis deals with the associa on between two or more variables"
Correla on is an analysis of the covariance between two or more variables.
The problem of analyzing the relation between different series should be broken down
into three steps:
• Posi ve or Nega ve
• Simple , Par al and Mul ple
• Linear and Non-linear
If on the other hand, the variables are varying in opposite direc on i.e., one is
increasing and the other one is decreasing or vice-versa, then correla on is said to
be nega ve.
Simple Partial and Multiple Correlation:
The definition between simple, partial, and multiple correlation is based upon the
number of variables Studied.
If study is confined on two variables then it is said to be simple correla on.
If the study is undertaken on three or more variables then it is a problem of either
mul ple or par al correla on
In mul ple correla on three or more variables are studied simultaneously
Ex: Study the rela onship between the yield of rice per acre and both the amount
of rainfall and the amount of fer lizers used Jit is a problem of mul ple correla on.
On the other hand, in par al correla on we recognize more than two variables,
but consider only two variables to be influencing each other the effect of other
influencing variables being kept constant.
Linear and Non-Linear Correlation:
The distinction between linear and nonlinear Correlation is based upon the
constancy of the ratio of range between the variables. If the amount of change in
the other variable then the correlation is said to be linear.
On the other hand if the amount of change in one variable does not bear a
constant ratio to the amount of change in the other variable , then the correlation
is said to be non-linear or Curvilinear
Method of Studying Correlation:
The two very popular methods of ascertaining whether two variables are correlated
or not are:
Example:
Given the following pair of values of the variables X and
X: 2 3 5 6 8 9
Y : 6 5 7 8 12 11
• Plot a scatter diagram.
𝜎x = 𝑉𝑎𝑟[𝑥 ] = 𝐸 [𝑥 ] − (𝐸[𝑥])
𝜎 y= 𝑉𝑎𝑟[𝑦] = 𝐸 [𝑦 ] − (𝐸[𝑦])
It can be realised that
−1 ≤ 𝜌(𝑥, 𝑦) = 𝜌 ≤ 1
Also:
−1 𝑖𝑓 𝑥 = −𝑎𝑦(𝑎 > 0)
𝜌(𝑥, 𝑦) = 0 𝑖𝑓 𝑥 𝑎𝑛𝑑 𝑦 𝑎𝑟𝑒 𝑢𝑛𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑒𝑑
+1 𝑖𝑓 𝑥 = 𝑎𝑦(𝑎 > 0)
With our experience on expectation, we can write equation (1) as:
𝐸[𝑥, 𝑦] − 𝐸[𝑥][𝑦]
𝜌=
𝐸 [𝑥 ] − (𝐸[𝑥]) 𝐸[𝑦 ] − (𝐸[𝑦])
1 1 1
∑
𝑥 𝑦 − ( ∑ 𝑥 )( ∑ 𝑦 )
= 𝑛 𝑛 𝑛
1 1 1 1
∑ 𝑥 −( ∑ 𝑥 ) ∑ 𝑦 −( ∑ 𝑦 )
𝑛 𝑛 𝑛 𝑛
∑ . ∵ ̅ ∑
=
∑ ̅ ∑ ∵ ∑
∑ ( )( )
=
∑ ( ) ∑ ( )
In order to complete the value of ‘𝜌’ by using formula (III), we need to complete the value
of 𝑥̅ and 𝑦. So
𝑥̅ = ∑ 𝑥 = (48 + 35 + 17 + 23 + 47) = = 34
𝑦= ∑ 𝑦 = (45 + 20 + 40 + 25 + 45) = = 35
= = = = 0.42859 (Ans.)
√ . √ .
Computational Steps:
1. Compute the mean of x series and y series.
2. Take the devia ons of x series from the mean of x (𝑥̅ ) and denote these devia ons
by (x-𝑥̅ )
3. Take the devia ons of y series from the mean of y (i.e., 𝑦) and denote these
devia ons by (y-𝑦)
4. Mul ply (x-𝑥̅ ) and (y-𝑦) i.e. compute (x-𝑥̅ )(y-𝑦) and obtain the
total i.e., ∑(x − 𝑥̅ )(y − 𝑦) .
5. Take the square of (x-𝑥̅ ) and obtain the total i.e., ∑(x − 𝑥̅ ) .
6. Take the square of (y-𝑦)and obtain the total i.e., ∑(y − 𝑦) .
7. Now compute the value of 𝜌 and display the value.
Exercise:
1. Convert the computational steps into a computer program using any language.
2. Calculate coefficient of correlation from the following data:
X: 100 200 300 400 500 600 700
Y: 30 50 60 80 100 110 130
Ans: +0.977
1 1 1
∑ 𝑥 𝑦 − ( ∑ 𝑥 )( ∑ 𝑦 )
𝜌= 𝑛 𝑛 𝑛
1 1 1 1
∑ 𝑥 −( ∑ 𝑥 ) ∑ 𝑦 −( ∑ 𝑦 )
𝑛 𝑛 𝑛 𝑛
∑ (∑ )(∑ )
=
∑ (∑ ) ∑ (∑ )
3. Compute the correlation coefficient from the following data using equation (IV).
X: 2 3 5 6 8 9
Y: 6 5 7 8 12 11
𝑆𝑜𝑙 :
x y xy 𝒙𝟐 𝒚𝟐
2 6 12 4 36
3 5 15 9 25
5 7 35 25 49
6 8 48 36 64
8 12 96 64 144
9 11 99 81 121
∑ 𝒙=33 ∑ 𝒚=49 ∑ 𝒙𝒚=305 ∑ 𝑥 =219 ∑ 𝑦 =439
6(305) − (33)(49)
𝜌=
6(219) − (33) 6(439) − (49)
=
√ √
= =
√ √ ( )( . )
The class intervals for y are listed in the captions or column headings, and those for x are
listed in the stubs at the left of the table, the order can also be reserved. The frequencies
for each cell of the table are determined by either tallying or card sorting just as in the case
of frequency distribution of a single variable.
The formula for calculating the coefficient of correlation is:
.∑ . . . (∑ )(∑ )
𝜌= ,
.∑ . . (∑ ) .∑ . . (∑ )
Where, 𝑥 = (x − 𝑥̅ ), 𝑑𝑦 = (y − 𝑦), 𝑥̅ and 𝑦 are assumed mean and ‘𝑓’ is the frequency.
Example:
The following table gives the frequency, according to groups of marks obtained by 67
students on a test. Measure the degree of relationship between age ad test.
Age in Years
Test marks 18 19 20 21 Total
200-250 4 4 2 1 11
250-300 3 5 4 2 14
300-350 2 6 8 5 21
350-400 1 4 6 10 21
Total 10 19 20 18 67
Solution:
Let 𝑥 is the assumed mean of x series and 𝑦 is the assumed mean of y series.
dx = x – 𝑥̅ = x – 275
dy = y – 𝑦 = y – 19
The table for computing the correlation coefficient is as follows:
-10 0 20 36
10 0 20 72
0 0 18 48
67(66) − (46)(52)
ρ=
(67)(102) − (46) (67)(112) − (52)
√ √
√ √ ( . ) ( . )
.
Exercise:
1. The following are the marks obtained by the students of a class in theory of probability
(TP) and Computer Network(CN):
Roll [Link] Theory of Computer
student probability Network
1 15 13
2 0 1
3 1 2
4 3 7
5 16 8
6 2 9
7 18 12
8 5 9
9 4 17
10 17 16
11 6 6
12 19 18
13 14 11
14 9 3
15 8 5
16 13 4
17 10 10
18 13 11
19 11 14
20 11 7
21 12 18
22 18 15
23 9 15
24 7 3
Prepare a correlation table taking the magnitude of each class interval as four marks and
the first interval as equal to 0 and less than 4. Calculate Karl Pearson’s correlation
coefficient of TP and CN.
Note: One of the merits of this method is that if summarizes in one figure not only the
degree of correlation but also the direction, i.e., whether correlation is positive or negative.
Some of the demerits of this method are: (I) the value of the coefficient is unduly affected
by the extreme items; (II) as compared with other methods this method takes more time
to compute the value of correlation coefficient; and (III) it also assumes linear relationship
between variables.
P.E. = 0.6745 x ( )
√
Where ‘𝜌′ is the correlation coefficient and ‘N’ is the number of pairs of observations.
Interpretation:
i. If the value of ‘𝜌′ is less than the probable error there is no evidence the probable error
there is no evidence of correlation i.e, the value of ‘𝜌’ is not at all significant.
ii. If the value of ‘𝜌’ is more than ‘6’ times the probable error the coefficient of correlation
is practically certain, i.e, the value of ‘𝜌’ is significant.
iii. The coefficient of correlation obtained from population can lie between
R= ± P.E
, where R denotes correlation in the population.
Standard Error of ′𝜌′
=
√
Properties of the Coefficient of Correlation:
i. The coefficient of correlation lies between -1 and +1. Mathematically, -1≤ 𝜌 ≤ 1 ,
|𝜌| ≤ 1.
ii. The coefficient of correlation is independent of change of scale and origin of the
variables X and Y.
<Hints: X’ = , Y’= >
iii. The coefficient of correlation is the geometric mean of two regression coefficients.
Mathematically, 𝜌 = 𝑏 𝑋𝑏
iv. The degree of relationship between the two variables is symmetric as show below.
𝜌𝑋𝑌 =𝜌𝑌𝑋