Statistics & Probability · Grade 12 and undergraduate

Inference for Regression: Testing and Estimating the Slope

Quick answer

A least-squares line from a sample estimates the true line y = α + βx for the whole population. Its slope b varies from sample to sample, with standard error SE_b = s/(s_x√(n − 1)), where s is the typical size of a residual. To test whether there is any linear relationship, test H₀: β = 0 with t = b/SE_b on n − 2 degrees of freedom. A confidence interval for the slope is b ± t* · SE_b. It needs a linear pattern, independent observations, and residuals with roughly equal spread and normal shape.

What you'll learn

  • Distinguish the sample slope b from the population slope β
  • Test H₀: β = 0 with a t statistic on n − 2 degrees of freedom
  • Build and interpret a confidence interval for the slope
  • Read slope, standard error and p-value from regression output

A sample line estimates a true line

A least-squares line y^=a+bx\hat{y} = a + bx comes from one sample. A different sample would give a slightly different slope. Behind the samples sits a population line μy=α+βx\mu_y = \alpha + \beta x, and bb estimates its slope β\beta.

The slope’s standard error measures that sample-to-sample wobble:

SEb=ssxn−1\text{SE}_b = \frac{s}{s_x\sqrt{n - 1}}

where ss is the standard deviation of the residuals and sxs_x that of the xx values. Inference then follows the t procedures, with n−2n - 2 degrees of freedom:

t=b−0SEbtests H0:β=0b±t∗⋅SEbestimates βt = \frac{b - 0}{\text{SE}_b} \quad\text{tests } H_0: \beta = 0 \qquad\qquad b \pm t^* \cdot \text{SE}_b \quad\text{estimates } \beta

Why the standard error has that form

Three things make a slope trustworthy. Small residuals (ss small) mean the points hug the line; a wide spread of xx values (sxs_x large) pins the line down like a long lever; and more points (nn large) average out the noise. The formula puts ss on top and sxn−1s_x\sqrt{n - 1} on the bottom for exactly these reasons. Two degrees of freedom are lost because both the slope and the intercept were fitted from the same data.

Worked examples

Common mistakes

Practice problems

  1. A regression on n=15n = 15 points gives b=1.2b = 1.2 and SEb=0.9\text{SE}_b = 0.9. Find tt and its degrees of freedom.

    Answer

    t≈1.33t \approx 1.33 with 1313 df

    Full solution

    t=1.20.9t = \tfrac{1.2}{0.9}, and df=15−2\text{df} = 15 - 2.

  2. For Exercise 1, is the slope significant at α=0.05\alpha = 0.05 (two-sided)?

    Answer

    No

    Full solution

    The p-value is about 0.210.21.

    With 1313 df, t∗=2.160t^* = 2.160, and 1.33<2.1601.33 < 2.160.

  3. Find SEb\text{SE}_b when s=6s = 6, sx=2s_x = 2 and n=26n = 26.

    Answer

    0.60.6

    Full solution

    6225=610\tfrac{6}{2\sqrt{25}} = \tfrac{6}{10}.

  4. In Exercise 3, how does SEb\text{SE}_b change if the xx values are spread twice as widely?

    Answer

    It halves, to 0.30.3.

    Full solution

    sxs_x is in the denominator, so doubling it halves the standard error.

  5. A 95%95\% interval for β\beta is (−0.4, 1.8)(-0.4,\ 1.8). What does a test of H0:β=0H_0: \beta = 0 at α=0.05\alpha = 0.05 conclude?

    Answer

    Fail to reject H0H_0.

    Full solution

    The interval contains 00, so 00 is a plausible slope.

  6. In Example 3, what does the slope −0.60-0.60 mean in context?

    Answer

    Each degree warmer goes with heating costs about 0.600.60 units lower, on average.

    Full solution

    The slope is the predicted change in yy per one-unit change in xx.

  7. A residual plot shows a clear U-shape. What should you conclude about the slope test?

    Answer

    The linear model does not fit, so the test is not valid.

    Full solution

    A curved residual pattern means the relationship is not linear; transform the data or use a different model.

  8. A student uses 1111 df for Example 1 because n=12n = 12. Correct it.

    Answer

    Use 1010 df.

    Full solution

    Regression estimates both the slope and the intercept, so df=n−2\text{df} = n - 2.

Frequently asked questions

What does the test of H₀: β = 0 ask?

Whether the data show a linear relationship in the population. If β = 0, knowing x does not help predict y with a line.

How many degrees of freedom does the slope test have?

n − 2, because two quantities, the slope and the intercept, are estimated from the data.

What is the standard error of the slope?

SE_b = s/(s_x√(n − 1)), where s is the residual standard deviation and s_x the standard deviation of x. Software reports it next to the slope.

What is a confidence interval for the slope?

b ± t* · SE_b, with t* from the t distribution on n − 2 degrees of freedom. It gives plausible values for the change in mean y per unit of x.

What conditions are needed?

A roughly linear pattern, independent observations, residuals with about the same spread at every x, and residuals that look roughly normal.