Introduction to Quant Finance · Lesson 11
Correlation and diversification
One number for how closely two series move together. It decides how much mixing two assets lowers risk; it sees straight lines only, and it says nothing about cause.
Know the basics? Read the lesson notesFive days, two assets
A day's return is what an asset gained or lost that day, in percent. Over five simulated days, asset X returned +2%, −1%, +3%, 0% and +1%, and asset Y returned −1%, −3%, +5%, +1% and +3%. Both averaged +1%: 5 ÷ 5.
A scatter plot draws each day as one dot: across for X's return, up for Y's. The dashed lines mark the two averages. Tap each day.
Five days of X and Y (simulated)
Each dot is a day. The box from the averages' crossing to the dot has sides equal to the two distances from the averages; colour: their product is positive; grey: negative.
A day when X and Y land on the same side of their averages, both above or both below, gives a positive product. Opposite sides give a negative one, and a day on an average line gives 0. The five products are −2, +8, +8, 0 and 0, which add up to 14.
Divide by 5 − 1 = 4, the way a sample's standard deviation (how far numbers typically land from their average) divides by n − 1 when a few days stand in for many more, and you get 3.5: the covariance. It is positive, so X and Y tended to land on the same side together. But 3.5 is in "percent times percent", and it grows with the size of the moves, so on its own it can't say how close the link is.
Covariance and correlation
Divide the covariance by both standard deviations and the units cancel. What is left is the correlation coefficient (Pearson's), usually just the correlation: a number from −1 to +1. At +1 the dots lie on a rising straight line, at −1 on a falling one, and at 0 there is no straight-line link.
- x1 … xn, y1 … yn
- the paired numbers, one pair a day; n is how many pairs
- μx, μy
- "mu", the average: their averages
- sx, sy
- their sample standard deviations: how far each typically lands from its average, dividing by n − 1
- cov
- the covariance: the average product of the two distances from the averages, dividing by n − 1
- ρ
- "rho", the correlation: from −1 to +1; it measures a straight-line link only
cov = 14 ÷ 4 = 3.5. X's distances +1, −2, +2, −1, 0 square to 1, 4, 4, 1, 0, which add up to 10: 10 ÷ 4 = 2.5, so sx = √2.5 ≈ 1.58%. Y's distances −2, −4, +4, 0, +2 square to 4, 16, 16, 0, 4, which add up to 40: 40 ÷ 4 = 10, so sy = √10 ≈ 3.16%. Their product is √(2.5 × 10) = √25 = 5, so ρ = 3.5 ÷ 5 = 0.7.
Double every one of Y's returns and the covariance and sy both double, so ρ stays 0.7. Correlation says how closely the dots follow a straight line, not how steep the line is.
- you want the strength of a straight-line link between two series;
- there are enough pairs;
- the link stays the same over the whole sample.
The link is curved (later in this lesson). One extreme day moves it a lot, because its distances are multiplied (real returns often have more extreme days than a bell curve; the Fat tails lesson covers this). If the link is stronger in wild spells than in calm ones, one number for the whole sample hides it.
New numbers. Over three days X returned +1%, +2% and +3%, and Y returned +2%, 0% and +4%. What is their correlation?
Drag the correlation
Two simulated assets, X and Y, over 250 days. Each day's return has a standard deviation of 1%, and the days were built to have exactly the correlation you set. Each price starts at 100 and compounds: every day it grows or shrinks by that day's return. Drag it to 1, to 0 and to −1.
X and Y at the correlation you set (simulated)
Top: one dot a day. Below: the two prices, both starting at 100. Dark: X. Colour: Y.
At 1 the dots lie on one rising line and the two prices move as one: X and Y moved the same way on all 250 days. At −1 the line falls and the prices mirror each other: 0 days. At 0 the dots make a round cloud and the prices wander apart: 124 days, about half.
Guess the correlation
Three more simulated pairs of 100 days, built with correlations of −0.6, 0.3 and 0.9, one each. Pick the correlation you think each scatter has.
Three pairs, 100 days each (simulated)
Pair A
Pair B
Pair C
Pair A was 0.3, pair B −0.6 and pair C 0.9. A correlation of 0.3 still looks like a round cloud with a slight lean; it takes about 0.9 before the dots form a tight band.
Two 10% risks, how big together?
Two simulated assets. Each one's yearly return has a standard deviation of 10%: its volatility, the usual name for the standard deviation of an asset's returns. Picture an account that holds half of each, reset to half and half at the start of every year (called rebalancing). This 50/50 mix's yearly return is half of one asset's return plus half of the other's. Guess first: if the two assets have a correlation of 0, what is the mix's volatility?
10,000 simulated years of the 50/50 mix
Each column counts the years whose return landed in a range 2.5% wide. Shaded: 0%, the average return, ± one standard deviation. At −1 every year lands on 0%, so the band has no width.
You guessed 10%. At a correlation of 0 it was 7.03%.
You guessed 5%. At a correlation of 0 it was 7.03%.
You guessed about 7%, and at a correlation of 0 it was 7.03%.
Across the 10,000 simulated years the mix's volatility was 9.86% at a correlation of 1, 7.03% at 0 and 0% at −1.
At 1 the two assets rise and fall together, so the mix is as risky as either one alone. At −1 one asset's gain is always the other's loss, and, being the same size, the two halves cancel. At 0 they partly cancel.
The volatility of a 50/50 mix
Lowering risk by mixing things that don't move as one is called diversification. In any one year, call the two assets' distances from their average returns d1 and d2. The mix's distance is ½d1 + ½d2, and its square is ¼d1² + ¼d2² + ½ × d1 × d2 (the middle term is 2 × ½ × ½ = ½). Averaged over many years, d1² gives σ1², d2² gives σ2², and d1 × d2 gives the covariance, which is ρ × σ1 × σ2 (the correlation formula turned around). Take the square root:
- σ1, σ2
- "sigma", the two assets' volatilities: the standard deviations of their returns
- ρ
- the correlation of their returns
- σmix
- the volatility of a mix holding half of each, if ρ is the same throughout
σ1 = σ2 = 10, so ¼ × 100 = 25 twice, and ½ × ρ × 10 × 10 = 50ρ: σmix = √(25 + 25 + 50ρ).
ρ = 1: √100 = 10%. ρ = 0.5: √75 ≈ 8.66%. ρ = 0: √50 ≈ 7.07%. ρ = −0.5: √25 = 5%. ρ = −1: √0 = 0%.
Below 1, the mix is less risky than either asset: that is the gain from diversification. Near 1 it fades: at ρ = 0.9, √95 ≈ 9.75%, barely below 10%. The simulation measured 9.86%, 7.03% and 0%: 10,000 years are still a sample, so its first two land a little off the formula's 10% and 7.07%.
- the two volatilities and the correlation are the true ones, or well measured (a later card shows how far a short sample's correlation can be off);
- the correlation is the same in calm and wild spells;
- the mix is reset to half and half each time.
If the correlation is higher in wild spells than the number put in, the mix is riskier than the formula says.
New numbers. Two assets have volatilities of 6% and 8% and a correlation of 0.5. What is the volatility of a 50/50 mix, in percent?
Straight lines only
Now a pair with a perfect link that isn't straight. Asset X's day is a bell-curve draw (most days near the average, fewer far out) with a standard deviation of 1%. Series Y's day is X's return in percent, squared, minus 1: on a day X moves 2% either way, Y is 2 × 2 − 1 = +3%. Y is fully set by X.
X and Y, 250 days (simulated)
Y = X × X − 1, with X in percent: X at +2% or −2% gives Y at +3%.
What is the correlation of these 250 days?
Not one sample's luck: across 1,000 simulated samples of 250 days, the correlation averaged 0.00 and landed between −0.3 and 0.3 in 978. A correlation near 0 means no straight-line link, not no link.
A short sample is noisy
Take two simulated series with nothing between them: each day of each is its own bell-curve draw, so their true correlation is 0. Guess first: of 1,000 samples of 20 days, how many measure a correlation of 0.3 or more, or −0.3 or less? Then look at 20 days and at 250.
1,000 samples of each length, true correlation 0 (simulated)
Each column counts the samples whose measured correlation landed in a range 0.05 wide. Colour: 0.3 or more either way.
You guessed about 10. It was 190.
You guessed about 200, the closest of the three. It was 190.
You guessed about 500. It was 190.
In this simulation, of the 1,000 samples of 20 days, 190 measured 0.3 or more either way, and the middle 950 ran from −0.45 to 0.44. Of the 1,000 samples of 250 days, 0 did, and the middle 950 ran from −0.13 to 0.12.
More days, more of the luck cancels.
Moving together, not moving each other
Two more simulated assets. Each day, X moves by a "market" move plus a move of its own, and Y moves by the same market move plus a move of its own. All three moves are separate bell-curve draws of the same size, so each asset is half market, half its own: half its movement is shared, and the true correlation is 0.5. Neither asset ever sees the other's move, yet over these 250 days they measured a correlation of 0.37, and over 1,000 such samples 0.50 on average.
X and Y, 250 days (simulated)
Take the market move out of both, leaving each asset's own move. What will their correlation be?
With the market move taken out, these 250 days measured −0.09; the 1,000 simulated samples averaged 0.00, and 0 of them measured 0.3 or more either way, against 999 before.
A correlation can't tell X moving Y from Y moving X, or from a third series moving both. The textbook name for such a third series is a confounder: correlation is not causation.
One more word: beta, how far one series tends to move for each 1% the other moves, the steepness the correlation leaves out. For the five days at the start, the covariance divided by X's standard deviation squared gives 3.5 ÷ 2.5 = 1.4: Y tended to move 1.4% for each 1% of X, with a correlation of 0.7. The Regression lesson works it out properly.
What this means for your backtest
A backtest runs a trading rule over past prices to see what it would have made. When you run two rules, or compare a rule with a market, correlation comes in. Three habits follow.
- Ask which correlation a mix's risk assumed.
A 50/50 mix of two 10% assets is 10% at a correlation of 1 and about 7% at 0. Mixing lowers risk only as far as the correlation sits below 1, and only while it stays there.
- Read a correlation with its sample.
In this lesson's simulation, over 20 days, two series with nothing between them landed anywhere from −0.45 to 0.44 in 950 of 1,000 samples. If the link differs between calm and wild days, one number hides that.
- Ask what it can't see.
A curved link can measure near 0, and a shared driver can make two series move together without either moving the other.
"14% of risk"
If the correlation stays at 0.25, what is the volatility of the account's yearly return, in percent?
Hint: σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2) with 12, 16 and 0.25.
"X drives Y"
What can those 20 days tell you?
Lesson done
The correlation measures how closely two series follow a straight line together, from −1 to +1: their covariance divided by both standard deviations. It decides how much mixing lowers risk: if the correlation stays the same throughout, a 50/50 mix's volatility is the average of the two only at a correlation of 1, less below it, and 0% at −1 for two equally volatile assets. It sees straight-line links only, not how steep the line is (that is beta); a short sample's figure is noisy (in this lesson's simulation, 20-day samples of unrelated series landed from −0.45 to 0.44 in 950 of 1,000); and it can't say which series moves which.
Key ideas
- Scatter plot
- a chart of pairs, one dot each: across for one series, up for the other
- Covariance
- the average product of two series' distances from their averages, dividing by n − 1; positive when they tend to land on the same side of their averages together
- Correlation
- the covariance divided by both standard deviations: from −1 to +1, the strength of a straight-line link only, for that sample
- Beta
- how far one series tends to move for each 1% the other moves: the steepness of the line, which the correlation leaves out
- Diversification
- lowering risk by mixing things that don't move as one; for a 50/50 mix it is largest at a correlation of −1 and gone at 1, if the correlation is the same throughout
- Confounder
- a third series that moves two others, giving them a correlation though neither moves the other
Formulas
cov = sum of (x − μx)(y − μy) ÷ (n − 1) · ρ = cov ÷ (sx × sy)
σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2)
The second formula, for a mix holding half of each, needs a correlation that stays the same throughout; a measured one carries its sample's noise.