insideout Get Pro

05 · Correlation

Pro

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:

  1. Compute the correlation of two series by hand.
  2. Spot when a single point is steering r.
  3. Tell r = 0 apart from no relation at all.
  4. Find the range a third correlation must lie in.

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?

  1. Find the two averages5 / 5 = 1%, both

    Each set of returns adds to 5.

  2. Measure each week from themmarket 0, −2, 2, −1, 1

    Each return minus 1%. GULL's distances are −1, −2, 1, 0 and 2.

  3. Multiply each week's pair and add0 + 4 + 2 + 0 + 2 = 8

    Matching signs give a positive product, opposite signs a negative one.

  4. 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.

−1%−1%0%0%+1%+1%+2%+2%+3%+3%both above: +both below: +one above: −one above: −0+4+20+2average 1%the market's weekly return, across; GULL's, up
Figure 1The five weeks, with dashed lines at the two averages. Weeks where both are above, or both below, add to r, and a week with one of each would take away. Here the products are 4, 2, 2, 0 and 0.

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?

The averages are 1% and 0%. The distances are −2, 0, 0, 2 and −1, 0, 1, 0, so the products add to 2. The squares add to 8 and 2, and 2 / √(8 × 2) = 0.5. Dividing by 8 alone gives 0.25, and forgetting the square root gives 0.125.

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.

Still to come
  1. One week can make a correlation
  2. Shapes r can't see
  3. Limits on a third correlation

Statistics and Regression overviewSpotted a mistake? Tell us.