Opening your learning space
Starting the app …
Opening your learning space
Starting the app …
Linear regression places the line of best fit through a scatter plot so that the sum of the squared deviations becomes minimal.
Free to browse · flashcards or a multiple-choice quiz · import from Essential
Formula
b in y-unit per x-unit · a in y-unit · r dimensionless (−1 to 1)
| Symbol | Meaning | Unit |
|---|---|---|
| Slope of the regression line | y unit/x unit | |
| y-intercept of the regression line | y unit | |
| x̄, ȳ | Means of the x and y data | same as the data |
| Correlation coefficient (strength of the linear relationship) | dimensionless |
b = \frac{\sum (x_{i}-\bar{x})(y_{i}-\bar{y})}{\sum (x_{i}-\bar{x})^{2}}, \quad a = \bar{y} - b\bar{x}Original schematic by Quanta
Free with a Quanta account. Your download stays ready after registration.
Method of least squares, published by Legendre in 1805 and used by Gauss to determine the orbit of the dwarf planet Ceres. The regression line always passes through the centroid (x̄|ȳ) of the data. The correlation coefficient r measures only the strength of the linear relationship: r near ±1 means tight coupling, r near 0 no linear relationship. Correlation does not prove causation, and predictions far outside the data are unreliable.
Meaningful only if the relationship is approximately linear (check the scatter plot); outliers distort the line strongly, and predictions are valid only within the data range.
Minimize the sum of the squared vertical deviations from the line.
Intercept
Follows from the line passing through (x̄|ȳ).
Correlation coefficient
Measures the strength of the linear relationship (−1 to 1).
Slope via r
Connection between correlation and standard deviations.
Determine the regression line for (0|1), (1|3), (2|5).
x̄ = 1, ȳ = 3.
Numerator: , denominator: .
, : ŷ = 2x + 1.
All points lie exactly on it .
For (1|2), (2|3), (3|5), (4|6) we have ŷ = 1.4x + 0.5. Predict y for and judge the fit.
ŷ(5) = 1.4·5 + 0.5 = 7.5.
Fit: , a very tight linear relationship; the prediction is only slightly outside the data and acceptable.
Interpreting correlation as causation.
r only measures co-movement; statistics does not say whether x causes y.
Extrapolating far outside the data range.
The linear trend holds only in the observed range; outside it the model can break.
Swapping the roles of x and y.
Regressing y on x minimizes vertical y-deviations; swapped roles give a different line.
Formula cluster
Connects means, spread and linear functions into a data model.
Points (1|2), (2|3), (3|5), (4|6): and . and , so . Prediction for : .
Trend forecasts from measurement series (climate and sales data), statistics tasks with graphing calculators, calibration lines in the sciences, social research
Here is how to work through a typical Linear Regression (Line of Best Fit) (ŷ = a + b·x) task step by step:
Task
Determine the regression line for (0|1), (1|3), (2|5).
Solution path
x̄ = 1, ȳ = 3.
Numerator: , denominator: .
, : ŷ = 2x + 1.
All points lie exactly on it .
Task
For (1|2), (2|3), (3|5), (4|6) we have ŷ = 1.4x + 0.5. Predict y for and judge the fit.
Solution path
ŷ(5) = 1.4·5 + 0.5 = 7.5.
Fit: , a very tight linear relationship; the prediction is only slightly outside the data and acceptable.
In four steps. First determine the means x̄ and ȳ. Second compute for each data point the deviation products (xi − x̄)(yi − ȳ) and the squares (xi − x̄)2. Third b = sum of products / sum of squares. Fourth a = ȳ ̄. Example with (0|1), (1|3), (2|5): x̄ = 1, ȳ = 3; products: ; squares: ; so , and ŷ = 2x + 1. Check: the line must pass through (x̄|ȳ), here ✓. A table with columns for xi, yi, deviations and products keeps the calculation tidy.
r measures strength and direction of the linear relationship between two quantities and always lies between −1 and +1. means all points lie exactly on a rising line; exactly on a falling one. Values near 0 mean no linear relationship. Rough school reading: |r| from about 0.8 strong, around 0.5 moderate, below 0.3 weak. Two warnings: first, r measures only LINEAR coupling; a perfect parabola can yield although a clear relationship exists (look at the scatter plot!). Second, even says nothing about cause and effect. Example: for (1|2), (2|3), (3|5), (4|6), , an almost perfect linear trend.
For three reasons. First the sign problem: positive and negative deviations would cancel each other when simply summed; a line could look perfect "on average" and still be far from all points. Squares are always positive. Second the weighting: squaring penalizes large outliers disproportionately, pulling the line towards points that would otherwise be missed badly. Third the mathematics: the sum of squares is differentiable, and setting the derivatives to zero yields unique closed formulas for a and b; with absolute values instead of squares there would be no such smooth solution. The price: single extreme outliers can tilt the line noticeably, so inspect the scatter plot first.
Within the data range (interpolation) yes, with judgement: for x-values between the observed data, ŷ = a + bx gives usable estimates when |r| is high. Example: ŷ = 1.4x + 0.5 from data with x from 1 to 4 may safely be evaluated at . Extrapolation far beyond is critical: the linear trend is only supported within the observed range; outside it the relationship may flatten, tip over or break entirely. A classic: children's growth data extended linearly to age 30 yields absurd body heights. Exams expect exactly this assessment: compute the prediction AND judge its reliability based on data range and r.
No, correlation is not causation. r only measures that two quantities vary together, not why. Often a third quantity is behind it (confounder): ice cream sales and sunburn cases correlate strongly, but the cause of both is sunny weather. The direction can also be unclear (does x influence y or vice versa?), and in small data sets high correlations even arise by chance. The sound approach: the regression describes the relationship and allows predictions; causal claims additionally require an experiment with controlled conditions or at least a plausible mechanism. In exam answers the sentence "a high r-value does not prove a causal relationship" is almost always a required assessment element.
Quanta exam set
Curated exam set for "Linear Regression (Line of Best Fit)":
Question (front)
Which formula describes Linear Regression (Line of Best Fit)?
Answer in your set
Question (front)
How do you rearrange Linear Regression (Line of Best Fit) for Intercept?
Answer in your set
Question (front)
Which common mistake happens with Linear Regression (Line of Best Fit)?
Answer in your set
+ 7 more cards: units, variables, derivation, example, exam task
The formula set contains 10 cards. After importing, review them and start practicing; your ratings determine later review intervals.
This list names subject references and further reading. A page or section number appears when it is part of the reference; these are not verbatim quotations.
Create a curated FSRS exam set for ŷ = a + b·x: formula recall, variables, derivation, rearrangement, worked example, common mistakes and exam context.
Curated formula set · LaTeX · FSRS spaced repetition · import from Essential