Correlation and linear regression
Learn one idea at a time
Choose a unit. Each has worked examples and practice.
Read correlation with the scatter
Calculate linear correlation and check the scatter and outliers.
Choose the response and fit a line
Distinguish the two regression directions and their residuals.
Predict in the right direction
Choose the regression line from the modelling setup and check the prediction range.
Transform variables and compare models
Track units and signs, then linearise a nonlinear relationship.
By the end, you can
- Use scatterplots before fitting a line
- Interpret correlation without claiming causation
- Distinguish interpolation, extrapolation and transformed models
4 focused units · about 40 minutes for the full chapter. Allow extra time for practice.
The central idea
Correlation describes linear association, while a regression line predicts a response from an explanatory variable. The least-squares line minimises squared vertical residuals. A strong association does not establish causation. Prediction beyond the observed input range is extrapolation; transformations can reveal a relationship hidden in the original coordinates.
Begin with paired observations
The notes ask about links between GenAI use and examination scores, and between temperature and rainfall intensity. These are questions to investigate, not established conclusions. In the source’s controlled experiment, vary the slope angle through and record a ball’s travel time. The angle is the independent (explanatory) variable, and the travel time is the dependent (response) variable.
When control is impractical, the source proposes observing temperature and sea level each day over ten years. This is observational data collection. The notes use “natural experiments” broadly here; an observational study is not automatically a natural experiment with an externally imposed change. Controlled studies are possible in some settings even in fields mentioned by the source; identify what is actually controlled in the particular investigation.
Bivariate data consist of ordered pairs , such as each person’s age and salary. Each pair must refer to the same observation. The explanatory variable supplies the basis for prediction or study; the response is the outcome observed or predicted. In an observational study the explanatory variable need not be manipulated. Calling a variable “independent” in this role does not assert statistical independence of X and Y.
Try the five source situations before opening their working.
Inspect a scatter diagram
A scatter diagram plots the paired numerical observations, usually with the explanatory variable on the horizontal x-axis and the response on the vertical y-axis. The notes also call it a scatter plot, scatter graph or scatter chart. Inspect:
- Shape: approximately linear, curved (such as the source’s inverted U), or another pattern (such as its loop).
- Direction for a linear pattern: positive/direct means y tends to rise with x; negative/inverse means y tends to fall with x. “Inverse” here describes direction, not a proved reciprocal formula .
- Strength of the linear pattern: tight clustering about a line is stronger than a widely scattered cloud. A strong curved pattern need not have strong linear correlation.
All eight schematic panels from the opening notes are reconstructed in the accompanying figure: three shape examples, two direction examples and three strength examples. They are illustrations, not measured numerical data.
The source uses numerical variables such as height, mass, rates and counts. It contrasts beauty and happiness as not directly numerical. Such concepts can be studied using explicitly defined numerical scores, but a score’s meaning and measurement quality need justification; merely assigning category numbers does not establish a quantitative scale.
For the linear correlation studied here, the source’s sequence is sketch the scatter diagram, then find the correlation coefficient. Plotting first can reveal curvature or unusual observations hidden by a single summary number.
Transfer a calculator plot to a clear sketch
Retain all five source pointers:
- Check the window scale: the origin may not be visible.
- Label both axes and put the explanatory variable horizontally, response vertically.
- Mark the minimum and maximum x and y values.
- Match the number of observations with the number of plotted dots or crosses. Coincident pairs can overlap, so record their multiplicity if needed.
- Preserve relative positions accurately. Graph paper is unnecessary unless requested.
Example 1 retains every data pair and the complete six-step calculator route before describing the observed pattern.
Worked example
For , both sample means are 2.5. A calculator gives for y on x and for x on y, with . The first minimises squared y residuals and the second squared x residuals. At y=3, the reverse fit estimates x as , whereas rearranging the forward line gives . The different estimates reflect different fitting objectives. These are observational predictions, with the response chosen for the modelling task.
Inspect the scatter, residual direction and modelling setup. A large correlation does not establish causation or justify extrapolation, and rearranging a fit does not generally refit the other response.
Check your understanding
An observational dataset has , , , and , where S denotes centred sums. Observed x values span 2 to 8 and y values span 12 to 28. Find both regression lines. Choose the appropriate fitted line to estimate y when x=7 and x when y=24. Compare the latter estimate with rearranging the other line, and assess a prediction at x=20.
The y-on-x slope is , giving , or . The x-on-y slope is , giving , or .
For x=7, the y-response fit estimates y as 24. For y=24, the x-response fit estimates x as 6. Rearranging the forward fit would give , which does not minimise the x residuals. Both requested explanatory values lie inside their respective observed ranges, but interpolation still does not guarantee an accurate individual outcome. At x=20 the forward prediction would be extrapolation and needs additional model justification.
Practice questions
31 examples and practice questions, in 6 sections.
Ready to try this on your own?
For “Correlation and linear regression”, try a question without the working and explain your method. This records your confidence, saved in this browser only.