The Sample Covariance Matrix
Defines the sample covariance between two variables and assembles the sample covariance matrix S for two or more variables, including its symmetry and the identification of its diagonal as sample variances.
Tutorial
Sample Covariance Between Two Variables
The sample variance measures how a single variable spreads around its own mean. When we record two variables on the same subjects, the analogous quantity measuring how they vary together is the sample covariance.
Given paired observations with sample means and , the sample covariance between and is
This formula mirrors the sample variance — the sample variance is just the covariance of a variable with itself:
The sign of indicates the direction of linear association:
- : when is above , tends to be above as well.
- : when one variable is above its mean, the other tends to be below.
- : no linear association is detected in the sample.
To illustrate, consider the three paired observations . We have and , so