Statistics and Regression, lesson 5
Correlation
Measuring how two things move together, and how it misleads.
Two stocks rise and fall in the same weeks. Correlation puts how closely they move together into one number, and that number misleads in ways worth knowing. You need averages and standard deviations from Samples and estimates.
By the end, you can:
Part 1. Moving together, in one number
Compute the correlation of two series by hand.
Here are five weeks of GULL and the market. In weeks when the market does better than usual, GULL tends to as well. To put a number on that, measure each week from the two averages, and see whether the two distances share a sign.
Example 1.1
Five weeks of GULL and the market
Over five weeks the market returns +1%, −1%, +3%, 0% and +2%, and GULL returns 0%, −1%, +2%, +1% and +3%. How strongly do they move together?
- Find the two averages5 / 5 = 1%, both
Each set of returns adds to 5.
- Measure each week from themmarket 0, −2, 2, −1, 1
Each return minus 1%. GULL's distances are −1, −2, 1, 0 and 2.
- Multiply each week's pair and add0 + 4 + 2 + 0 + 2 = 8
Matching signs give a positive product, opposite signs a negative one.
- Scale by the two spreads8 / √(10 × 10) = 0.8
Each stock's squared distances add to 10: 0 + 4 + 4 + 1 + 1 for the market.
Answerr = 0.8: they move together closely.
Why does it work? A week where both stocks beat their averages, or both fall short, gives a positive product. A week where one is above and the other below gives a negative one. The sum says which kind wins, and dividing by √(10 × 10) scales it so r always lands between −1 and +1.
Correlation
The correlation coefficient r, also called Pearson's r, runs from −1 to +1. +1 means the points sit exactly on a rising line, −1 exactly on a falling one, and 0 means no straight-line relation. Σ means "add up":
r = Σ(x − x̄)(y − ȳ) / √(Σ(x − x̄)² × Σ(y − ȳ)²)
The top sum divided by n − 1 is the covariance, here 8 / 4 = 2. It carries the units of both returns, %², so its size depends on how you measure. r divides the units away: add a constant to every return, or count in basis points, and r doesn't move.
Your turn
Over four weeks the market returns −1%, +1%, +1% and +3%, and a second stock returns −1%, 0%, +1% and 0%. What's their correlation?
Part 2. One week can make a correlation
Spot when a single point is steering r.
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- One week can make a correlation
- Shapes r can't see
- Limits on a third correlation
Statistics and Regression overviewSpotted a mistake? Tell us.