Learn

Scatter Plots, Correlation and Regression

Contents

Here two measurements are taken from each subject instead of one, and the question becomes whether the two move together.

What does a scatter plot show?

A scatter plot draws one dot for each subject, placed by its two measurements: the explanatory variable across and the response variable up. See Scatter Plots.

Each dot is one person: hours practiced across, score up the side. Full lesson: Scatter Plots

Read three things from the cloud of dots before any calculation: the direction (rising or falling), the form (straight, curved or shapeless) and the strength (a tight band or a loose drift).

Correlation is positive when the dots rise together, negative when one measurement climbs as the other falls, and absent when the cloud has no shape. See Correlation.

One climbs while the other falls. That is negative correlation. Full lesson: Correlation
A shapeless cloud is no correlation: one measurement tells you nothing about the other. Full lesson: Correlation
Look at the plot before computing anything. Frank Anscombe's four data sets share identical means, standard deviations, correlation and regression line, yet one is a straight band, one a smooth curve, one a perfect line with an outlier, and one a vertical stack with a single far point.

Now you

What correlation do these dots show?

How do you draw a line of best fit?

The mean point has the mean of the x values as its x-coordinate and the mean of the y values as its y-coordinate. A line of best fit passes through the mean point, with about as many dots above it as below. See Line of Best Fit.

Draw the line through the mean point, with roughly as many dots above it as below. Full lesson: Line of Best Fit

To estimate, go up from the x value to the line and across to the y-axis, or substitute into the equation: y = 0.6x + 2.4 at x = 6 gives 6.

The residual at each point is the measured value minus the value the line predicts. Small residuals with no pattern mean the line fits. Residuals that run high, low, low, low, high mean the data curve, so a curved model fits better. See Choosing Between Two Models.

The gap at each point is the residual: the count minus what the line predicted. Full lesson: Choosing Between Two Models

Reading the line inside the range of the data is interpolation, which the data support. Reading beyond the range is extrapolation, which nothing measured supports. See Interpolation and Extrapolation.

Stretch it out to 20 and that is extrapolation — nothing measured supports it. Full lesson: Interpolation and Extrapolation

A line fitted to heights at ages 5 to 12 predicts a three-meter adult at age 40, and the arithmetic gives no warning.

Now you

A line of best fit is y = 2x. Estimate y when x is 6.

A line of best fit is y = 0.5x. Estimate y when x is 2.

Data that arrives in order

A time series joins readings taken in time order. To see the trend under the ups and downs, compare each low point with the one before it; to allow for the season, compare this July with last July. See Time Series.

It wiggles, yet every dip lands higher than the dip before — under the wiggle, it rises. Full lesson: Time Series

Does correlation mean one thing causes the other?

No. Two measurements can rise together because x causes y, y causes x, a third variable causes both, or the sample is small and the pattern is chance.

The third reason cannot be seen in the data. Ice-cream sales and drownings rise together because hot weather drives both; shoe size and reading ability rise together in children because age drives both. Such a hidden variable is a lurking variable. See Correlation Is Not Causation.

Ice-cream sales and drownings rise together — the dots genuinely climb. Full lesson: Correlation Is Not Causation
Behind both sits a shared cause: hot weather sells ice cream and sends people swimming. Full lesson: Correlation Is Not Causation
Only an experiment rules out a lurking variable, because the experimenter sets the explanatory variable and assigns treatments at random. A study that only observes reports an association, not a cause.

How is correlation measured exactly?

Pearson's product-moment correlation coefficient r converts each measurement to standard deviations from its own mean, multiplies the two converted values for each subject, and averages the products, so r does not depend on the units. See Pearson's Correlation Coefficient.

A subject above both means or below both gives a positive product and a mixed subject a negative one, so the sign of r is the direction. The size of r is the strength, from −1 to 1: every dot on one rising line gives r = 1, and more scatter moves r toward 0.

The same rise with more scatter drops r toward 0. The size of r is the strength. Full lesson: Pearson’s Correlation Coefficient

r judges straight lines only: dots on a tight curve can still give r near 0.

And r judges straight lines only — this tight arch still gives r near 0. Full lesson: Pearson’s Correlation Coefficient

A sample r might be chance. A table gives the critical value r must beat for that sample size at the 5 percent level: ten pairs need 0.632, so r = 0.81 clears it. Falling short shows only that this sample cannot rule out chance. See Critical Values of r.

Ten pairs put the bar at 0.632, and an r of 0.81 clears it comfortably. Full lesson: Critical Values of r

Now you

Which value of r fits these dots best?

When the relationship is not straight

Spearman's rank correlation replaces every value by its rank, its place in size order, and correlates the ranks. Any relationship that rises at every step gives 1, curved or not, and an outlier can move a rank by only a place or two. See Spearman's Rank Correlation.

Ranking turns the curved pattern into a straight line, and two orders that agree perfectly give a rank correlation of 1. Full lesson: Spearman’s Rank Correlation

Non-linear regression fits a curve by the same least-squares rule, and the shape of the data decides between quadratic, cubic, exponential, power and sine. Counts that double every two weeks need an exponential, y = ab^x; the functions and logarithms guide covers that algebra. See Non-Linear Regression.

Fit a quadratic by the same rule and every gap closes: a straight line was the wrong shape for these data. Full lesson: Non-Linear Regression

What is the regression line, and which one?

The least-squares regression line of y on x makes the sum of the squared vertical residuals as small as possible. Residuals above the line are positive and those below negative, so square them before adding, or they cancel. One line makes the total smallest, and it passes through the mean point. See The Least-Squares Regression Line.

Tilt the line and some gaps shrink while others grow. Gaps above and below the line have opposite signs, so square them before adding, or they cancel. Full lesson: The Least-Squares Regression Line

The residuals are vertical because the line predicts y from x. Write it as y = ax + b: a is the change in y per unit of x, and b is y when x is 0.

The line of x on y makes the horizontal residuals smallest and is a different line through the same dots; the two cross at the mean point and coincide only when r is 1 or −1. Use y on x to predict y and x on y to predict x. See The Regression Line of x on y.

Back on the original axes, the fit of x on y is a different line. Full lesson: The Regression Line of x on y

A prediction inside the range of the data is a result; beyond it, a guess. The gradient is a rate for the group, not a promise about one person. See Predicting from a Regression Line.

The coefficient of determination is the share of the variation in y that the line accounts for. If the squared gaps from the mean of y total 18 and the squared residuals total 3.6, the unexplained share is 3.6/18 = 0.2 and R² = 0.8. For a straight line R² = r². A high on the wrong model only says the line follows the points it was given, so look at the residuals too. See The Coefficient of Determination.

here is 0.91, but the residuals still curve, so look at them as well as at . Full lesson: The Coefficient of Determination

Now you

Which total does the regression line of y on x make smallest?

Cost = 8n + 35 was fitted to n items. What is the 35?

The mistakes worth naming

Where this leads next

A claim about a population you did not measure is inference, in the sampling and inference guide. Means and standard deviations are in the averages and spread guide, the other displays in the charts and displays guide, and gradient and intercept in the coordinate geometry guide.

Learn this properly in the app

Math Challenge teaches each lesson above with a drawn scatter plot, a worked calculation and practice questions, in Scatter Plots and Correlation and Correlation and Regression.

Your turn

Three to try — tap what you get.

Points rising from left to right show

A correlation of −0.9 is

Correlation on its own shows

Math ChallengePractice that adapts to you, the whole lesson ladder, and your progress saved.
Start with Math Challenge

Mr. Chalk Practice this lesson in the app