Home › Statistics & Probability Calculators › Linear Regression Calculator (With Steps)
Linear Regression Calculator
Simple linear regression fits the straight line ŷ = b₀ + b₁x that minimises the sum of squared vertical distances from the data points. Enter x and y values and the calculator derives the slope and intercept from the sums of squares, lists every fitted value and residual, and computes the standard error of estimate, r², the standard errors of both coefficients, a t-test and confidence interval for the slope, and the F statistic.
You can also enter an x value to predict y, and the tool warns when that x lies outside the range of the data, where extrapolation is unreliable. The step-by-step layout mirrors the hand method taught in statistics courses: means, Sxy, Sxx, slope, intercept, then the residual analysis.
The slope test asks whether x has any linear effect on y at all; a small p-value means the slope is significantly different from zero. Check the residuals for patterns before trusting the line, and view the data first with the scatter plot maker. The correlation coefficient shown here matches the Pearson calculator.
Separate values with commas, spaces or new lines.
Separate values with commas, spaces or new lines.
Result and step-by-step solution
r = 0.9994, r² = 0.9988 (99.9% of the variation in y is explained by x). Standard error of estimate s = 0.1802.
- Meansx̄ = 4.5, ȳ = 9.025 (n = 8)
- Sums of squaresSxy = Σ(x − x̄)(y − ȳ) = 83.9; Sxx = Σ(x − x̄)² = 42; Syy = Σ(y − ȳ)² = 167.795
- Slopeb₁ = Sxy ÷ Sxx = 83.9 ÷ 42 = 1.9976
- Interceptb₀ = ȳ − b₁x̄ = 9.025 − 1.9976 × 4.5 = 0.0357
- Fitted values and residualsSSE = Σ(y − ŷ)² = 0.1948; s = √(SSE ÷ (n − 2)) = 0.1802
x y ŷ residual 1 2.1 2.0333 0.0667 2 3.9 4.031 −0.131 3 6.2 6.0286 0.1714 4 7.8 8.0262 −0.2262 5 10.1 10.0238 0.0762 6 12.2 12.0214 0.1786 7 13.8 14.019 −0.219 8 16.1 16.0167 0.0833 - Goodness of fitr² = 1 − SSE/Syy = 1 − 0.1948/167.795 = 0.9988
- Test of the slopeSE(b₁) = s ÷ √Sxx = 0.0278; t = b₁ ÷ SE(b₁) = 71.8557, df = 6, p = < 0.0001; 95% CI for the slope: 1.9296 to 2.0656
- PredictionAt x = 10: ŷ = 0.0357 + 1.9976 × 10 = 20.0119 (extrapolation: outside the range of the data)
| SE of intercept | 0.1404 |
|---|---|
| F statistic (1, 6) | 5163.2347 |
Frequently asked questions
- How are the slope and intercept calculated?
- Slope b₁ = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)². Intercept b₀ = ȳ − b₁x̄. The line always passes through the point (x̄, ȳ).
- What does r² tell me?
- The fraction of the variation in y explained by the line. r² = 0.9 means 90% of the variation in y is accounted for by its linear relationship with x.
- What is the standard error of the estimate?
- s = √[SSE ÷ (n − 2)], the typical size of a residual. It is the standard deviation of the points around the fitted line.
- Can I use this for prediction outside my data range?
- You can compute it, but the tool flags it as extrapolation. Relationships often stop being linear beyond the observed range.
Last reviewed: September 25, 2026. Calculations run in your browser and were validated against SciPy.
