One outlier and the correlation

100 points from a bivariate normal distribution (same data as in the script, seed 123). The last point is the one you can move: drag the red point with the mouse, or select it and use the arrow keys. Watch how the numerator and the standard deviations of x and y change, and what that does to r.

Place the point (as in the script):
Blue point: adds positively to the numerator, (x−x̄)(y−ȳ) > 0. It lies right of and above, or left of and below, the crossing of the dashed mean lines.
Orange point: adds negatively, (x−x̄)(y−ȳ) < 0. It lies left of and above, or right of and below, the crossing of the mean lines.
Red point: the point you can move.
Dashed ring and line: where the red point was originally.
Red line: regression line now.
Grey dashed line: regression line of the original data.
Thin dashed lines: means x̄ and ȳ (now).
Shaded rectangle: cross-product of the red point, blue if positive, orange if negative.

If the colouring is switched off, all points except the red one are blue.

– r now   (original: –)

Formula. r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √( Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)² ). This is the same as Sxy / (sₓ · sy) with covariance and standard deviations that all divide by n − 1: the n − 1 cancels, so (n − 1) · sₓ · sy equals the denominator above. The numerator is the sum of the cross-products. A point above the mean of y and right of the mean of x (or below and left) adds a positive amount, the other two quadrants add a negative amount. The denominator is always positive and grows with the spread of x and of y. The original line shows the data with the last point at its original position (A). Spearman's rs uses ranks only and is much less affected by the moved point. The data are the same as in the R code of the script (set.seed(123), ρ = 0.75, n = 100): r = 0.71 originally, 0.44 for B, 0.82 for C and 0.48 for D.