Correlation and linear regression
Bivariate data contain two measurements for each individual or object. If is a person’s height and is their arm span, each person supplies one pair . We use correlation to describe the strength and direction of an association, and regression to model one variable in terms of the other.
These ideas answer different questions:
- correlation asks how closely the points follow a straight line;
- regression asks which straight line should be used to estimate one variable from the other.
Neither, by itself, establishes that one variable causes the other.
Prerequisites
Section titled “Prerequisites”You should be able to:
- plot coordinates and interpret the gradient and intercept of ;
- calculate means and standard deviations;
- use summation notation and calculator statistics modes;
- distinguish a population from a sample.
Review averages and measures of spread if ar x, variance or standard deviation are unfamiliar.
Scatter diagrams
Section titled “Scatter diagrams”A scatter diagram plots one point for each paired observation. The variable thought to explain or predict is usually placed on the horizontal axis and called the explanatory variable. The variable being predicted is placed on the vertical axis and called the response variable.
Look for four features:
- Direction: positive, negative or no apparent association.
- Form: linear, curved, clustered or another pattern.
- Strength: how tightly the points follow the form.
- Unusual observations: outliers or influential points.
In positive correlation, larger values tend to occur with larger values. In negative correlation, larger values tend to occur with smaller values. A strong curved relationship can have weak linear correlation, so always inspect the scatter diagram before relying on one calculated number.
Worked example 1: interpreting a context
Section titled “Worked example 1: interpreting a context”A sample shows a negative association between the age of a used car and its selling price.
A careful conclusion is:
Older cars in this sample tended to have lower selling prices.
This describes association, direction and context. It does not claim that age is the only cause. Mileage, condition and model may also affect price.
If one point represents a very old but unusually expensive classic car, it may be an outlier. Removing it merely to strengthen the pattern would be unjustified. Investigate whether it is an error, a member of a different population, or a genuine observation.
Pearson’s product moment correlation coefficient
Section titled “Pearson’s product moment correlation coefficient”Pearson’s product moment correlation coefficient, usually written , measures the strength and direction of linear association in a sample.
Its interpretation is:
| Value of | Linear association |
|---|---|
| close to | strong positive |
| close to | weak or no linear association |
| close to | strong negative |
| exactly or | perfect linear association |
There are no universal boundaries at which correlation suddenly becomes “strong”. Context and sample size matter. An of may be impressive for noisy biological data but disappointing for repeated measurements from calibrated equipment.
Define the corrected sums of squares and products by
Then
The denominator is positive, so the sign of is the sign of . The division standardises the result, making dimensionless and unaffected by the units used.
Why the formula measures association
Section titled “Why the formula measures association”For a point with and , both deviations are positive, so their product is positive. A point with both values below their means also gives a positive product. These points support positive association.
If one value is above its mean and the other below, the product is negative. Such points support negative association. Adding the products gives ; standardising gives a value between and .
Worked example 2: calculating
Section titled “Worked example 2: calculating rrr”For five students, is the number of hours revised and is a test score.
The required totals are
Therefore
and
Hence
This is impossible, since cannot exceed . The contradiction exposes an arithmetic error: the correct value is
Thus and
That is still impossible, revealing that must also be checked. In fact,
Now , so
There is a very strong positive linear association between revision time and score in this sample. The deliberate checks illustrate an important safeguard: always signals an input or arithmetic error.
Self-check 1
Section titled “Self-check 1”What can you conclude if ?
Answer
There is no measured linear association. You cannot conclude that the variables are unrelated. For example, points lying exactly on and arranged symmetrically about can have despite a perfect curved relationship.
The least squares regression line
Section titled “The least squares regression line”The regression line of on predicts from a given value of . Write it as
where
The gradient is the predicted change in for a one unit increase in . Its units are “units of per unit of ”. The intercept is the predicted when , but it may have no practical meaning if is outside the observed range.
The line always passes through the mean point because
Why it is called least squares
Section titled “Why it is called least squares”For an observed point , the fitted value is
The vertical residual is
The least squares line chooses and to minimise
Residuals are squared so that positive and negative errors cannot cancel. A positive residual means the observed value lies above the line; a negative residual means it lies below.
Worked example 3: finding and interpreting a regression line
Section titled “Worked example 3: finding and interpreting a regression line”Return to the revision data. We found
and the means are
So
and
The regression line of score on revision time is
The gradient predicts an increase of marks for each additional hour of revision. This is an association based on the fitted model, not proof that forcing every student to revise one more hour will raise their score by exactly .
For hours,
The predicted score is about marks. This is an interpolation because lies within the observed range .
For the student who revised for hours, the fitted score is
The observed score was , so the residual is
The model overestimates this score by marks.
Which regression line?
Section titled “Which regression line?”The regression line of on minimises vertical squared residuals and predicts from . If the task is instead to predict from , use the regression line of on :
These are generally different lines. Do not find on and rearrange it to predict . Rearranging preserves the same geometric line, but it does not change which squared residuals were minimised.
Worked example 4: regression in the other direction
Section titled “Worked example 4: regression in the other direction”For the revision data,
and
Thus the regression line of revision time on score is
To estimate revision time for a score of ,
The on line would give hours. The answers happen to be close because the correlation is almost perfect, but only on is appropriate for predicting .
Both regression lines pass through . Their gradients also satisfy
Self-check 2
Section titled “Self-check 2”For a data set, , , and . Find the regression line of on and estimate when .
Answer
Therefore
When ,
Interpolation and extrapolation
Section titled “Interpolation and extrapolation”Interpolation predicts within the range of observed explanatory values. Extrapolation predicts beyond that range.
Interpolation is usually safer because it uses the model where data have actually been observed. Extrapolation assumes the same linear pattern continues into an unobserved region, which may be unrealistic.
Worked example 5: spotting an unsafe prediction
Section titled “Worked example 5: spotting an unsafe prediction”Suppose tree height was measured for ages from to years and the fitted model is
where is age in years and is height in metres.
At ,
This is interpolation and may be reasonable if the scatter diagram supports a linear model.
At , the model predicts m. This is extreme extrapolation. Tree growth does not remain linear for a lifetime, so the numerical calculation is valid but the prediction is not credible.
Even interpolation deserves caution when there is an outlier, a curved pattern, changing variability, or a sample that is not representative of the target population.
Effect of coding and transformations
Section titled “Effect of coding and transformations”Adding a constant to every value, or multiplying every value by a positive constant, does not change . Changing centimetres to metres therefore leaves correlation unchanged. Multiplying one variable by a negative constant reverses the sign of .
The regression coefficients do change with units. If changes from metres to centimetres, a gradient measured per metre must be rescaled to a gradient per centimetre.
A curved relationship can sometimes be transformed into a linear one. For example, if
then
Correlation and regression may be applied to , not blindly to . Learn more in linearising data.
Common misconceptions
Section titled “Common misconceptions”- “A high proves causation.” It shows strong linear association in the data, not a causal mechanism.
- “An near zero means no relationship.” It means little linear association; a curved relationship may remain.
- “The regression line can be used both ways.” Use on to predict , and on to predict .
- “A precise calculator answer is an accurate prediction.” Model suitability and data range matter more than displayed decimal places.
- “An outlier should always be removed.” Remove data only for a defensible reason, such as a confirmed recording error or an explicitly different population.
- “The intercept must have a real interpretation.” It is algebraically necessary but may correspond to an impossible or unobserved input.
Mixed self-check
Section titled “Mixed self-check”A study of six machines gives , , , and , where is machine age in years and is output in units per hour.
- Calculate and interpret it.
- Find the regression line of on .
- Estimate output for a machine aged years.
- Explain one reason why predicting output at age years may be unreliable if observed ages were between and years.
Answers
There is a strong negative linear association between machine age and output in this sample.
- The gradient is
so
The line is
- At ,
units per hour.
- An age of lies far beyond the observed range, so this is extrapolation. The linear trend may not continue that far. The machine might fail, be repaired or be replaced before then.
Exam checklist
Section titled “Exam checklist”Before finishing a correlation or regression question, check that you have:
- used paired observations in the correct rows;
- confirmed that ;
- described association in context without claiming causation;
- selected the regression direction that matches the variable being predicted;
- interpreted the gradient with units and context;
- substituted into the unrounded regression equation;
- considered the observed range before accepting a prediction.
Next steps
Section titled “Next steps”Correlation strength can be judged formally using a hypothesis test. Continue to hypothesis tests for correlation. For broader issues about samples and conclusions, review populations, samples and sampling. For data quality and influential observations, see outliers and cleaning data.