Linear Regression (slope, intercept, R^2)

Least-squares fitted line (slope, intercept), R^2, residual standard error, the slope t-test with a two-tailed p-value, and an optional prediction at a given x, for paired x / y series. Per OpenIntro Statistics Ch. 8.

Run the calculator

Formula and source

Least squares: slope = sum((x - xbar)(y - ybar)) / sum((x - xbar)^2); intercept = ybar - slope * xbar. R^2 = r^2. Residual sum of squares RSS = Syy - slope * Sxy; residual standard error = sqrt(RSS / (n - 2)). Slope t-test for slope = 0: t = slope / (RSE / sqrt(Sxx)) on n - 2 df, two-tailed p = 2 * (1 - tcdf(|t|, n - 2)). Prediction y-hat = intercept + slope * x.

OpenIntro Statistics 4th ed. Chapter 8 (introduction to linear regression) by name; the Student-t CDF via the regularized incomplete beta function per Numerical Recipes in C 2nd ed. ยง6.4.

Audience

This tile is built for trades and the adjacent professions in the Educators and K-12 group. The interactive calculator runs entirely in your browser. No account, no fee, no advertising, no tracking.

Related tools

Posture

Rough Logic answers the math question the working professional asks on the job. The site is a calm, fast, ad-free, account-free, ever-free reference. It does not interpret code. It does not replace the licensed professional. It does not store your inputs. The Authority Having Jurisdiction governs all installations and inspections.