EN
My tools

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.

A header line such as "hours, score" is skipped. Paste two columns straight from a spreadsheet.
Regression equation
ŷ = 4.47619x + 46.8571
Predicted y at x = 10
91.619048
95% CI for the mean 89.2819 to 93.9562 · 95% prediction interval 88.1658 to 95.0723 · outside the observed x range, so this is an extrapolation
Slope (b)
4.47619
Intercept (a)
46.857143
Pearson correlation r
0.996174
R² (coefficient of determination)
0.992363
99.24% of the variation in y is explained by x
Standard error of the estimate
1.038925
√(SSE ÷ (n − 2))
Standard error of the slope
0.16031
Standard error of the intercept
0.809524
t statistic for the slope
27.9222
H₀: slope = 0, df = 6
p-value for the slope
1.396 × 10⁻⁷
two-tailed
95% confidence interval for the slope
4.08393 to 4.86845
Number of points
8

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.

Residuals (y − ŷ)
  • y
  • Fitted ŷ
Residuals (y − ŷ): y, Fitted ŷ50607080902468x
Residuals (y − ŷ)
#xyFitted ŷResidual
115251.33330.666667
225555.8095-0.809524
336160.28570.714286
446464.7619-0.761905
557069.23810.761905
667273.7143-1.7143
777978.19050.809524
888382.66670.333333
My tools →
Advertisement

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

  1. Paste or type one x, y pair per line (two spreadsheet columns work).
  2. Optionally enter an x value to predict y for, and choose the confidence level.
  3. Read the equation, r and R², then the slope's p-value.
  4. 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:

Cite or embed this tool
APA

kakaoCalc. (2026, November 9). Linear Regression Calculator (Line of Best Fit & Correlation). https://kakao.mobile/tools/linear-regression-calculator/

MLA

“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

Advertisement