Regression Equation Calculator

This regression equation calculator finds the least squares line of best fit from your x and y data. You get the equation, correlation, R², a test of the slope, a prediction with intervals and a residual plot.

Separate with commas, spaces or new lines.

Same number of values as x, in the same order.

Checks on your data

  • Only 8 points. A line fitted to so few points is unstable and the R² is easily inflated by chance.
  • x = 10 lies outside your data range (1 to 8). Predictions beyond the data assume the line keeps going and are much less reliable.

Results

Regression equation
ŷ = 1.97857x + 0.171429
Slope b₁
1.97857
95% CI 1.8428 to 2.1143
Intercept b₀
0.171429
95% CI -0.51412 to 0.85698
Correlation r
0.99765
strong positive linear relationship
R² (coefficient of determination)
0.9953
99.53% of the variation in y is explained by x
Adjusted R²
0.99452
Standard error of estimate s
0.35956
typical size of a residual
t statistic for the slope
35.66
df = 6
p-value for the slope
< 0.0001
significant at 5%
F statistic (ANOVA)
1272
p = 3.2414 × 10^-8
Number of points n
8
Means (x̄, ȳ)
4.5, 9.075
Prediction at x = 10
19.9571
95% CI for the mean 19.148 to 20.766
95% prediction interval for a new observation
18.762 to 21.152
Extrapolation warning
x is outside your data range: unreliable
Scatter plot with least squares line (ŷ = 1.97857x + 0.171429, R² = 0.995)
5101520246810xy
Residual plot: a patternless cloud around 0 means the line is a good model
00.52468xresidual
Calculation table
xyFitted ŷResidual
12.32.150.15
24.14.1286-0.028571
35.86.1071-0.30714
48.48.08570.31429
59.710.064-0.36429
612.512.0430.45714
713.614.021-0.42143
816.2160.2
Show step-by-step solution
  1. Means: x̄ = 4.5, ȳ = 9.075. Sxx = Σ(x − x̄)² = 42, Sxy = Σ(x − x̄)(y − ȳ) = 83.1, Syy = 165.195.
  2. Slope b₁ = Sxy ÷ Sxx = 83.1 ÷ 42 = 1.97857.
  3. Intercept b₀ = ȳ − b₁x̄ = 9.075 − 1.97857 × 4.5 = 0.171429.
  4. Equation: ŷ = 1.97857x + 0.171429.
  5. r = Sxy ÷ √(Sxx·Syy) = 0.99765, so R² = 0.9953.
  6. SSE = 0.775714; s = √(SSE ÷ (n − 2)) = 0.35956; SE(slope) = s ÷ √Sxx = 0.055482; t = 35.66.
Equationŷ = b₀ + b₁x
SlopeSxy / Sxx
R²Share of variation explained
CheckResidual plot

What Is Regression Equation?

Simple linear regression fits a straight line y = b₀ + b₁x that minimises the sum of squared vertical distances to the points. The slope b₁ says how much y changes per unit of x and the intercept b₀ is the predicted y at x = 0.

Beyond the equation, the calculator reports the correlation r, R² and adjusted R², the standard error of the slope with its t test, the ANOVA F statistic and a 95 % prediction interval for a new observation. It warns you when a prediction is an extrapolation outside the range of your data.

Below you will find the formulas, a variables table, a worked example and answers to common questions such as correlation versus regression and how to interpret the slope.

How to Use the Regression Equation Calculator

  1. Paste the x values and the y values, in matching order.
  2. Optionally enter an x value to predict y.
  3. Read the equation, then R² and the slope p-value to judge how well and how reliably the line fits.
  4. Check the residual plot for curvature, funnel shapes or outliers before trusting the result.

Regression Equation Formula

Slope

b1=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2=SxySxxb_1=\frac{\sum (x_i-\bar x)(y_i-\bar y)}{\sum (x_i-\bar x)^2}=\frac{S_{xy}}{S_{xx}}

Intercept

b0=yˉ−b1xˉb_0=\bar y-b_1\bar x

Correlation and R²

r=SxySxxSyy,R2=1−SSESST=r2r=\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}},\quad R^2=1-\frac{SSE}{SST}=r^2

Standard error of the slope and t test

SE(b1)=sSxx,t=b1SE(b1), df=n−2SE(b_1)=\frac{s}{\sqrt{S_{xx}}},\quad t=\frac{b_1}{SE(b_1)},\ df=n-2

Prediction interval

y^0±t∗s1+1n+(x0−xˉ)2Sxx\hat y_0\pm t^{*}s\sqrt{1+\frac1n+\frac{(x_0-\bar x)^2}{S_{xx}}}

Regression Equation Variables Explained

SymbolMeaningNotes
b₁SlopeChange in y per unit of x
b₀InterceptPredicted y when x = 0
rCorrelation coefficient−1 to 1
R²Share of variation explainedr² for simple regression
x̄, ȳMeans of x and yThe line passes through (x̄, ȳ)

Regression Equation Worked Example

Using the example values (press “Load example” above to try them):

  1. Means: x̄ = 4.5, ȳ = 9.075. Sxx = Σ(x − x̄)² = 42, Sxy = Σ(x − x̄)(y − ȳ) = 83.1, Syy = 165.195.
  2. Slope b₁ = Sxy ÷ Sxx = 83.1 ÷ 42 = 1.97857.
  3. Intercept b₀ = ȳ − b₁x̄ = 9.075 − 1.97857 × 4.5 = 0.171429.
  4. Equation: ŷ = 1.97857x + 0.171429.
  5. r = Sxy ÷ √(Sxx·Syy) = 0.99765, so R² = 0.9953.
  6. SSE = 0.775714; s = √(SSE ÷ (n − 2)) = 0.35956; SE(slope) = s ÷ √Sxx = 0.055482; t = 35.66.

Result: Regression equation = ŷ = 1.97857x + 0.171429; Slope b₁ = 1.97857; Correlation r = 0.99765; Prediction at x = 10 = 19.9571.

How to interpret the output

Reading regression results
OutputMeaningWhat to look for
Slope b₁Average change in y per unit of xSign and size in context; CI excluding 0 supports a real relationship
Intercept b₀Predicted y at x = 0Meaningful only if x = 0 is plausible
rStrength and direction of the linear relationship|r| above 0.7 is strong
R²Share of variance in y explained by xHigher is better, but context matters
p-value for slopeEvidence the true slope is not 0Below 0.05 is conventionally significant
Standard error sTypical residual size in y unitsCompare with the spread of y

Assumptions and diagnostics

  • Linearity: the relationship is roughly straight. A curved pattern in the residual plot means a different model is needed.
  • Independence: observations do not influence each other (be careful with time series).
  • Constant variance: residuals have about the same spread across x. A funnel shape violates this.
  • Normal residuals: matters mainly for the p-values and intervals with small samples.
  • No influential outliers: a single extreme point can tilt the line. Check the scatter plot.

Prediction and extrapolation

Two intervals are reported. The confidence interval for the mean response says where the average y at that x probably lies. The prediction interval is wider and says where a single new observation will probably fall. Predictions are most reliable near the mean of x and inside the range of your data. Predicting far outside it, extrapolation, assumes the straight-line relationship continues, which is often false.

Correlation is not causation

A strong fit shows that x and y move together, not that x causes y. A hidden third variable may drive both, or the direction may be reversed. Only a well-designed experiment or a careful causal analysis can establish cause.

Where Regression Equation Is Used

Predicting y from x

Using the fitted line to estimate a value for a new x.

Describing a trend

Reporting slope, intercept and R² for a relationship.

Testing the slope

Checking whether the relationship is statistically significant.

Checking residuals

Looking at the residual plot for curvature or unequal spread.

Common Regression Equation Mistakes to Avoid

  • Always plot the data first.
  • Do not extrapolate far beyond your data.
  • A high R² does not prove the model is right; check the residuals.
  • For several predictors use multiple regression in a statistics package.

Regression Equation Terms and Definitions

Residual
Observed y minus the fitted ŷ.
Least squares
Choosing the line that minimises the sum of squared residuals.
Prediction interval
Range likely to contain a single future observation.

Regression Equation FAQs

How do you find the regression equation?

Compute the slope as Sxy/Sxx and the intercept as ȳ − b₁x̄. The calculator shows each step.

What does R² mean?

The proportion of the variation in y explained by the linear relationship with x. R² = 0.8 means 80% is explained.

What is the difference between r and R²?

r is the correlation, between −1 and 1, and shows direction. R² is its square, between 0 and 1, the share of variance explained.

What is a residual plot used for?

To check whether a straight line is appropriate. A random cloud around zero is good; curves or funnels signal problems.

What is the difference between a confidence interval and a prediction interval?

The confidence interval is for the average y at a given x. The prediction interval is for one new observation and is always wider.

Can I use this for non-linear data?

Not directly. Try the curve fitting calculator for polynomial, exponential, power and logarithmic models, or the non-linear regression calculator.

How many data points do I need?

At least 3 are required, but 20 or more give much more reliable results.

Related calculators

Last updated 2026-11-09. See our disclaimer.