In: Statistics and Probability
Solution:
A basic concept of the correlation coefficient r and covariance between two (random) variables X & Y and their necessary interpretation is required as a pre-requisite to understand the solution given to the problem.
We take 10 sample X-values and use a simple polynomia function to define Y.
Basically we have taken a U(2,4) distribution and simulated 10 values in R for illustration of the covariance and correlation values in this problem. The R code is as:
X<-runif(10,2,4) #10
random numbers are generated from a Uniform distribution
U(2,4)
Y=2*X+5 #We square the 10 X values
sort(X, decreasing = F)
sort(Y, decreasing = F)
The outputs are as:
Clearly, as X increases, the values of Y also increases (from the equation Y defined to explain the relationship between X & Y)
1. Now, the value of Correlation between X & Y asseses the strength of linear relationship between X & Y
Since r measures the strength of linear relationship, that is why Y and X have been related as a linear function.
(Non-linear finctions could have been also taken)
Here in this problem, the R code is :
corr<-cor(X,Y)
The value of r comes out to be1, which is very obvious.
Hence there is a high and positive linear relationship between the values of X & Y. It is obvious from the values of X & Y, which are linearly relateed to each other.
2. Covariance between 2 variables X & Y denotes the relationship between X & Y whenever one variable changes.
a) If an increase/decrease in one variable results in increase/decrease in the other variable, both variables are said to have positive covariance.
b) If the increase in one variable results in the decrease in the other variable, and vice versa, then it has negative variance
If a positive number is the magnitude of the covariance, the covariance is positive.
In this problem, the Y values increase as X values keeps increasing. The output is:
It is a positive value, 0.36, hence the relationship is such that Y and X tends to move in the same directions, i.e, as X increases, Y also increases.
The plot of X & Y values give us a better idea:
It is clear that as X is increasing, so as the values of Y. Moreover, the visulaization clearly indicates that the relationship is linear in nature, as evident from the value of the correlation coeffiecient of X & Y which is having the value 1.
The R-code for the above plot is:
plot(X,Y,main="Plot of
values of X & Y", xlab="x-val",
tlab="y-val")
(Answer)