What Is Linear Regression?
Linear regression is a statistical technique that finds the straight line which best fits a set of data points. The "best" line minimises the total squared distance from each data point to the line — this is the least squares criterion.
It answers the question: Given a set of data, what linear relationship best describes the trend?
Regression Playground
Learning Goals: By the end of this guide, you should be able to:
- Calculate the equation of the least squares regression line from data.
- Interpret the slope and intercept in context.
- Understand and calculate the correlation coefficient and .
- Use residuals to assess how well the model fits.
The Least Squares Regression Line
For a dataset of points , the line of best fit is:
where the slope and intercept are:
Here and are the means of and respectively.
Key property: The regression line always passes through the point .
Correlation Coefficient
The Pearson correlation coefficient measures the strength and direction of the linear relationship:
| Value of | Interpretation |
|---|---|
| Perfect positive linear relationship | |
| Strong positive correlation | |
| Weak to moderate positive correlation | |
| No linear correlation | |
| Negative correlation (analogous ranges) |
The coefficient of determination tells you the proportion of variation in explained by the model.
Worked Example
Data:
Step 1: Compute the sums: , , , , .
Step 2: Slope:
Step 3: Intercept: , , so
Answer:
Residuals
A residual is the difference between an observed value and the predicted value:
- Positive residual: the point is above the line
- Negative residual: the point is below the line
- If the model fits well, residuals should be randomly scattered around zero with no visible pattern.
Common Mistakes
- Extrapolating beyond the data range — The regression line is only reliable within the range of your data. Predicting far outside this range is unreliable.
- Confusing correlation with causation — A strong value means the variables are associated linearly, NOT that one causes the other.
- Using a linear model for non-linear data — Always plot the data first. If the scatter plot shows curvature, a linear model is inappropriate.
Exam Tips (A-Level / AP / IB)
- For a quick sanity check, the slope should have the same sign as .
- In context questions, always interpret the slope: "For each additional unit of , increases/decreases by units on average."
- When asked about the reliability of a prediction, mention whether the predicted value is within the data range (interpolation) or outside it (extrapolation).
Frequently Asked Questions
When should I use on vs on regression?
Use on () when you want to predict from a known . Use on when predicting from known . The two lines are generally different unless .
What if my data has outliers?
Outliers can dramatically affect the regression line. Consider whether the outlier is a genuine data point or an error. Report results both with and without the outlier for transparency.
Related Topics
- Probability Distributions — The normal distribution underlies many regression assumptions.
- Sequences & Series — Summation notation is the language of regression formulas.
- Derivative Applications — The least squares method is derived by minimising a function using calculus.