Sub topic 3
Covariance and Correlation
This chapter assumes you can compute a mean, a variance, and a standard deviation, and that you know why variance measures dispersion around an expected return. The previous chapters covered those ideas for a single asset. Here you extend them to a pair of assets. Everything about portfolio risk in the next chapters depends on this pair-level measure.
Why a single-asset measure is not enough
Variance tells you how much one asset's return moves around its own mean. It says nothing about whether two assets move together. Two portfolios can hold assets with identical standard deviations and still have very different total risk. The difference comes from how the assets co-move, and covariance and correlation are the tools that measure it.
Covariance
Covariance is a measure of how two random variables move together relative to their own means. For assets i and j:
Cov(Ri, Rj) = E[(Ri − E[Ri]) × (Rj − E[Rj])]
Read the formula as an average of products of deviations. When both assets are above their means at the same time, or both below, the product is positive. When one is above and the other is below, the product is negative.
- Positive covariance: the returns tend to move in the same direction.
- Negative covariance: the returns tend to move in opposite directions.
- Zero covariance: there is no linear tendency to move together.
Two facts follow directly from the definition:
- Covariance is symmetric: Cov(Ri, Rj) = Cov(Rj, Ri).
- The covariance of an asset with itself is its variance: Cov(Ri, Ri) = σ_i².
Covariance from scenarios
When you are given a probability for each scenario, covariance is the probability-weighted sum of the deviation products.
| Scenario | Probability | Return A | Return B |
|---|---|---|---|
| Strong economy | 0.25 | 20% | 2% |
| Base case | 0.50 | 8% | 6% |
| Recession | 0.25 | −10% | 10% |
First find the expected returns:
- E[R_A] = 0.25(20) + 0.50(8) + 0.25(−10) = 6.5%
- E[R_B] = 0.25(2) + 0.50(6) + 0.25(10) = 6.0%
Next multiply the deviations in each scenario, then weight by probability:
- Strong economy: (20 − 6.5)(2 − 6) = 13.5 × (−4) = −54
- Base case: (8 − 6.5)(6 − 6) = 1.5 × 0 = 0
- Recession: (−10 − 6.5)(10 − 6) = −16.5 × 4 = −66
Cov(A, B) = 0.25(−54) + 0.50(0) + 0.25(−66) = −30 (in %², or −0.0030 in decimals).
The negative sign says that A tends to do well when B does poorly. The number −30 is hard to interpret on its own, which is the main weakness of covariance.
Covariance from historical data
With historical returns you have no probabilities. You treat each of the n observations as equally likely and divide by n − 1, which gives the sample covariance:
Cov(Ri, Rj) = Σ (Ri,t − meani)(Rj,t − meanj) / (n − 1)
Dividing by n − 1 instead of n corrects the bias that comes from estimating the means from the same sample. CFA problems usually say whether the data are a sample. When they do not, a list of historical returns means n − 1.
Correlation
Covariance has two problems. Its units are squared returns, and its size depends on how volatile the assets are, so you cannot compare covariances across pairs. Correlation fixes both by dividing covariance by the product of the standard deviations:
ρij = Cov(Ri, Rj) / (σi × σ_j)
Correlation is a unitless number between −1 and +1. Rearranged, it gives the form you will use constantly in portfolio math:
Cov(Ri, Rj) = ρij × σi × σ_j
Continuing the scenario example:
- Var(A) = 0.25(13.5²) + 0.50(1.5²) + 0.25(−16.5²) = 114.75, so σ_A ≈ 10.71%
- Var(B) = 0.25(−4²) + 0.50(0²) + 0.25(4²) = 8, so σ_B ≈ 2.83%
- ρ = −30 / (10.71 × 2.83) ≈ −0.99
The two assets are almost perfectly negatively correlated. That fact is far easier to read from −0.99 than from a covariance of −30.
Interpreting correlation values
| Correlation | Meaning | Effect on a two-asset portfolio |
|---|---|---|
| +1.0 | Perfect positive linear relationship | No risk reduction; risk is the weighted average of the two standard deviations |
| Between 0 and +1 | Partial co-movement | Some risk reduction |
| 0 | No linear relationship | More risk reduction |
| Between −1 and 0 | Tendency to move oppositely | Substantial risk reduction |
| −1.0 | Perfect negative linear relationship | Risk can be reduced to zero with the right weights |
Computing both measures in code
The following program computes the scenario covariance and the sample covariance and correlation from historical returns.
from math import sqrt
def scenario_cov(probs, a, b):
mean_a = sum(p * x for p, x in zip(probs, a))
mean_b = sum(p * y for p, y in zip(probs, b))
return sum(p * (x - mean_a) * (y - mean_b) for p, x, y in zip(probs, a, b))
def sample_cov(a, b):
n = len(a)
mean_a, mean_b = sum(a) / n, sum(b) / n
return sum((x - mean_a) * (y - mean_b) for x, y in zip(a, b)) / (n - 1)
def sample_corr(a, b):
return sample_cov(a, b) / sqrt(sample_cov(a, a) * sample_cov(b, b))
# Scenario example, in percent: covariance comes out in %^2
print(scenario_cov([0.25, 0.50, 0.25], [20, 8, -10], [2, 6, 10])) # -30.0
# Historical example, in decimals
a = [0.10, 0.04, -0.02, 0.08, 0.05]
b = [0.06, 0.03, 0.01, 0.05, 0.04]
print(f"cov={sample_cov(a, b):.6f} corr={sample_corr(a, b):.4f}")The last line prints a covariance of 0.000875 and a correlation of 0.9927. Note that sample_cov(a, a) reuses the covariance function to get the variance, which follows from Cov(Ri, Ri) = σ_i².
The covariance matrix
For a portfolio of n assets you organize all the pairwise covariances in an n × n covariance matrix. The diagonal holds the variances. The off-diagonal cells hold covariances, and the matrix is symmetric, so only n(n − 1)/2 distinct covariances need estimating. A 3-asset portfolio needs 3 variances and 3 covariances. A 50-asset portfolio needs 50 variances and 1,225 covariances. Because the covariance terms grow much faster than the variance terms, they dominate portfolio risk as the number of holdings rises. This is the mechanism behind diversification, which a later chapter develops.
Common errors and limits
Mixing percent and decimal units. If returns are entered as 20 instead of 0.20, the covariance is in %² and is 10,000 times larger than the decimal version. Correlation is unaffected because the units cancel. When you plug covariance into portfolio variance, keep the weights, standard deviations, and covariance in the same units.
Reading covariance magnitude as strength. A covariance of 0.0090 between two volatile assets can reflect a weaker relationship than a covariance of 0.0010 between two quiet ones. Only correlation compares strength across pairs.
Treating zero correlation as independence. Correlation captures only linear association. Two variables can have a correlation of zero and still be strongly related, for example when one is the square of the other over a symmetric range. Independence implies zero correlation, but not the reverse.
Confusing correlation with causation. A high correlation does not show that one asset drives the other. Both may respond to a third factor, or the pattern may be a coincidence in a short sample. Spurious correlation is a recognized pitfall in the CFA curriculum.
Assuming correlations are stable. Estimated correlations change with the sample period and the market regime. Correlations between risky assets often rise in market crises, so diversification can be weaker exactly when you need it. Outliers can also distort a sample correlation.
Summary of the working model
- Covariance measures co-movement in squared-return units. Its sign is meaningful and its size is not comparable across pairs.
- Correlation rescales covariance to the range −1 to +1, which makes it comparable and easy to interpret.
- Use probabilities for scenario data and n − 1 for sample data.
- The covariance of an asset with itself is its variance.
- Correlation measures only linear association and is not guaranteed to be stable over time.
Exercise
Two assets have standard deviations of 12% and 5%. Their covariance is 0.0048. What is the correlation? If the correlation were instead 0.5, what would the covariance be?
Show answer
Convert the standard deviations to decimals: 0.12 and 0.05. Their product is 0.006. Correlation = 0.0048 / 0.006 = 0.80. With a correlation of 0.5, covariance = 0.5 × 0.12 × 0.05 = 0.003.
Exercise
A student computes the covariance of two return series as 0.0004 and reports that the relationship is "weak because the number is small." The standard deviations are 2% and 2%. What is the correlation, and is the student's conclusion correct?
Show answer
Correlation = 0.0004 / (0.02 × 0.02) = 0.0004 / 0.0004 = 1.0. The two series are perfectly positively correlated, so the conclusion is wrong. A small covariance only reflects the small standard deviations. Correlation is the measure that shows the strength of the relationship.