Covariance
Weight and Height estimates
In this chart of weight and height, there is some correlation. We can tell from this chart that large height values are often associated with higher weights. We can calculate the variance between the two variables with covariance.
The expectation of the product between
Covariance with independent variables
If the two are independent, then the covariance will be zero. This tracks with what we learned about the product of expectations (Important Formulas) - if they are independent then the expectation of the product is the product of the expectation:
Then, based on the rules for the expectation of a sum, and given that the expectation of a single number is that number:
The covariance of a variable with itself (e.g. between height and height) is the same as the variance. In fact, we can think of the covariance as just a special case of the variance.
Sample covariance
This is our unbiased estimate of the covariance -but we can only estimate this, we can never get the "true" value.
Correlation coefficient
What are the units of the covariance?
- In our example, we were looking at height (
) and weight ( ). - Therefore, the units of our covariance would be
. - These units are not that useful, so we often look at the "correlation coefficient"
instead:
So, the units end up being:
In other words, it is unitless value between -1 and 1. This is a more useful estimate and can be applied to different units and data sources and be easily understood.
Covariance Matrix
What if we want the covariance between three variables? We can arrange them in a covariance matrix. This is how Principal Component Analysis works - with a matrix of covariances.
Note that