Shows how strongly two things move together, from −1 to +1.
cor(x, y)
Key idea
Correlation, written r, is one number from -1 to +1 showing how strongly two things move together in a straight line. (e.g. -1 to +1)
A value near +1 means a strong positive link: both rise together. (e.g. r = 0.9)
A value near -1 means a strong negative link: one rises as the other falls. (e.g. r = -0.85)
A value near 0 means little or no straight-line link. (e.g. r = 0.02)
Correlation is not causation: a link does not prove one thing causes the other.
Definition
r=∑(xi−xˉ)2∑(yi−yˉ)2∑(xi−xˉ)(yi−yˉ)
xi,yi
each pair of values
xˉ,yˉ
their means
r
the correlation, from -1 to +1
r=∑(x−xˉ)2∑(y−yˉ)2∑(x−xˉ)(y−yˉ)≈0.98
Where you'd use it
You record each student’s study hours and exam score. cor might return 0.85, a strong positive number telling you that students who study more clearly tend to score higher.
Tracking daily temperature against ice-cream sales, cor could come out near 0.9, confirming a strong link — though remember it shows they move together, not that heat directly causes the sales.
For cars, comparing weight with fuel used per mile gives a positive cor around 0.7, so heavier cars tend to burn more fuel, while a value near 0 would mean almost no straight-line link.
Frequently asked questions
What does cor measure?
The strength of a linear relationship, from −1 to +1. 0 means no linear link (a curve can still exist).