Memra

Sign, strength, linear only, and never causation

◈ 10 cards

=CORREL(C2:C7, B2:B7) and cor(stores$adspend, stores$sales) both give 0.9985999 ≈ 0.9986. r runs from −1 to 1, is unit-free (cor(adspend * 1000, sales) is identical), measures linear association only (cor(x, x^2) on a symmetric x is 0), and says nothing about cause. With an NA, cor() returns NA unless use = "complete.obs".

Strength, as a number

Lesson 13.1 called the scatter "strong" by eye. The correlation coefficient r turns that into a number between −1 and +1. In Sheets, with ad spend in B2:B7 and sales in C2:C7:

=CORREL(C2:C7, B2:B7)

and in R:

> cor(stores$adspend, stores$sales)
[1] 0.9985999
> round(cor(stores$adspend, stores$sales), 4)
[1] 0.9986

0.9986: positive, and very close to 1 — the six points are almost exactly on a rising line. Argument order does not matter for r (cor(storesadspend) is the same 0.9985999); it will matter for the slope in Lesson 13.3.

Read r in two parts. The sign is the direction: positive, y rises with x; negative, y falls as x rises. The magnitude is the strength: near 1 (either sign) the points hug a line; near 0 they do not. Rough words for the magnitude — 0.8 and up strong, 0.5 to 0.8 moderate, under 0.3 weak — are a convention, not a law; the scatter is still the evidence.

Worked example — three things r does not do

r ignores units. Ad spend in dollars instead of thousands:

> cor(stores$adspend * 1000, stores$sales)
[1] 0.9985999

Identical. r is computed from standardised distances from each mean, so rescaling either variable changes nothing — which is why r can be compared across datasets and the slope cannot.

r sees only straight lines. Seven points on a perfect U — x from −3 to 3, y = x²:

> xx <- c(-3, -2, -1, 0, 1, 2, 3)
> cor(xx, xx^2)
[1] 0

Exactly zero, for a relationship you could draw with your eyes shut. r ≈ 0 means no linear association, not no relationship. Look at the scatter first; a curve hides from r.

r is not robust. One outlier — a store that spent $10k and sold $10k — drags r down or even flips its sign. Rescaling cannot move r; a single wild point can.

The sentence you may not say

r = 0.9986 does not establish that advertising causes sales. Two other stories fit the same six points. A confounder: the bigger stores both advertise more and sell more, and size is doing the work. Reverse causation: "stores with more staff sell more" — but stores are staffed because they sell more; the arrow runs the other way. r measures association; a causal claim needs an experiment or a design that rules the other stories out, and AFM 112 gives you neither. Write "ad spend and sales are strongly, positively associated" and stop there.

When a value is missing

> cor(stores$adspend, s2)
[1] NA
> cor(stores$adspend, s2, use = "complete.obs")
[1] 0.9988267

One blank sales figure and cor() returns NA — the Module 9 rule, opt-in. use = "complete.obs" drops the incomplete pair; the five remaining stores give 0.9988, and the difference from 0.9986 is the price of the missing store.

Type both, then reproduce r in Python

The code block computes r from the two lists by hand: the sum of products of deviations over the square root of the two sums of squares.

CRISP-DM: r is data understanding → explore data — it describes the pair before any model is built.

NORMAL ~/memra/learn/afm-112/correlation-r utf-8 LF