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.
Separate values with commas, spaces or new lines. Both lists need the same count.
Enter data on the left and click Calculate to see results.
Best-Fit Line Equation
Slope (m)
Intercept (b)
R²
Points (n)
Regression Coefficients
| Term | Estimate | Std. error | t | p-value | 95% CI |
|---|
R² Interpretation
Summary Statistics
Std Dev X and Y are population values (÷ n). Std error s = √(SSE ÷ (n − 2)).
Scatter Plot with Regression Line
Step-by-Step Working
Residuals (y − ŷ)
| # | x | y | ŷ | Residual | Residual² |
|---|
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.
| Output | Formula | What it tells you |
|---|---|---|
| Slope b1 | Sxy ÷ 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 r | Sxy ÷ √(Sxx·Syy) | Strength and direction of the linear relationship, −1 to 1 |
| R² | 1 − SSE ÷ SST | Share 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 slope | s ÷ √Sxx | Uncertainty of b1; t = b1 ÷ SE, df = n − 2 |
| SE of intercept | s·√(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 |
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
| Statistic | Formula | Sample data result |
|---|---|---|
| Sums | n, Σ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 r | R² = 1 − SSE ÷ SST | 1 − 4.2857 ÷ 24.8571 = 0.8276, r = 0.9097 |
| Slope SE, t, p | s ÷ √Sxx, b1 ÷ SE, df = n − 2 | 0.1750, t = 4.899, p = 0.0045 |
| Prediction | ŷ = b0 + b1·x | x = 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
- 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.
- Click Calculate to run the least-squares fit.
- 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.
- Check the scatter plot and the residuals table (y − ŷ for each point) for curvature or outliers.
- Open the step-by-step section to see the sums and how the slope, intercept and r are calculated.
- 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.