Simple regression
- Read it, not yetReach the end of the page
- Practice it, not yetAnswer a few questions
- Master it, not yet80% on a drill of 8 or more
Regression fits the line with the smallest squared misses. Slope: how much y moves per unit of x. R²: the share of y's variation explained. t-test: does x help?
Why it matters
Regression draws the best straight line through a cloud of points, so x can predict y.
It turns “these move together” into a number: each extra unit of x is worth this much y.
- PricingHow much demand drops for every $1 of price.
- MarketingSales per $1,000 of ad spend, with care about cause and effect.
- Real estatePrice per extra square foot.
Everyday example
Does advertising move sales? Six weeks give Sales = 1.43 + 1.14 Adv: each extra unit of ads adds about 1.14 units of sales. R² = 87.1%: the line explains most of the scatter. t = 5.19 (p = 0.007): not luck.
Least squares: six weeks of data plus one point you control
Base line (dashed): Sales = 1.43 + 1.14 Adv, R² = 87.1%. Tick the box to add a point you control.
Check yourself
Σx = 24, Σy = 36, Σxy = 176, Σx² = 124, n = 6. Slope?
1.143(6 · 176 − 24 · 36) / (6 · 124 − 24²) = 192 / 168.Intercept?
1.429ȳ − b₁ = 6 − 1.143(4).Predict sales at 8 units of advertising?
10.571.429 + 1.143 × 8.
The trap
The mistake people make most on this one.
Correlation is symmetric; regression is not. Swap x and y and you get a different line. Never predict outside the x range you have.
Formulas
7 formulas and a way to remember them.
- Line
- ŷ = b₀ + b₁x
- Slope
- b₁ = [nΣxy − ΣxΣy] / [nΣx² − (Σx)²]
- Intercept
- b₀ = ȳ − b₁
- Fit
- SST = SSR + SSE, R² = SSR / SST = 1 − SSE / SST
- Residual SD
- s = √(SSE / (n − 2))
- Slope test
- t = b₁ / SE(b₁), df = n − 2
- Correlation
- r = ±√R², with the sign of the slope
- Remember it
- Slope is rise over run. R² is how much scatter the line explains. The t-test asks: is the slope really nonzero?
Watch and go deeper
3 free videos and pages.
- StatQuest: Linear Regression, Clearly ExplainedLeast squares, R squared, and the p-value for R squared from the F distribution, step by step. Watch it before you start regression. About 27 minutes.
- jbstatistics: Inference on the Slope (The Formulas)The t test and confidence interval for the slope, and where the standard error comes from. About 7 minutes.
- Seeing Theory: Regression AnalysisDrag points and watch the least squares line chase them. About 10 minutes.