Why analyse data this way. Measurements always carry noise, so a fitted number (a slope, a rate, an effect size) is itself uncertain. Good analysis reports the estimate and its uncertainty, and checks that the model is appropriate.
Least squares. For points (xi, yi) the line minimising the sum of squared residuals has b1 = Sxy/Sxx and b0 = &ybar; − b1x̄. With s² = SSE/(n−2) the standard error of the slope is s/√Sxx and the 95 % confidence interval is b1 ± t0.975,n−2 SE. The coefficient of determination is R² = 1 − SSE/SST. The shaded band is the 95 % interval of the mean response, ŷ ± t s √(1/n + (x−x̄)²/Sxx).
Other methods. The Theil-Sen estimator takes the median of all pairwise slopes, so a minority of outliers hardly moves it. The quadratic fit solves the 3×3 normal equations. The bootstrap re-samples your own data with replacement (300 times, 80 for Theil-Sen) and refits; the 2.5 % and 97.5 % percentiles of the estimates form a distribution-free interval. Drag a point (mouse) or tap near one (touch) to see how a single point with high leverage can move a least-squares fit.
Checks on this page. (1) The closed-form OLS slope equals an independent gradient-descent solution; (2) the t-quantile routine (a Cornish-Fisher series) matches textbook table values 2.2281 and 2.0423; (3) over 3000 freshly simulated Gaussian data sets the 95 % interval contains the true slope about 95 % of the time — the defining property of a confidence interval. The check uses ideal Gaussian data; with outliers, fan-shaped noise or the wrong model the real coverage is lower, which you can see by comparing the bootstrap and OLS intervals.
Honest simplifications. The data are synthetic; x is uniform on 0-10 and noise is Gaussian unless you add outliers. Residual flags use a simple 2.5 s rule, not a formal outlier test; there is no p-value, no multiple-comparison correction and no model selection. Correlation shown here is not evidence of causation. The Simpson-paradox example uses an arbitrary group offset.