# Inference for the slope

To test whether x really predicts y, test H0: true slope = 0. The statistic is t = b1 / SE(b1) with n - 2 degrees of freedom, where SE(b1) = s / square root of Sxx and s = square root of (residual SS / (n - 2)).

Statistics (university) · Part 08: Correlation and regression · Card 7 of 9 · Last updated 2026-10-19

## Analogy

It asks whether the slope you found is bigger than the wobble you would expect from a line fitted to pure noise.

## Example

**Testing the slope**

Residual SS = 2.4, n = 5
s = square root of (2.4 / 3) = 0.894
SE = 0.894 / square root of 10 = 0.283
t = 0.6 / 0.283 = 2.12, df = 3
p about 0.12: not significant

## In practice

Tells you if a link is real or could be a fluke of a small sample.

## Practice

### Flashcards

- **Degrees of freedom for the slope t test?** n minus 2.

## Questions people ask

### Why does the slope test use n minus 2 degrees of freedom?

Fitting the line uses two estimated numbers, the intercept and the slope, so two degrees of freedom are used up. That leaves n minus 2 to estimate the error spread. With 5 points that leaves just 3, so evidence is weak.

### How do I build a confidence interval for the slope?

Take the slope plus or minus the critical t value times the standard error, using n minus 2 degrees of freedom. If the interval excludes zero, the slope test is significant at the matching level. The interval also shows how large the effect might be.

## Related concepts

- [Least squares regression line](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-8/statistics-university-part-8-concept-2)
- [Slope and intercept](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-8/statistics-university-part-8-concept-3)
- [Residuals](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-8/statistics-university-part-8-concept-4)
- [R-squared](https://studyvisually.com/learn/science/statistics-university/statistics-university-part-8/statistics-university-part-8-concept-5)

Web page: https://studyvisually.com/learn/science/statistics-university/statistics-university-part-8/statistics-university-part-8-concept-7
Study this card in the app: https://studyvisually.com/app/learn?category=statistics-university&card=statistics-university-part-8-concept-7
