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 ξ−E(ξ) and the same formula for η gives us the amount that they co-vary with each other:

Cov(ξ,η)=E[(ξ−E(ξ))(η−E(η))]

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:

E(ξ−E(ξ))×E(η−E(η))

Then, based on the rules for the expectation of a sum, and given that the expectation of a single number is that number: E(E(ξ))=E(ξ):

(E(ξ)−E(ξ))×(E(η)−E(η))]

E(ξ)−E(ξ)=0. So, we end up with 0×0.

Covariance of a variable with itself

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.

Cov(ξ,ξ)=E[(ξ−E(ξ))2]=V(ξ)

Sample covariance

∑i=1n(ξi−ξ¯)(ηi−η¯)n−1

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?

r=cov(ξ,η)V(ξ)V(η)

So, the units end up being:

cm⋅kgcm2⋅kg2

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 C11 is the same as V(1), and C12=C21.

[C11C12C13C21C22C23C31C32C33]