Probability & Statistics · Correlation

Correlation

The correlation coefficient r measures the direction and strength of a straight-line association between two quantities that both vary. Here each point and the center of the data bound a rectangle measured in standard deviations, and r adds up their signed areas.

Correlation in this visualization

The correlation coefficient rr of paired data, also called Pearson's correlation coefficient, measures how closely the points follow one straight line: it runs from −1 to 1, positive when xx and yy tend to rise together. Here each point and the center of the data bound a rectangle whose sides are measured in standard deviations, and rr is their signed areas added up and divided by n−1n-1. You can drag, add and delete points, load Anscombe's four data sets or a cloud made with a chosen rr, and see the squares that keep rr between −1 and 1.

Standard units, and r from the rectangles
zx=x−xˉsx,zy=y−yˉsy,r=1n−1∑zxzyz_x = \frac{x - \bar x}{s_x}, \quad z_y = \frac{y - \bar y}{s_y}, \qquad r = \frac{1}{n-1}\sum z_x z_y

What does rr measure? In standard units, zxz_x says how many standard deviations a point lies to the right of the mean of xx, and zyz_y how many above the mean of yy. The rectangle between the point and the center has area ∣zxzy∣|z_x z_y|; it counts as positive in the upper right and lower left, where both coordinates are on the same side of their means, and as negative in the other two corners. Because the sides are in standard deviations, changing units or swapping xx and yy leaves rr unchanged. The plot is drawn the same way: one standard deviation is equally long on both axes, so the dashed box is a square and its upper right quarter is one unit of area.

Why can rr never pass ±1? Draw the line zy=zxz_y = z_x through the center. A point's squared distance from it is (zy−zx)2/2(z_y - z_x)^2/2, and these squares added up and divided by n−1n-1 give exactly 1−r1 - r, because the zx2z_x^2 and the zy2z_y^2 each add up to n−1n-1. Across the other diagonal, zy=−zxz_y = -z_x, the same sum gives 1+r1 + r. Squares are never negative, so −1≤r≤1-1 \le r \le 1, and r=1r = 1 only when every square across zy=zxz_y = z_x vanishes: all the points lie on one rising line.

Why can the same rr come from very different pictures? rr adds up rectangles and never looks at the shape. The statistician Francis Anscombe built four data sets in 1973 with nearly the same rr, means and fitted line: one is a straight band, one a smooth curve, one follows a nearly straight line apart from an outlier, and one has a single point carrying most of the signed sum. A rectangle grows with the product of a point's two distances from the center, so one far point can supply most of the total area. And points exactly on a parabola can have r=0r = 0 when they are placed symmetrically: each rectangle on one side is cancelled by its mirror image on the other. rr measures straight-line association only.

Why look at it in standard units? The eye judges correlation by how thin the cloud looks, and that depends on the axes: stretch one and the same points look thinner or rounder. In experiments by Cleveland, Diaconis and McGill (1982), people judged the same scatter plots as more strongly correlated when the scales were enlarged around them. Standard units make the two axes comparable, one standard deviation equally long on both, and in that picture the cloud's spread across the two diagonals is exactly what rr measures. They do not make the eye reliable: zoomed out, the same cloud still looks tighter.

Things to notice

  • A strong correlation does not show that one variable causes the other: both may follow a third.
  • rr is the cosine of the angle between the centered data vectors (xi−xˉ)(x_i - \bar x) and (yi−yˉ)(y_i - \bar y).
  • A cloud made from rr has exactly that correlation by construction; random samples would vary around it.

Controls

  • Moving one point can change the center and the standard deviations of the whole cloud, so even points you did not touch can move on the screen.

Related