All tools

Correlation and the Least-Squares Line

The least-squares line $\hat{y} = a + bx$ is the line that minimises the sum of the squared residuals (the vertical distance from a point to the line, $y - \hat{y}$). The correlation coefficient $r$ gives the direction and strength of the linear relationship, and $r^2$ the proportion of the variation in $y$ explained by the line. Click on the plot to add a point; click a point to remove it. The red segments are the residuals.

What to notice

  • In the "curved relationship" example $r$ is close to zero, yet the points are very strongly related. $r$ measures only linear association; always look at the plot first.
  • In the "influential point" example remove the single point at the top right: $r$ and the slope change completely. Points that are extreme in the $x$ direction pull the line towards themselves.
  • The line always passes through the point $(\bar{x}, \bar{y})$.
  • $s$ is the typical size of a residual: it says, in the units of $y$, how far off the line's predictions are on average.