Correlation measures how strongly two variables move together. Regression goes further and fits a line, so one variable can be predicted from the other. Both are easy to compute and easy to over-interpret.
Scatter diagrams
Plot the pairs (x,y) before calculating anything. A scatter diagram shows at once whether the relationship is:
positive — y rises as x rises;
negative — y falls as x rises;
linear or curved — and if it is curved, a correlation coefficient will understate it badly;
affected by outliers — one distant point can dominate the whole calculation.
By convention x is the explanatory (independent) variable and y the response (dependent) variable.
So r=0.853 indicates a fairly strong positive linear relationship.
Spearman's rank correlation
When data is ranked rather than measured — positions in a competition, quality ratings — or when the relationship is monotonic but not straight, use
rs=1−n(n2−1)6∑d2
where d is the difference between the two ranks for each item.
Two judges rank five entries. The rank differences are −1,1,−1,1,0.
∑d2=1+1+1+1+0=4rs=1−5(24)6(4)=1−12024=0.8
A strong measure of agreement between the judges.
The regression line
The least-squares regression line of y on x minimises the sum of the squared vertical distances from the points to the line:
y=a+bxb=SxxSxya=yˉ−bxˉ
For the data above:
b=108=0.8a=4.2−0.8(3)=1.8y=1.8+0.8x
The gradient b is the practical result: each unit increase in x is associated with an increase of 0.8 in y.
The line always passes through (xˉ,yˉ). Here 1.8+0.8(3)=4.2=yˉ ✓ — a free check on the arithmetic.
Using the regression line
Interpolation — predicting inside the range of the data — is reasonable. For x=2.5:
y=1.8+0.8(2.5)=3.8
Extrapolation — predicting outside it — is unreliable, however tidy the arithmetic. At x=20 the line gives y=17.8, but nothing in data spanning x=1 to 5 justifies assuming the pattern continues that far.