MicrolearnENPTES

Least squares regression

Lesson 14 of 15 · Stats.Micro

A regression line ŷ = m·x + b predicts y from x. Each point's vertical distance to the line is its residual.

Ordinary least squares (OLS) picks the m and b that minimize the sum of squared residuals (SSE). On the chart, each residual is a square: the best line has the smallest total area. Because of the squaring, a single outlier can pull the whole line.

Spreadsheet trendlines and most first models in economics and science are OLS fits.

Turn on guess mode to fit the line yourself.

Bring your line's SSE within 10% of the least squares SSE.

Check yourself

What does OLS minimize?

The sum of the squared vertical distances from the points to the line

Drag points or click to add data to see the best-fit line update and minimize geometric squared residual boxes.

Click anywhere on the Cartesian plane to insert a new data point.

Drag any point to reposition it and watch the regression line and residual squares automatically rebalance.

Notice how an outlier with high x-leverage pulls the entire regression line toward itself.

The OLS line minimizes the sum of squared vertical differences between observed points yᵢ and fitted predictions ŷᵢ.

Do it in the browser: a real statistics tool, a short mission and instant feedback. No install.

Start this lesson — free
← Bayes factorsCorrelation →

All lessons · Stats.Micro