Linear Regression
Enter data points and see the best-fit line, residuals, and correlation statistics.
why one point can hijack the whole line 🖖
Least squares minimizes the sum of squared residuals, so a point far from the trend is penalized quadratically — it pulls the line toward itself far more than an ordinary point would. Cook's distance measures exactly that: how much the fitted line would shift if one point were removed. A high R² can hide this too — a single influential point can inflate correlation even when the rest of the cloud is nearly uncorrelated. Drag the flagged point outward and watch the slope chase it.
what the best-fit line really does 🖖
The tool draws the single straight line that sits closest to all your dots at once. "Closest" means the smallest total of the squared vertical gaps between each point and the line — those gaps are the residuals shown as little sticks. R² then reports how much of the up-and-down variation in y the line accounts for: R² = 0.8 means the line explains 80% of the spread, leaving 20% unexplained.
swap the axes and the line moves 🖖
Fitting y from x minimizes vertical gaps, but fitting x from y minimizes horizontal gaps — two different lines through the same cloud, even though both pass through the mean point (x̄, ȳ). Multiply their two slopes together and you get exactly r². So the familiar r is the geometric mean of the two regression slopes, and the two lines coincide only when the fit is perfect (r = 1).
Example problems
- Classic trend - Classic positive trend, y˜2x
- Outlier effect - Outlier at (6,30) skews regression
- No correlation - Near-zero correlation, r˜0.1
- Spearman ρ=1 - Perfect monotonic: Spearman ρ=1