- Describes how a numeric outcome \(Y\) relates to a single predictor \(X\)
- Fits the straight line that best summarizes the trend in the data
- Common uses: predicting test scores from study time, fuel economy from engine size, etc.
\[Y_i = \beta_0 + \beta_1 X_i + \epsilon_i, \qquad i = 1, \dots, n\]
Least squares chooses \(\hat\beta_0, \hat\beta_1\) to minimize the sum of squared errors:
\[\hat\beta_1 = \frac{\sum (x_i - \bar x)(y_i - \bar y)}{\sum (x_i - \bar x)^2}, \qquad \hat\beta_0 = \bar y - \hat\beta_1 \bar x\]
Using the Fish Market dataset (159 fish, 7 species). We look at whether a fish’s height predicts its width, both measured in centimeters.
fish <- read.csv("Fish.csv")
fit <- lm(Width ~ Height, data = fish)
summary(fit)