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 comes from one sample. A different sample would give a slightly different slope. Behind the samples sits a population line , and estimates its slope .
The slope’s standard error measures that sample-to-sample wobble:
where is the standard deviation of the residuals and that of the values. Inference then follows the t procedures, with degrees of freedom:
Why the standard error has that form
Three things make a slope trustworthy. Small residuals ( small) mean the points hug the line; a wide spread of values ( large) pins the line down like a long lever; and more points ( large) average out the noise. The formula puts on top and 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
-
A regression on points gives and . Find and its degrees of freedom.
Answer
with df
Full solution
, and .
-
For Exercise 1, is the slope significant at (two-sided)?
Answer
No
Full solution
The p-value is about .
With df, , and .
-
Find when , and .
Answer
Full solution
.
-
In Exercise 3, how does change if the values are spread twice as widely?
Answer
It halves, to .
Full solution
is in the denominator, so doubling it halves the standard error.
-
A interval for is . What does a test of at conclude?
Answer
Fail to reject .
Full solution
The interval contains , so is a plausible slope.
-
In Example 3, what does the slope mean in context?
Answer
Each degree warmer goes with heating costs about units lower, on average.
Full solution
The slope is the predicted change in per one-unit change in .
-
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.
-
A student uses df for Example 1 because . Correct it.
Answer
Use df.
Full solution
Regression estimates both the slope and the intercept, so .
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.