Covariance
GeneralStatistical Covariance
A measure of how two variables change together, where the sign indicates the direction of the relationship โ positive means they move together, negative means they move oppositely.
Definition
Covariance is a measure of how two variables change together. If both variables tend to be above their respective means at the same time (and below their means at the same time), the covariance is positive. If one variable tends to be above its mean when the other is below its mean, the covariance is negative. A covariance near zero suggests little to no linear relationship between the variables. The Covariance Calculator computes this value directly from a dataset of paired observations.
Covariance is the foundation for the correlation coefficient, which rescales covariance into a standardized, unitless value between -1 and 1 so relationships can be compared across variables measured in completely different units. Because raw covariance is expressed in the product of the two variables' units (for example, dollars ร years), it can be difficult to interpret magnitude directly โ this is why analysts typically move to the Correlation Coefficient, calculated with the Correlation Coefficient Calculator, when they need to judge the strength of a relationship rather than just its direction.
In finance, covariance between asset returns is a critical building block of modern portfolio theory โ it determines how combining two assets affects overall portfolio risk, independent of each asset's individual volatility.
Formula
For a sample of paired observations (x, y):
Cov(X, Y) = ฮฃ[(xแตข โ xฬ)(yแตข โ ศณ)] รท (n โ 1)
Where xฬ and ศณ are the means of X and Y, and n is the number of paired observations.
Worked Example
Consider 4 paired observations of advertising spend (X, in $1,000s) and sales (Y, in $1,000s):
| X | Y |
|---|---|
| 2 | 20 |
| 4 | 30 |
| 6 | 35 |
| 8 | 45 |
Mean of X (xฬ) = 5, Mean of Y (ศณ) = 32.5
Deviations and products: (2โ5)(20โ32.5) = 37.5, (4โ5)(30โ32.5) = 2.5, (6โ5)(35โ32.5) = 2.5, (8โ5)(45โ32.5) = 37.5
Sum = 37.5 + 2.5 + 2.5 + 37.5 = 80
Cov(X, Y) = 80 รท (4 โ 1) = 80 รท 3 โ 26.67
The positive covariance confirms advertising spend and sales tend to increase together.
Key Things to Know
- Sign matters more than magnitude: a positive covariance means the variables move together, a negative one means they move oppositely โ but the raw number itself is hard to interpret in isolation.
- Units affect the scale: covariance is expressed in the product of the two variables' units, which is why it's not directly comparable across different variable pairs.
- Correlation is the standardized version: dividing covariance by the product of the two standard deviations produces the Correlation Coefficient, which ranges from -1 to 1 and is easier to interpret for relationship strength.
- Zero covariance doesn't guarantee independence: two variables can have zero linear covariance while still having a strong non-linear relationship.
- Central to portfolio diversification: in finance, pairing assets with low or negative return covariance can reduce overall portfolio risk even when individual assets are volatile.
Related Calculators
Frequently Asked Questions