Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Multivariate statistics: covariance and dependence

Heinrich Heine University Düsseldorf

Joint distribution and Bayes

More generally, (X1,X3,X9)(X_1,X_3,X_9) is also called a marginal distribution of XX, as is any composition of XX with a linear projection π ⁣:Rn→Rm\pi \colon \mathbb{R}^n \to \mathbb{R}^m – not necessarily onto a coordinate (hyper)plane of the standard basis of Rn\mathbb{R}^n.

Statement 3 is the generalisation of P(A∣B)=P(A)P(A \mid B) = P(A) from the chapter Expected value and variance: knowing XX does not shift the distribution of YY. In the continuous case the same equivalence holds with densities, but only “almost everywhere” – densities, after all, are determined only up to null sets (see Continuous distributions).

To work out the denominator P(B)P(B), the following theorem often helps:

In Bayes’ theorem you can therefore replace the denominator by P(B)=P(B∣A)P(A)+P(B∣Ac)P(Ac)P(B) = P(B|A)P(A) + P(B|A^c)P(A^c) when AA and its complement are all you have to go on.

We often apply this as follows: YY is “known” and XX is the provisional model. We then call Y=yY=y the data DD and X=xX=x the hypothesis HH.

For data and hypothesis this gives

Covariance

First a warning familiar from the chapter Descriptive statistics: covariance and correlation measure a relationship across all the data points. If the data split into groups, the relationship within each group can have the opposite sign – see Simpson’s paradox. So the numbers in this chapter tell you something only once you know that the sample comes from a single population.

In particular, V(X)=Cov⁡(X,X)\mathbb{V}(X) = \operatorname{Cov}(X,X).

The covariance suffers from the same complaint as the variance: it depends on the scale. The cure is to normalise by the standard deviations:

Symmetry and bilinearity give us the rules of calculation that come up constantly in practice:

The covariance therefore behaves like an inner product – but only “modulo constants”, since constant random variables have covariance 0 with everything, themselves included. This can be made rigorous by reading the covariance as an inner product on an L2\mathcal{L}^2 space of random variables in which two random variables differing only by a constant are identified. The correlation coefficient then plays the role of the cosine of the angle between two random variables. For data it literally is that (see the remark For data above); the “cosine similarity” so widespread in machine learning is the same cosine, just without the centring.

You can get some practice at “seeing” the correlation coefficient in a scatter plot of two variables, for instance with the game “Guess the Correlation” by Omar Wagih.

A sample from a bivariate normal distribution, with the two marginal histograms.

Figure 1:A sample from a bivariate normal distribution, with the two marginal histograms.

The picture shows why the correlation cannot be read off the individual variables. Each of the two marginal histograms is an unremarkable bell curve; they would look exactly the same if the correlation had the opposite sign, or were 0, because the marginal distributions do not depend on it. The relationship shows only in the joint scatter plot, in the tilt of the cloud of points. This is the observation made above about the joint distribution: it cannot be reconstructed from the individual ones.

What covariance and correlation mean geometrically we will see in the next chapter, on the multivariate normal distribution: there the covariance matrix describes the shape and position of the ellipses that are the contour lines of the density.