Statistics & Probability ★☆☆ Beginner

📈 Linear Regression — OLS Least Squares

Click the canvas to add data points. The least-squares regression line updates instantly. Drag points to see how outliers affect slope and R².

Datasets:
Slope (m)
Intercept (b)
R² (fit quality)
Pearson r
0
Points (n)
SSE (residuals²)
y = m·x + b   (add at least 2 points)

Ordinary Least Squares (OLS)

OLS minimises the sum of squared vertical distances from each point to the line. The unique solution is:

m = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²  ·  b = ȳ − m·x̄

(coefficient of determination) measures the fraction of total variance explained by the line: R² = 1 − SSE/SST. R² = 1 is a perfect fit; R² = 0 means the line explains nothing.