Sub topic 3
Covariance and Correlation
Assume you know how to calculate an arithmetic mean, variance, and standard deviation. You should also know that an asset’s return can differ from its expected return across possible outcomes.
Covariance and correlation measure how two asset returns move together. This matters because portfolio risk depends on the relationship between assets, not only on each asset’s individual risk.
Covariance
Covariance measures the direction of the relationship between two returns. For assets A and B with scenario probabilities, calculate it as:
Covariance(A, B) = Σ pi [RA,i − E(RA)] [RB,i − E(R_B)]
A positive covariance means the assets tend to be above or below their expected returns at the same time. A negative covariance means that when one asset is above its expected return, the other tends to be below its expected return. A covariance near zero means there is little linear relationship.
For historical sample data, use the sample covariance formula and divide by n − 1 rather than n. For equally likely scenarios in a population model, divide by the number of scenarios.
Consider these three equally likely scenarios:
| Scenario | Asset A return | Asset B return |
|---|---|---|
| Good | 10% | -5% |
| Neutral | 0% | 0% |
| Poor | -10% | 5% |
Both expected returns equal 0%. The covariance is:
- Good: 10% × -5% = -0.005
- Neutral: 0% × 0% = 0
- Poor: -10% × 5% = -0.005
- Average covariance: (-0.005 + 0 - 0.005) / 3 = -0.00333
The negative result shows that the assets move in opposite directions in these scenarios.
Covariance has units. If returns are measured in percentage points, covariance is measured in squared percentage points. Its size is therefore difficult to compare across different pairs of assets.
Correlation
Correlation standardizes covariance by dividing it by both assets’ standard deviations:
Correlation(A, B) = Covariance(A, B) / [σA × σB]
Correlation has no units and always falls between -1 and +1.
- +1 means perfect positive movement.
- -1 means perfect negative movement.
- 0 means no linear relationship.
In the example, Asset B is always half the opposite of Asset A. Therefore, their correlation is -1. Perfect negative correlation provides the greatest possible diversification benefit for two assets.
from math import sqrt
def covariance_and_correlation(asset_a, asset_b):
mean_a = sum(asset_a) / len(asset_a)
mean_b = sum(asset_b) / len(asset_b)
cov = sum(
(a - mean_a) * (b - mean_b)
for a, b in zip(asset_a, asset_b)
) / len(asset_a)
variance_a = sum((a - mean_a) ** 2 for a in asset_a) / len(asset_a)
variance_b = sum((b - mean_b) ** 2 for b in asset_b) / len(asset_b)
sd_a = sqrt(variance_a)
sd_b = sqrt(variance_b)
correlation = cov / (sd_a * sd_b)
return cov, correlation
a = [0.10, 0.00, -0.10]
b = [-0.05, 0.00, 0.05]
print(covariance_and_correlation(a, b))Why It Matters for Portfolios
Covariance enters the two-asset portfolio variance formula:
Portfolio variance = wA²σA² + wB²σB² + 2wAwB Cov(A, B)
Because covariance can be negative, combining assets can reduce portfolio risk below the risk of either asset alone. The next step is to use these relationships to calculate portfolio expected return and standard deviation.
Exercise
What does a correlation of -0.6 between two assets imply?
Show answer
Their returns tend to move in opposite directions, but not perfectly. Combining them can reduce portfolio risk, although it cannot generally eliminate all risk.