Linear Regression Calculator (Line of Best Fit & Correlation)
Paste x,y pairs to get the least-squares line of best fit, Pearson r, R², standard errors, the slope t-test with p-value, residuals and a prediction.
Least squares assumes a straight-line relationship, independent observations and residuals with constant spread and a roughly normal shape. Look at the residual column: a curved or funnel-shaped pattern means the line is the wrong model.
Correlation is not causation: a strong r only says the points lie close to a line.
- y
- Fitted ŷ
| # | x | y | Fitted ŷ | Residual |
|---|---|---|---|---|
| 1 | 1 | 52 | 51.3333 | 0.666667 |
| 2 | 2 | 55 | 55.8095 | -0.809524 |
| 3 | 3 | 61 | 60.2857 | 0.714286 |
| 4 | 4 | 64 | 64.7619 | -0.761905 |
| 5 | 5 | 70 | 69.2381 | 0.761905 |
| 6 | 6 | 72 | 73.7143 | -1.7143 |
| 7 | 7 | 79 | 78.1905 | 0.809524 |
| 8 | 8 | 83 | 82.6667 | 0.333333 |
Linear regression finds the straight line that best describes how y changes with x, by minimising the sum of squared vertical distances from the points to the line. Paste your x, y pairs to get the line of best fit, the Pearson correlation r, R², standard errors, a t-test of whether the slope differs from zero, residuals and a prediction with its confidence and prediction intervals.
How to use this tool
- Paste or type one x, y pair per line (two spreadsheet columns work).
- Optionally enter an x value to predict y for, and choose the confidence level.
- Read the equation, r and R², then the slope's p-value.
- Check the residual table and the chart for curves or outliers before trusting the line.
Formula
b = Sxy ÷ Sxx · a = ȳ − b·x̄ · r = Sxy ÷ √(Sxx·Syy) · s = √(SSE ÷ (n − 2)) · SE(b) = s ÷ √Sxx · t = b ÷ SE(b)
Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)², Sxy = Σ(x − x̄)(y − ȳ) and SSE = Σ(y − ŷ)². The t statistic has n − 2 degrees of freedom. The confidence interval for the mean response at x₀ uses s√(1/n + (x₀ − x̄)²/Sxx); the prediction interval for a single new point adds 1 under the square root.
Example
Study hours 1 to 8 against exam scores 52, 55, 61, 64, 70, 72, 79 and 83 give ŷ = 4.47619x + 46.8571: each extra hour adds about 4.5 points. r = 0.9962 and R² = 0.9924, and the slope's p-value is 1.396 × 10⁻⁷. At x = 10 hours the predicted score is 91.62, an extrapolation beyond the data.
Frequently asked questions
What is the difference between r and R²?
r measures the direction and strength of the straight-line relationship, from −1 to 1. R² is r squared for simple regression: the share of the variation in y that the line explains.
Why does the prediction interval look so wide?
A confidence interval covers the average y at that x; a prediction interval must also cover the scatter of a single new observation around that average, so it is always wider.
Can I fit a curve instead?
Not here. For an exponential or power relationship, a common trick is to regress log(y) on x or log(y) on log(x) and transform back, but check the residuals afterwards.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/linear-regression-calculator/
Cite or embed this tool
kakaoCalc. (2026, November 9). Linear Regression Calculator (Line of Best Fit & Correlation). https://kakao.mobile/tools/linear-regression-calculator/
“Linear Regression Calculator (Line of Best Fit & Correlation).” kakaoCalc, 9 Nov. 2026, kakao.mobile/tools/linear-regression-calculator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms