Linear Regression Slope Calculator

The slope of the least-squares line says how much y changes, on average, for each one-unit increase in x. Its standard error and interval show how precisely the data pin it down.

Also called: Least-squares slope calculator · Line of best fit slope

  • Last updated
  • Formula tested against reference values

Your numbers

At least 3 values.

Result

Slope (b₁)
—

Calculating…

Standard error of the slope
—
t statistic (n − 2 df)
—
p-value (two-sided)
—
p-value and hypothesis
—
Confidence interval for the slope
—
Intercept (b₀)
—
Fitted line
—
Pairs (n)
—

How to use this calculator

  1. Enter or choose x values (predictor).
  2. Enter or choose y values (response, same order).
  3. Enter or choose confidence level.
  4. The slope (b₁) updates as you type. Use Copy result or Share to keep it.

Method

b₁ = Sxy ÷ Sxx; b₀ = ȳ − b₁x̄; s² = SSE ÷ (n − 2); SE(b₁) = √(s² ÷ Sxx); t = b₁ ÷ SE; CI = b₁ ± t*·SE

Sxy
Σ(x − x̄)(y − ȳ)
Sxx
Σ(x − x̄)²
SSE
sum of squared residuals
t*
two-sided t critical value with n − 2 df

Worked example

  1. Sxy = 6 and Sxx = 10, so b₁ = 0.6; b₀ = 4 − 0.6 × 3 = 2.2.
  2. Residuals −0.8, 0.6, 1, −0.6, −0.2 give SSE = 2.4 and s² = 2.4 ÷ 3 = 0.8.
  3. SE = √(0.8 ÷ 10) = 0.2828; t = 2.121 with 3 df, two-sided p = 0.124; 95% CI = 0.6 ± 3.182 × 0.2828.

Each extra unit of x adds 0.6 to y on average, but with five points the 95% interval (−0.30 to 1.50) still includes zero.

What the result means

The slope is in units of y per unit of x. A confidence interval that excludes 0 corresponds to a two-sided p-value below 1 − confidence. A significant slope shows association in this range of x; do not extrapolate far beyond the data.

Assumptions and limits

  • Ordinary least squares: the relation is linear, residuals are independent with constant variance and roughly normal.
  • x is measured without important error.
  • The test is two-sided, H₀: slope = 0.
  • Outliers and high-leverage points can dominate the fit; check a residual plot.
  • One predictor only; multiple regression needs a matrix method.

Questions

How is the slope related to the correlation?

b₁ = r × (s_y ÷ s_x). The slope keeps the units; r is unit-free.

Why use n − 2 degrees of freedom?

Two parameters (slope and intercept) are estimated from the data before measuring the scatter around the line.