# Linear Regression Slope Calculator

> Fit a least-squares line to x and y data and get the slope with its standard error, t statistic, two-sided p-value and confidence interval.

Category: Statistics & probability · Applies to: Worldwide · Last updated: 2026-10-29
Interactive calculator: https://calculators.geekmidst.com/calculators/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.

## Inputs
- X values (predictor) (default 1, 2, 3, 4, 5)
- Y values (response, same order) (default 2, 4, 5, 4, 5)
- Confidence level (unit %; default 95)

## Results
- Slope (b₁)
- 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)

## Formula

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

Where:
- 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.

**Result:** 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.

## Related calculators
- [Linear Regression Intercept Calculator](https://calculators.geekmidst.com/calculators/linear-regression-intercept-calculator)
- [R-Squared Calculator](https://calculators.geekmidst.com/calculators/regression-r-squared-calculator)
- [Pearson Correlation Calculator](https://calculators.geekmidst.com/calculators/pearson-correlation-calculator)
- [P-value Calculator](https://calculators.geekmidst.com/calculators/p-value-calculator)

Source: GM¹X CalcVerse — https://calculators.geekmidst.com/calculators/linear-regression-slope-calculator
