Mostly Harmless StatisticsXYZ Homework Edition

⇩ Download ▾

12.2 Scatterplots

A scatterplot shows the relationship between two quantitative variables measured on the same individuals.

How to Interpret a Scatterplot:

Correlation Coefficient

The sample correlation coefficient measures the direction and strength of the linear relationship between two quantitative variables. There are several different types of correlations. We will be using the Pearson Product Moment Correlation Coefficient (PPMCC). The PPMCC is named after biostatistician Karl Pearson. We will just use the lower-case rr for short when we want to find the correlation coefficient, and the Greek letter ρ\rho, pronounced “rho,” (rhymes with sew) when referring to the population correlation coefficient.

Portrait photograph of Karl Pearson.
Karl Pearson

Interpreting the Correlation:

8 sample scatterplots, with correlation values ranging from -1 to 1. Plots form a straight line when r=-1 or r=1, and become more random as r approaches 0.
Figure 12-1: Sample scatterplots with various values of rr.

When you have a correlation that is very close to 1-1 or 11, then the points on the scatter plot will line up in an almost perfect line. The closer rr gets to 00, the more scattered your points become.

When rr is equal to 1-1 or 11 all the dots in the scatterplot line up in a straight line. As the points disperse, rr gets closer to zero. The correlation tells the direction of a linear relationship only. It does not tell you what the slope of the line is, nor does it recognize nonlinear relationships. For instance, in Figure 12-2, there are three scatterplots overlaid on the same set of axes. All three data sets would have r=1r = 1 even though they all have different slopes.

Line chart titled Figure 12-2: Different Slopes, all with r = 1, showing three sets of points for x from -20 to 20 that each lie exactly on a straight line through (0, 5): circles with slope 1, squares with slope 2, and triangles with slope 0.5; every set has r = 1.
Figure 12-2: Any straight line has r=1r=1.

For the next example in Figure 12-3, r=0r = 0 would indicate no linear relationship; however, there is clearly a non-linear pattern with the data.

Scatterplot titled Figure 12-3: Nonlinear Scatterplot with r = 0 of 41 points on a symmetric downward-opening parabola: from (-20, -30) the points rise to a peak of 50 at x = 0 and fall back to (20, -30); the pattern is clearly curved, and r = 0.
Figure 12-3: A plot of points in a parabola, a non-linear pattern, has r=0r=0.

Figure 12-4 shows a correlation r=0.874r = 0.874, which is pretty close to one, indicating a strong linear relationship. However, there is an outlier, called a leverage point, which is inflating the value of the slope. If you remove the outlier then r=0r = 0, and there is no up or down trend to the data.

Scatterplot titled Figure 12-4: Scatterplot with r = 0.874 of 15 points: 14 form a 7-by-2 grid at x = 1, 1.5, 2, 2.5, 3, 3.5, and 4 with y = 1.5 and y = 2, and one leverage point sits far away at (10, 7).
Figure 12-4: A single outlier can significantly change the value of rr.

Calculating Correlation

To calculate the correlation coefficient by hand we would use the following formula.

Instead of doing all of these sums by hand we can use the output from summary statistics. Recall that the formula for a variance of a sample is sx2=(xix¯)2n1s_{x}^{2} = \frac{\sum \left(x_{i} - \bar{x}\right)^{2}}{n-1}. If we were to multiply both sides by the degrees of freedom, we would get (xix¯)2=(n1)sx2\sum \left(x_{i} - \bar{x}\right)^{2} = (n-1) s_{x}^{2}.

We use these sums of squares (xix¯)2\sum \left(x_{i} - \bar{x}\right)^{2} frequently, so for shorthand we will use the notation SSxx=(xix¯)2SS_{xx} = \sum \left(x_{i} - \bar{x}\right)^{2}. The same would hold true for the yy variable; just changing the letter, the variance of yy would be sy2=(yiy¯)2n1s_{y}^{2} = \frac{\sum \left(y_{i} - \bar{y}\right)^{2}}{n-1}, therefore SSyy=(n1)sy2SS_{yy} = (n-1) s_{y}^{2}.

The numerator of the correlation formula is taking in the horizontal distance of each data point from the mean of the xx values, times the vertical distance of each point from the mean of the yy values. This is time-consuming to find so we will use an algebraically equivalent formula ((xix¯)(yiy¯))=(xy)n·x¯y¯\sum \left(\left(x_{i} - \bar{x}\right) \left(y_{i} - \bar{y}\right) \right) = \sum (xy) - n \cdot \bar{x} \bar{y}, and for short we will use the notation SSxy=(xy)n·x¯y¯SS_{xy} = \sum (xy) - n \cdot \bar{x} \bar{y}.

To start each problem, use descriptive statistics to find the sum of squares.

When is a correlation statistically significant? The next subsection shows how to run a hypothesis test for correlations.

Adapted from Mostly Harmless Statistics by Rachel Webb (Portland State University, https://mostlyharmlessstat.wixsite.com/webpage), © Rachel Webb, licensed under CC BY-SA 4.0. Changes were made. License: CC-BY-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.