Statistics & data
Linear regression
Fit a straight line to paired measurements.
Your measurements
Number formats & units
Use decimal dots in datasets. Single values also accept decimal commas and scientific notation such as 1.2e-3 or 1.2 × 10⁻³.
Calculated locally. No account or uploads.
Result & working
ExampleThe calculator is loading. You can read the worked example below.
Download results
Excel and CSV files can be imported into Google Sheets.
More results
Show calculation steps
Interpretation & assumptions
Copy & export
Formula & example
The relationship
What the variables mean
| Symbol | Meaning |
|---|---|
| Sums of squared deviations of x and y from their means. | |
| Sum of products (xᵢ − x̄)(yᵢ − ȳ). | |
| Sum of squared residuals Σ(yᵢ − ŷᵢ)². | |
| Slope and intercept. Slope units are y-units divided by x-units. | |
| Signed linear correlation and coefficient of determination. |
Worked example
- Data entry
- Two columns: x then y
- Two-column data
- 1 2 2 4 3 5 4 4 5 5
y = 0.6x + 2.2
Follow the example steps
- n = 5; x̄ = 3; ȳ = 4
- Sxx = Σ(xᵢ − x̄)² = 10
- Syy = Σ(yᵢ − ȳ)² = 6
- Sxy = Σ(xᵢ − x̄)(yᵢ − ȳ) = 6
- m = Sxy / Sxx = 6 / 10 = 0.6
- c = ȳ − mx̄ = 4 − (0.6) × 3 = 2.2
- SSE = Σ(yᵢ − ŷᵢ)² = 2.4
- r = Sxy / √(Sxx Syy) = 0.7745967; R² = 1 − SSE / Syy = 1 − 2.4 / 6 = 0.6
- Residual SD sₑ = √(SSE / (n − 2)) = √(2.4 / 3) = 0.8944272
- SE(m) = sₑ / √Sxx = 0.8944272 / √10 = 0.2828427
- SE(c) = sₑ √(1/n + x̄²/Sxx) = 0.8944272 × √(1/5 + (3)²/10) = 0.9380832
Common mistakes
Keep each x paired with the y measured with it.
Incorrect approach
Original pairs (1, 5), (2, 3): sort y alone to get (1, 3), (2, 5).
Correct approach
Keep (1, 5), (2, 3): the fitted gradient is −2.
More checks before you submit
- A fitted intercept is not automatically evidence of a calibration error.
- A high R² can hide curvature or outliers; inspect the graph.
- Keep each x paired with its original y.
- Do not confuse a regression standard error with the max/min-gradient method.
Method notes
Ordinary least squares chooses the line that minimizes squared vertical residuals. It treats x as known and fits an intercept; it does not force the line through the origin or account for x uncertainty.
Coefficient standard errors need at least three points and assume independent errors with constant variance. Confidence intervals require further assumptions and an appropriate t multiplier. Constant y gives a horizontal fitted line, but r and R² are undefined because y has no variation.