18. Inference for Linear Regression

a. Hypothesis Test for the Slope
Math 115

Yurk

What Is the Line Estimating?

Topic 17 fit a line to a sample: \hat{y} = b_0 + b_1 x. Behind that sample sits a population, where every individual follows

y = \beta_0 + \beta_1 x + \varepsilon

\beta_0 and \beta_1 are the population intercept and slope — fixed, unknown, never observed. \varepsilon is how far one individual falls above or below that line.

b_0 and b_1 estimate \beta_0 and \beta_1. A different sample gives different estimates — so what can one sample’s b_1 tell us about \beta_1? That question is inference for the slope.

What Does “No Relationship” Look Like?

A different population — this time x tells you nothing about y:

Try it — in y = \beta_0 + \beta_1 x + \varepsilon, what must \beta_1 be?

\beta_1 = 0, and the model collapses to y = \beta_0 + \varepsilon. x is gone from the equation. Every x gives the same predicted y, so the population line is flat. Here \beta_0 = 50.

Do Samples Come Out Flat?

Draw a sample of 20 from that population — the one where \beta_1 = 0.

Same population every time, with \beta_1 = 0. But the sample slope b_1 never comes out zero.
So the question: is b_1 far enough from zero to rule out \beta_1 = 0?

NYC Italian Restaurants

Research question: Is the price of dinner at an NYC Italian restaurant related to its food-quality rating?

  • Data: customer surveys from 168 Italian restaurants in NYC (Zagat, via Sheather, 2009).
  • Response (y): average price of dinner in dollars (includes one drink and tip).
  • Predictor (x): food-quality rating on Zagat’s 0–30 scale. These restaurants span only 16–25.

Fitted line: \widehat{Price} = -17.8 + 2.94 \times Food — higher ratings track higher prices. But is there a linear relationship between food rating and price in the population, or is b_1 just sampling noise?

Hypotheses for the Slope

Try it — the research question is whether food rating is related to price. Write H_0 and H_A in terms of \beta_1.

H_0: \beta_1 = 0 — the true slope is zero; a restaurant’s food rating tells you nothing about its price, linearly.
H_A: \beta_1 \neq 0 — there is a linear relationship; food rating and price move together.

Two-sided is the default. One-sided versions (\beta_1 > 0 or \beta_1 < 0) exist when the research question commits to a direction.

Test Statistic and Degrees of Freedom

Same T-statistic shape we’ve used since topic 11:

T = \frac{\text{statistic} - \text{null value}}{SE} = \frac{b_1 - 0}{SE_{b_1}} = \frac{b_1}{SE_{b_1}}

Software reports b_1 and SE_{b_1} — you can always verify T by hand.

Reference distribution: under H_0, T follows a t-distribution with

df = n - 2

Why n - 2? Fitting the line uses up two degrees of freedom — one for the intercept b_0, one for the slope b_1.

Conditions for Inference

Four conditions for the t-distribution to be a valid reference for T:

Condition Rule Check with
Linearity True relationship between x and y is approximately linear. Residual plot
Constant variance Residual spread is about the same across all \hat{y}. Residual plot
Normality n \geq 30: mild skew is fine, but no extreme outliers. n < 30: residuals should look roughly normal. Residual plot
Independence Observations are independent of each other. Study design

NYC Residual Plot

  • Linearity: no obvious curve — the residuals scatter randomly around zero ✓.
  • Constant variance: spread looks roughly the same across \hat{y} ✓.
  • Normality: no lone point far off from the rest, and no long tail on one side of zero ✓. (Additionally, n = 168 is large, so the CLT covers b_1.)
  • Independence: restaurants surveyed separately ✓.

Conditions met — proceed with the t-test.

Software Output

The regression output (Jamovi):

Term Estimate (b) Std. Error (SE) T p-value
(Intercept) -17.83 5.863 -3.04 0.003
Food 2.94 0.283 10.37 < 0.001

Read the Food row (the slope):

  • b_1 = 2.94 — predicted price rises about $3 per point of food rating.
  • SE_{b_1} = 0.283.
  • T = 10.37, p-value < 0.001.

Verify the T-Statistic

The output gives you b_1 and SE_{b_1}. You should always be able to compute T yourself — the software is just doing the arithmetic.

Recall: b_1 = 2.94, SE_{b_1} = 0.283. Try it: compute T and compare to the output.

T = \dfrac{b_1}{SE_{b_1}} = \dfrac{2.94}{0.283} \approx 10.39 — matches the output’s T = 10.37 (the tiny difference is rounding) ✓. The slope sits more than 10 standard errors above zero.

The P-Value Picture

Two-sided p-value = 2 × (smaller-tail area) ≈ < 0.0001 — software reports < 0.001.

Conclusion

Results: T = 10.37, df = 166, p-value < 0.001 → reject H_0.

In context: there is convincing evidence that food-quality rating is associated with meal price at NYC Italian restaurants. Higher food ratings are associated with higher prices.

Scope of inference.

  • Generalization: these are Zagat-guide restaurants, listed because they were selected for the guide and drew enough diner reviews — not a random sample of NYC Italian restaurants. Strictly, the result describes the restaurants studied; extending it further is a judgment call, not something the sampling justifies.
  • Causation: nobody assigned food ratings to restaurants, so association only — not that higher food quality causes higher prices. (Pricier restaurants may attract better-trained chefs; nicer décor may lift ratings.)

Looking Ahead

The slope is statistically distinguishable from zero, but how big is the population slope? “More than zero” is a weak summary — we’d like a range of plausible values.

Next (18b): the matching confidence interval for \beta_1 — same b_1, same SE_{b_1}, same t-critical-value machinery as topic 11b, applied to the regression slope.

References

  • Introduction to Modern Statistics (2e) textbook by Mine Çetinkaya-Rundel and Johanna Hardin
  • Sections 24.4, 24.6
  • Sheather, S. J. (2009). A Modern Approach to Regression with R. Springer. (restNYC data.)