Skip to content
2x2xKit

Linear Regression Calculator

Find the best-fit line and R² for a set of x/y data points.

How this is calculated
Slope = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²); Intercept = (Σy − slope·Σx) ÷ n

Assumptions used in this calculation

  • Ordinary least squares: Fits the line that minimizes the sum of squared vertical distances from each point (OLS), which weights outliers heavily since errors are squared.

About this calculator

The linear regression calculator finds the ordinary least-squares best-fit line through a set of x/y data points, along with the R² goodness-of-fit measure.

Worked example

5 data points

Result: y = 0.6x + 2.2, R² = 0.6

Was this helpful?

Frequently asked questions