The formula
y = a + b·x, with b = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)²
What it means
The regression line is the one that minimises the sum of the squared vertical distances between the points and the line. The slope says how much y changes when x rises by one unit, and the intercept where it crosses the axis. R² measures how much of y's variation x explains, and the standard error of the estimate says, in y's own units, how far off the line is on average.
How to work it out by hand
- Work out the mean of x and the mean of y
- The slope is the covariance divided by the variance of x
- The intercept is the mean of y minus the slope times the mean of x
- To predict, substitute the value of x into y = a + b·x
What is worth knowing
Predicting outside the range of your data — extrapolating — is where regression fails, and it fails silently: the line hands back a perfectly formatted number for an x that looks nothing like anything you measured. The intercept suffers the same way: if your x values run from 20 to 50, the value at x = 0 is an extrapolation and often means nothing. Nor does a high R² guarantee the line is the right model: you have to look at the residuals.