Lesson 2 of 8

Regression Assumptions and Residuals

In Lesson 1, Priya's iced-coffee cart got its line: each warmer degree buys about two more cups, and temperature explained 96% of her daily swing. A great fit. But a line that fits well can still be lying to you, because every regression quietly leans on four assumptions, and lm() will hand you slopes and p-values whether or not they hold.

The good news: you already met the tool that checks all four. The residual, the gap between what actually happened and what the line predicted, is a regression's lie detector. This lesson teaches you to read it. The plot below is where we are headed; by the end you will diagnose a model from its shape in seconds.

By the end of this lesson you will be able to:

  • Name the four assumptions behind a linear regression and say what each one means
  • Read a residuals-vs-fitted plot: tell a healthy fit from a funnel and from a curve
  • Check normality with a Q-Q plot, and check independence, and know which fix each problem needs

Prerequisites: Lesson 1 (you can fit a line with lm() and you know a residual is actual minus predicted). You can run R and read its output. Every new term is defined as it appears.

The fine print

The four promises a regression makes

When you fit lm(cups ~ temp), you are not just drawing a line. You are assuming the data was generated by

\[ y_i = \beta_0 + \beta_1 x_i + \varepsilon_i \]

Read it out loud: each day's cups \(y_i\) equals the true intercept \(\beta_0\) plus the true slope \(\beta_1\) times that day's temperature \(x_i\), plus an error \(\varepsilon_i\), the part no straight line could ever capture (weekend crowds, a passing tour group, rain). The slope and p-values R reports are only trustworthy if that error term behaves. It must keep four promises, easy to remember as LINE:

Assumption What it means for Priya How you check it
Linearity The real relationship between temp and cups is a straight line, not a curve residuals vs fitted (look for a bend)
Independence One day's miss tells you nothing about the next day's miss residuals in time order (look for runs)
Normality The misses pile up in a symmetric bell around zero a Q-Q plot of the residuals
Equal variance The misses are the same size for cool days and hot days alike residuals vs fitted (look for a funnel)

Notice the right column: you check almost everything by looking at the residuals. So let us learn to look.