Instant PDF download, name-and-email checkout. Complete bundle: every Economics and Statistics book
Statistics guide, Unit 6, step 20 of 22Previous stepNext step

Step 20: Inference for Regression

SyllabusUniversity (left the AP course in 2026)
In 30 seconds
  • Your fitted line \( \hat{y} = a + bx \) is an estimate of an unknown population line \( \mu_y = \beta_0 + \beta_1 x \). The slope \( b \) changes from sample to sample, so it has a standard error.
  • The key test is \( H_0: \beta_1 = 0 \) (no linear relationship), using \( t = b \div SE(b) \) with df \( = n – 2 \). The interval is \( b \pm t^{*} \cdot SE(b) \).
  • \( r^2 \) gives the share of variation explained; the residual standard error \( s_e \) gives the typical prediction error in the units of \( y \). Report both.
  • Exam point: a prediction interval for one new case is always wider than a confidence interval for the mean response. Check L-I-N-E with a residual plot before trusting any p-value.
Video lesson coming soonA short animated lesson for this step will appear here.

From a fitted line to a population line

A company plots ten months of advertising spend against sales (both in $000s) and fits a straight line. The slope comes out at about 2.5: each extra $1,000 of advertising goes with about $2,500 more sales. The marketing director wants to put that number in next year’s budget.

Three questions stand in the way. Is the slope real, or could ten noisy points produce a line this steep when there is no true relationship? If it is real, how precisely do we know it? And if the company spends $6,000 next month, what sales should it expect, and with what uncertainty?

Earlier, regression was purely descriptive. Inference needs one more idea: the sample line is an estimate of a true line for the whole population, written with Greek letters:

\[ \text{population: } \mu_y = \beta_0 + \beta_1 x \qquad \text{sample estimate: } \hat{y} = a + bx \]

\( \beta_1 \) is the unknown true slope; \( b \) is our estimate of it from one sample. Just as \( \bar{x} \) estimates \( \mu \), \( b \) estimates \( \beta_1 \). A different ten months would give a different \( b \), so \( b \) has a sampling distribution and a standard error.

Key termResidual standard error \( s_e \): the typical size of a residual, that is, roughly how far the points sit from the fitted line, measured in the units of \( y \).

For the advertising data (\( x = 1, 2, \dots, 10 \); \( y = 14, 13, 20, 18, 26, 22, 30, 27, 34, 36 \)), the means are \( \bar{x} = 5.5 \) and \( \bar{y} = 24.0 \), with \( \sum(x-\bar{x})(y-\bar{y}) = 206.0 \) and \( \sum(x-\bar{x})^2 = 82.5 \). So \( b = 206.0 \div 82.5 = 2.497 \) and \( a = 24.0 – 2.497(5.5) = 10.267 \). The fitted line is \( \hat{y} = 10.267 + 2.497x \). The squared residuals add up to 55.62, so:

\[ s_e = \sqrt{\frac{\sum (y – \hat{y})^2}{n – 2}} = \sqrt{\frac{55.62}{8}} = 2.637 \]

Note the divisor \( n – 2 \), not \( n \). Two things (slope and intercept) were estimated from the data, and each costs one degree of freedom.

Testing the slope

A slope of zero means a flat line: \( x \) tells you nothing about \( y \). So the central test in regression is \( H_0: \beta_1 = 0 \) against \( H_a: \beta_1 \neq 0 \). The test follows the usual pattern, (estimate − hypothesised value) ÷ standard error:

\[ t = \frac{b – 0}{SE(b)}, \quad \text{df} = n – 2 \qquad SE(b) = \frac{s_e}{\sqrt{\sum (x – \bar{x})^2}} \]

The slope is estimated more precisely when the points hug the line (small \( s_e \)) and when the \( x \)-values are spread out (large \( \sum(x-\bar{x})^2 \)).

Worked example

For the advertising data, \( b = 2.497 \), \( s_e = 2.637 \), \( \sum(x-\bar{x})^2 = 82.5 \), \( n = 10 \). Test whether the slope differs from zero at \( \alpha = 0.05 \), and give a 95% interval for \( \beta_1 \).

Step 1\( H_0: \beta_1 = 0 \); \( H_a: \beta_1 \neq 0 \).
Step 2\( SE(b) = 2.637 \div \sqrt{82.5} = 2.637 \div 9.083 = 0.290 \)
Step 3\( t = 2.497 \div 0.290 = 8.61 \), df = 8. Two-tailed p ≈ 0.000026, so reject \( H_0 \).
Step 4\( t^{*} = 2.306 \): margin \( 2.306 \times 0.290 = 0.669 \); interval \( 2.497 \pm 0.669 = (1.83,\ 3.17) \).

There is very strong evidence of a positive linear relationship. We are 95% confident that each extra $1,000 of advertising goes with between about $1,830 and $3,170 of extra sales. The interval excludes zero, which matches the significant test. The honest message for the budget: the effect is real, but the range is wide, so planning on the optimistic end would be unwise.

How well does the line fit?

Two numbers summarise fit, and they answer different questions.

  • \( r^2 \), the coefficient of determination, is the proportion of the variation in \( y \) explained by the linear relationship with \( x \). It has no units and lies between 0 and 1.
  • \( s_e \) is the typical prediction error in the original units of \( y \). It answers the practical question: how far off is a typical prediction?

For the advertising data, \( r^2 = 0.902 \): about 90% of the variation in sales is explained by advertising, leaving 10% to things like season, competitors and pricing. And \( s_e = 2.637 \), so a typical prediction misses actual sales by about $2,640. With average monthly sales of $24,000, that may or may not be acceptable for planning. That is why you report \( s_e \) alongside \( r^2 \).

Common mistakeOver-reading \( r^2 \). A high \( r^2 \) does not prove a straight line is the right model (curved data can still give a high \( r^2 \)). It does not prove causation. And it does not guarantee useful predictions, because \( s_e \) can still be large when \( y \) itself varies a lot. Always check the residual plot first.

Two kinds of interval for a prediction

Suppose the company plans to spend $6,000. Putting \( x = 6 \) into the line gives \( \hat{y} = 10.267 + 2.497(6) = 25.25 \), about $25,250. But an interval around that number can mean two different things.

  • A confidence interval for the mean response estimates the average sales across all months with $6,000 of advertising.
  • A prediction interval estimates the sales in one particular new month with that spend.

The prediction interval is always wider. It carries two sources of uncertainty: where the true line sits, plus the scatter of individual months around that line. Averaging washes out the second source; predicting a single month does not.

Key termPrediction interval: an interval that aims to capture a single new observation at a given \( x \), rather than the average response.

At \( x = 6 \) the book’s 95% intervals are:

IntervalRange ($000s)Meaning
Mean response(23.30, 27.20)Average sales of all $6,000 months
Prediction(18.86, 31.63)Sales in one new $6,000 month

The prediction interval is about three times wider. If the director asks what next month will bring, the wider interval is the honest answer. Both bands are narrowest near \( \bar{x} \) and widen towards the edges of the data, which is another reason not to extrapolate far beyond the \( x \)-values you observed.

Checking the assumptions and reading output

All of this rests on four conditions, remembered as L-I-N-E:

ConditionHow to check
LLinear relationshipScatterplot; residual plot with no curve
IIndependent observationsStudy design (watch for data collected over time)
NNormally distributed residualsHistogram or quantile plot of residuals
EEqual variance of residualsResidual plot with constant vertical spread

The residual plot (residuals against \( x \) or fitted values) checks three of the four at once. A healthy plot is a shapeless band around zero. A curve means the straight-line model is wrong. A funnel means unequal variance, so standard errors and intervals are unreliable; transforming \( y \), often with a logarithm, can help. A single extreme point may be distorting the fit, so refit without it and compare. For the advertising data, L, N and E look fine, but the data is monthly, so independence is questionable and should be reported as a limitation.

Software condenses everything into one table:

CoefficientsEstimateStd. Errort valuep-value
(Intercept)10.2671.8025.700.00045
advertising2.4970.2908.600.000026

Residual standard error: 2.637 on 8 degrees of freedom; R-squared: 0.902. Read four things first: the slope (effect size, in units), its p-value, its interval (or the SE that builds it), and \( s_e \). The intercept’s p-value is usually of no interest. As a rough guide, \( |t| \) above about 2 suggests significance at 5%. Then look at the residual plot before believing any of it.

One unifying idea: every test in this part of the book has the same skeleton. Form an estimate, divide by its standard error, and compare with a reference distribution (t, z, \( \chi^2 \) or F). Testing a slope is the same as testing a correlation, and for simple regression the F in the output equals \( t^2 \).

Exam tipUse df = \( n – 2 \), write hypotheses about \( \beta_1 \) (not \( b \)), and interpret the slope interval in context with units (“each extra $1,000 of advertising…”). Match the interval to the question: one specific case needs a prediction interval. Mention the residual plot and any doubt about independence.

Practise: 6 questions

Try each one on paper first, then check the worked answer.

EasyQ1. A slope has \( b = 4.2 \) and \( SE(b) = 1.5 \) from \( n = 20 \) points. Compute t and df. Show worked answer
\( t = 4.2 \div 1.5 = 2.80 \)
df \( = n – 2 = 18 \).
EasyQ2. A regression on 27 points has residual sum of squares 200. Find \( s_e \). Separately, if \( s_e = 6 \) and \( \sum(x-\bar{x})^2 = 144 \), find \( SE(b) \). Show worked answer
\( s_e = \sqrt{200 \div (27 – 2)} = \sqrt{8} = 2.83 \)
\( SE(b) = 6 \div \sqrt{144} = 6 \div 12 = 0.5 \)
MediumQ3. \( b = 0.8 \), \( SE(b) = 0.5 \), \( n = 12 \). With \( t^{*} = 2.228 \), is the slope significant at 5%? Show worked answer
\( t = 0.8 \div 0.5 = 1.60 \), df = 10.
\( 1.60 \lt 2.228 \), so not significant (two-tailed p ≈ 0.14).
No linear relationship has been established; a slope of 0 is still plausible.
MediumQ4. Using \( \hat{y} = 10.267 + 2.497x \) (all in $000s), predict sales at \( x = 8 \). If the CEO asks what one new month at that spend will bring, which interval should you give and why? Show worked answer
\( \hat{y} = 10.267 + 2.497 \times 8 = 10.267 + 19.976 = 30.24 \), about $30,240.
Give a prediction interval, because one specific month is a single new observation, not an average. It includes the scatter of individual months around the line, so it is wider than the confidence interval for the mean.
MediumQ5. A residual plot shows (a) a clear U-shape, (b) a fan that widens as \( x \) increases. Which condition fails in each case, and what should you do? Show worked answer
(a) Linearity fails: a straight line cannot capture the bend. Transform a variable or fit a curved model.
(b) Equal variance fails. Standard errors, intervals and p-values become unreliable, especially at the wide end. Try transforming \( y \) (for example a logarithm) and re-check the residual plot.
ExamQ6. A study of 15 stores regresses sales on floor area: \( b = 3.4 \), \( SE(b) = 1.2 \), \( s_e = 8.5 \), \( r^2 = 0.38 \). (a) Test whether the slope differs from zero using \( t^{*} = 2.160 \) at \( \alpha = 0.05 \). (b) Build a 95% interval for \( \beta_1 \). (c) Interpret \( r^2 \) and \( s_e \) together. (d) A manager says “bigger stores cause higher sales”. Comment. [8 marks] Show worked answer
(a) \( H_0: \beta_1 = 0 \), \( H_a: \beta_1 \neq 0 \) [1]. \( t = 3.4 \div 1.2 = 2.83 \), df = 13 [1]. \( 2.83 \gt 2.160 \), so reject \( H_0 \): the slope differs significantly from zero [1].
(b) \( 3.4 \pm 2.160 \times 1.2 = 3.4 \pm 2.59 = (0.81,\ 5.99) \) [2].
(c) Only 38% of the variation in sales is explained by floor area, and a typical prediction misses by about 8.5 units: the relationship is real but weak and imprecise [2].
(d) Not justified: this is observational data showing association only. Lurking variables such as location or footfall could drive both [1].

Check yourself

1. Why is df \( = n – 2 \) in a slope test?

Each estimated parameter costs one degree of freedom.

2. Output reads “Residual standard error: 2.637 on 8 degrees of freedom”. How many observations were there?

df = \( n – 2 = 8 \), so \( n = 10 \).

3. Which L-I-N-E condition cannot be checked from a residual plot?

Independence comes from the study design, not a plot.

Your score: 0 out of 3

The short version

  • The sample line \( \hat{y} = a + bx \) estimates the population line \( \mu_y = \beta_0 + \beta_1 x \); \( b \) has a standard error \( SE(b) = s_e / \sqrt{\sum(x-\bar{x})^2} \).
  • Test \( H_0: \beta_1 = 0 \) with \( t = b/SE(b) \), df \( = n – 2 \). The interval \( b \pm t^{*} SE(b) \) excludes zero exactly when the test is significant.
  • \( r^2 \) is the share of variation explained; \( s_e \) is the typical error in the units of \( y \). Report both.
  • A prediction interval for one new case is always wider than a confidence interval for the mean response, and both widen away from \( \bar{x} \).
  • Check L-I-N-E with the residual plot before trusting the output. The full chapter in Statistics Made Simple has 56 practice questions with a complete answer key.
Want more questions like these, with worked answers?
The practice book has hundreds more, graded from easy to exam level.
Next: step 21 of 22Comparing Several Means with ANOVA