Chapter 5: JOINT PROBABILITY DISTRIBUTIONS Part 2: Section 5-2 Covariance and Correlation Consider the joint probability distribution f XY (x, y). Is there a relationship between X and Y? If so, what kind? If you re given information on X, does it give you information on the distribution of Y? (Think of a conditional distribution). Or are they independent? 1
Below is a different joint probability distribution for X and Y. Does there seem to be a relationship between X and Y? Are they independent? If you re given information on X, does it give you information on the distribution of Y? How would you describe the relationship? Is it stronger than the relationship on the previous page? Do you know MORE about Y for a given X? 2
Below is a joint probability distribution for an independent X and Y. This picture is the give-away that they re independent. Does there seem to be a relationship between X and Y? If you re given information on X, does it give you information on the distribution of Y? 3
Covariance When two random variables are being considered simultaneously, it is useful to describe how they relate to each other, or how they vary together. A common measure of the relationship between two random variables is the covariance. Covariance The covariance between the random variables X and Y, denoted as cov(x, Y ), or σ XY, is σ XY = E[(X E(X))(Y E(Y ))] = E[(X µ X )(Y µ Y )] = E(XY ) E(X)E(Y ) = E(XY ) µ X µ Y 4
To calculate covariance, we need to find the expected value of a function of X and Y. This is done similarly to how it was done in the univariate case... For X, Y discrete, E[h(x, y)] = x y h(x, y)f XY (x, y) For X, Y continuous, E[h(x, y)] = h(x, y)f XY (x, y)dxdy Covariance (i.e. σ XY ) is an expected value of a function of X and Y over the (X, Y ) space, if X and Y are continuous we can write σ XY = (x µ X )(y µ Y )f XY (x, y) dx dy To compute covariance, you ll probably use... σ XY = E(XY ) E(X)E(Y ) 5
When does the covariance have a positive value? In the integration we re conceptually putting weight on values of (x µ X )(y µ Y ). What regions of (X, Y ) space has... (x µ X )(y µ Y ) > 0? Both X and Y are above their means. Both X and Y are below their means. Values along a line of positive slope. A distribution that puts high probability on these regions will have a positive covariance. 6
When does the covariance have a negative value? In the integration we re conceptually putting weight on values of (x µ X )(y µ Y ). What regions of (X, Y ) space has... (x µ X )(y µ Y ) < 0? X is above its mean, and Y is below its mean. Y is above its mean, and X is below its mean. Values along a line of negative slope. A distribution that puts high probability on these regions will have a negative covariance. 7
Covariance is a measure of the linear relationship between X and Y. If there is a non-linear relationship between X and Y (such as a quadratic relationship), the covariance may not be sensitive to this. When does the covariance have a zero value? This can happen in a number of situations, but there s one situation that is of large interest... when X and Y are independent... When X and Y are independent, σ XY = 0. 8
If X and Y are independent, then... σ XY = (x µ X )(y µ Y )f XY (x, y) dx dy = (x µ X )(y µ Y )f X (x)f Y (y) dx dy ( ) ( ) = (x µ X )f X (x)dx (y µ Y )f Y (y)dy ( ) ( ) = xf X (x)dx µ X yf Y (y)dy µ Y = (E(X) µ X ) (E(Y ) µ Y ) = (µ X µ X ) (µ Y µ Y ) = 0 This does NOT mean... If covariance=0, then X and Y are independent. We can find cases to the contrary of the above statement, like when there is a strong quadratic relationship between X and Y (so they re not independent), but you can still get σ XY = 0. Remember that covariance specifically looks for a linear relationship. 9
When X and Y are independent, σ XY = 0. For this distribution showing independence, there is equal weight along the positive and negative diagonals. 10
A couple comments... You can also define covariance for discrete X and Y : σ XY = E[(X µ X )(Y µ Y )] = x y (x µ X)(y µ Y )f XY (x, y) And recall that you can get the expected value of any function of X and Y : E[h(X, Y )] = h(x, y)f XY (x, y) dx dy or E[h(X, Y )] = x y h(x, y)f XY (x, y) 11
Correlation Covariance is a measure of the linear relationship between two variables, but perhaps a more common and more easily interpretable measure is correlation. Correlation The correlation (or correlation coefficient) between random variables X and Y, denoted as ρ XY, is ρ XY = cov(x, Y ) V (X)V (Y ) = σ XY σ X σ Y. Notice that the numerator is the covariance, but it s now been scaled according to the standard deviation of X and Y (which are both > 0), we re just scaling the covariance. NOTE: Covariance and correlation will have the same sign (positive or negative). 12
Correlation lies in [ 1, 1], in other words, 1 ρ XY +1 Correlation is a unitless (or dimensionless) quantity. Correlation... 1 ρ XY +1 If X and Y have a strong positive linear relation ρ XY is near +1. If X and Y have a strong negative linear relation ρ XY is near 1. If X and Y have a non-zero correlation, they are said to be correlated. Correlation is a measure of linear relationship. If X and Y are independent, ρ XY = 0. 13
Example: Recall the particle movement model An article describes a model for the movement of a particle. Assume that a particle moves within the region A bounded by the x axis, the line x = 1, and the line y = x. Let (X, Y ) denote the position of the particle at a given time. The joint density of X and Y is given by f XY (x, y) = 8xy for (x, y) A a) Find cov(x, Y ) ANS: Earlier, we found E(X) = 4 5... 14
15
Example: Book problem 5-43 p. 179. The joint probability distribution is x -1 0 0 1 y 0-1 1 0 f XY 0.25 0.25 0.25 0.25 Show that the correlation between X and Y is zero, but X and Y are not independent. 16
17