Correlation measures how two variables change together; its strength and direction are given by the correlation coefficient \(r\), which lies between −1 and +1.
Types of correlation
- Positive: both variables move in the same direction. Example: height and weight, study hours and marks.
- Negative: one rises as the other falls. Example: price of a product and its demand; speed of a car and travel time.
- Zero (no correlation): no linear relationship. Example: shoe size and IQ.
- Linear vs non-linear: linear if the points lie close to a straight line (constant rate of change); non-linear (curvilinear) if they follow a curve.
- Simple, partial and multiple: simple = two variables; multiple = one variable with two or more others together; partial = two variables with the effect of others held constant.
Karl Pearson's correlation coefficient
\[r = \frac{\sum (x-\bar x)(y-\bar y)}{\sqrt{\sum (x-\bar x)^2\,\sum (y-\bar y)^2}}\]
\(r = +1\): perfect positive; \(r = -1\): perfect negative; \(r = 0\): no linear relation. Roughly, \(|r| > 0.7\) is strong, 0.3–0.7 moderate, below 0.3 weak.
Worked example. \(x\): 1, 2, 3, 4, 5 and \(y\): 2, 4, 5, 4, 5. Means: \(\bar x = 3,\ \bar y = 4\).
- \(x-\bar x\): −2, −1, 0, 1, 2; \(y - \bar y\): −2, 0, 1, 0, 1
- \(\sum(x-\bar x)(y-\bar y) = 4 + 0 + 0 + 0 + 2 = 6\)
- \(\sum(x-\bar x)^2 = 10,\ \sum(y-\bar y)^2 = 6\)
\[r = \frac{6}{\sqrt{10\times 6}} = \frac{6}{7.746} \approx 0.77\]
So there is a fairly strong positive correlation.
Spearman's rank correlation (for ranked or non-normal data): \(\rho = 1 - \dfrac{6\sum d^2}{n(n^2-1)}\), where \(d\) is the difference in ranks.
Remember: correlation does not prove causation.