Simple linear regression, step by step
6 min read
Short answer
The least-squares line minimizes the sum of squared vertical errors. Its slope is and its intercept is . is the fraction of the variation in explained by the line.
Interpreting the numbers
The slope is the predicted change in for a one-unit increase in . The intercept is the predicted at , which may be outside the data and meaningless. The correlation and for simple regression.
Why this line
Setting the derivatives of with respect to and to zero gives the formulas above. The same result comes from projecting the vector of values onto the span of the constant and vectors (least squares in linear algebra).
Worked example
Fit a line to and predict at .
, . and , so , . Prediction at : . Also , so and .
Try it yourself
If for a fitted line, what is and what does it mean?
Show the answer
: the line explains 36% of the variation in . The negative sign of only tells you the slope is negative.
Keep going with practice
Vidi's linear algebra lessons show regression as an orthogonal projection, the geometry behind R².