Scatter plots, correlation and least-squares regression
MathematicsStatisticsAges 15–16
How do you mainly use this simulation?
Use it with your class: students open it from a link or a QR code, with no account needed.
Drag, add or delete points, or paste a table of bivariate data, and see Pearson's r, Spearman's rank coefficient, the least-squares lines (y on x and x on y) and the residual plot update at once. Other screens show high-leverage and influential points, the risks of extrapolation, and a lurking variable that removes or reverses a correlation. A Covariance screen shades each point's rectangle (x − x̄)(y − ȳ) about the mean point and shows how cov, divided by s_x·s_y, gives r without units.
Lesson: Scatter diagrams, correlation and linear regression; covariance
What it shows
Each point is a pair (x, y). Pearson's r measures how closely the points follow a straight line, from −1 to 1; Spearman's rₛ is r computed on the ranks. The least-squares line of y on x minimises the sum of squared residuals and passes through (x̄, ȳ). On Covariance, each point's rectangle (x − x̄)(y − ȳ) is positive or negative by quadrant; their sum divided by n or n − 1 is cov, in units of x times y, and cov ÷ (s_x·s_y) gives r, which has no units. Most data sets are simulated; Anscombe's quartet is the published set, and the heights are rounded WHO medians.
How to use
On Explore, choose a Dataset and drag points with Move points, or use Add point and Delete point; open Data table (editable) to paste your own values. On Influential points, drag the red point far to the right. On Predict, move Predict at x = beyond the data and tick Show ages 13–18. On Lurking variable, tick Colour by group. On Covariance, choose n or n − 1 under Divide by, tap a point to see its rectangle, and press Record.
Parameters you can change
- Screen Explore, Influential points, Predict, Lurking variable, Covariance
- Dataset (Explore screen) Height and arm span (simulated), Revision time and test score (simulated), Shoe size and maths score (simulated), Height of a ball over time, Bacteria over time (simulated), Anscombe's quartet I, Anscombe's quartet II, Anscombe's quartet III, Anscombe's quartet IV, Empty (add your own points)
- Model Linear ŷ = bx + a, Exponential ŷ = A·eᵏˣ (via ln y)
- Show regression line
- Show regression line of x on y
- Show residual plot
- Age to predict (Predict screen) 0–30 years
- Show data for ages 13–18 (Predict screen)
- Lurking variable example Ice cream sales and sunburn, Study time and exam score by course
- Colour by group (Lurking variable screen)
- Divisor for cov and s (Covariance screen) n (population), n − 1 (sample)
Questions to explore
- Why does the ball data show a clear relationship although r is close to 0?
- Where must you drag the red point to change the regression line the most, and why?
- Is it sensible to use the regression line to predict a person's height at age 30?
- Why does r stay the same when cov is divided by n instead of n − 1?