Covariance and Pearson correlation
Covariance and Pearson's r measure how strongly two quantitative variables move together along a straight line.
- sample covariance of x and y (units of x × units of y)
- number of (x, y) pairs
- sample means of x and y
- sum of cross-products
- sums of squared deviations of x and of y
- sample standard deviations (n − 1)
- unit-free correlation, between −1 and 1
- test statistic, referred to a t distribution with n − 2 degrees of freedom
- population correlation
- Fisher's z transform of r, approximately normal with SE
- standard normal critical value (1.96 for 95%)
When to use
- Two quantitative variables measured on the same units, and you want the direction and strength of a linear association.
- Always draw the scatter plot first: r summarises a straight-line pattern and nothing else.
Assumptions
- Pairs are independent of each other.
- For the t-test and Fisher interval to be exact: (approximately) bivariate normal data. Outliers and curvature distort r badly.
How to interpret
- Sign gives direction; near 1 means the points lie close to a line, near 0 means no linear trend (there may still be a curved one).
- is the proportion of the variance in y explained by a straight-line fit on x.
- r has no units and is unchanged by changing units or swapping x and y. Covariance keeps units, so its size is hard to judge on its own.
- A small p-value says the data are hard to reconcile with ; it does not say the association is strong or causal.
Common mistakes
- Reading correlation as causation: a confounder, reverse causation or coincidence can all produce r.
- Concluding "no relationship" from when the scatter plot shows a curve.
- Letting one extreme point drive r, or computing r on groups mixed together (Simpson's paradox).
- Comparing covariances measured in different units.
Example
Six weeks of advertising spend x (thousand SAR) and sales y: x = 1, 2, 3, 4, 5, 6 and y = 3, 5, 4, 7, 8, 9.
- ; , , so .
- on 4 df, two-sided p = 0.0039.
- 95% Fisher interval for ρ: (0.596, 0.995) — wide, because n = 6.