Linear Regression Calculator

Paste two columns of X and Y values (or separate X and Y lists) to get the regression line ŷ = b0 + b1x, the slope and intercept with standard errors, t, p-value and 95% CI, r and R², every residual, a scatter plot with the fitted line and the step-by-step sums.

Simple linear regression fits ŷ = b0 + b1·x by least squares: the slope is b1 = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²) and the intercept is b0 = ȳ − b1·x̄.

Use the Linear Regression Calculator

Enter X, Y Data

Paste two columns from Excel or Sheets, or type x, y per line. A header row is skipped.

Enter data on the left and click Calculate to see results.

Regression output — formulas and meaning

Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)², Sxy = Σ(x − x̄)(y − ȳ), SSE = Σ(y − ŷ)², SST = Syy. Tests use the t distribution with n − 2 degrees of freedom.

OutputFormulaWhat it tells you
Slope b1Sxy ÷ Sxx = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²)Change in ŷ per 1-unit increase in x
Intercept b0ȳ − b1·x̄Predicted y when x = 0
Pearson rSxy ÷ √(Sxx·Syy)Strength and direction of the linear relationship, −1 to 1
R²1 − SSE ÷ SSTShare of the variance in y explained by x
Adjusted R²1 − (1 − R²)(n − 1) ÷ (n − 2)R² penalised for the number of predictors
Standard error of estimate s√(SSE ÷ (n − 2))Typical size of a residual, in y units
SE of slopes ÷ √SxxUncertainty of b1; t = b1 ÷ SE, df = n − 2
SE of intercepts·√(1/n + x̄² ÷ Sxx)Uncertainty of b0; t = b0 ÷ SE
95% prediction intervalŷ ± t·s·√(1 + 1/n + (x − x̄)² ÷ Sxx)Range for one new y at that x
Copied!

Quick answer

Simple linear regression fits ŷ = b0 + b1·x by least squares: the slope is b1 = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²) and the intercept is b0 = ȳ − b1·x̄. For the sample data (1,2), (2,4), (3,5), (4,4), (5,6), (6,8), (7,7) the line is ŷ = 1.7143 + 0.8571x, with r = 0.9097, R² = 0.8276, slope standard error 0.1750, t = 4.899 and two-sided p = 0.0045 on 5 degrees of freedom. The slope is the change in y for each 1-unit increase in x; R² is the share of the variance in y the line explains.

Examples

StatisticFormulaSample data result
Sumsn, Σx, Σy, Σxy, Σx²n = 7, Σx = 28, Σy = 36, Σxy = 168, Σx² = 140
Slope b1(nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²)(7·168 − 28·36) ÷ (7·140 − 28²) = 168 ÷ 196 = 0.8571
Intercept b0ȳ − b1·x̄5.1429 − 0.8571·4 = 1.7143
R² and rR² = 1 − SSE ÷ SST1 − 4.2857 ÷ 24.8571 = 0.8276, r = 0.9097
Slope SE, t, ps ÷ √Sxx, b1 ÷ SE, df = n − 20.1750, t = 4.899, p = 0.0045
Predictionŷ = b0 + b1·xx = 8 → ŷ = 8.5714

Paste your X and Y columns from a spreadsheet and click Calculate to get your own line, statistics, residuals and plot.

Summary

This linear regression calculator applies ordinary least squares to find the straight line ŷ = b0 + b1x that best fits your data. Paste two columns straight from a spreadsheet (a header row is skipped) or enter X and Y as separate lists. Along with the equation it reports the standard error, t statistic, two-sided p-value and 95% confidence interval for the slope and the intercept, Pearson r, R² and adjusted R², the standard error of the estimate, a residuals table, a scatter plot with the fitted line, and the sums Σx, Σy, Σxy and Σx² so you can check the working by hand. You can also predict y for any x with a 95% prediction interval.

How it works

  1. Paste your data as X,Y pairs, one per line (comma, tab, space or semicolon), or switch to "Separate X and Y lists". A text header row is ignored.
  2. Click Calculate to run the least-squares fit.
  3. Read the equation, slope, intercept, R² and the regression table: each coefficient has a standard error, t, p-value and 95% confidence interval on n − 2 degrees of freedom.
  4. Check the scatter plot and the residuals table (y − ŷ for each point) for curvature or outliers.
  5. Open the step-by-step section to see the sums and how the slope, intercept and r are calculated.
  6. Enter an X value in the prediction box to get ŷ with a 95% prediction interval.

Use cases

  • Statistics homework that asks for the regression equation, r, R² and the working.
  • Testing whether a slope is significantly different from zero (t-test and p-value).
  • Fitting a calibration line (concentration vs signal) and checking residuals.
  • Forecasting sales, costs or demand from a single predictor.
  • Checking a spreadsheet LINEST or SLOPE/INTERCEPT result.
  • Exploring the relationship between two measurements in a lab report.

Frequently Asked Questions

Last updated: 2026-10-10 · Reviewed by Nham Vu