What Is Simple Linear Regression?

  • 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.

The Model

\[Y_i = \beta_0 + \beta_1 X_i + \epsilon_i, \qquad i = 1, \dots, n\]

  • \(\beta_0\): intercept, predicted \(Y\) when \(X = 0\)
  • \(\beta_1\): slope, change in \(Y\) per one-unit change in \(X\)
  • \(\epsilon_i\): random error, assumed \(\epsilon_i \sim N(0, \sigma^2)\)

Estimating the Coefficients

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\]

The Data

Using the Fish Market dataset (159 fish, 7 species). We look at whether a fish’s height predicts its width, both measured in centimeters.

Fitting the Model in R

fish <- read.csv("Fish.csv")
fit <- lm(Width ~ Height, data = fish)
summary(fit)

Scatterplot with Fitted Line

Residual Plot

Interactive 3D Plot

Interpretation

  • Slope: 0.312 — each additional cm of height increases the predicted width by about 0.312 cm
  • \(R^2\): 0.629
  • The p-value for Height is below 0.05, so the relationship is statistically significant

Takeaways

  • Simple linear regression summarizes a relationship with a slope and intercept
  • Always check residuals before trusting the fit
  • Correlation does not imply causation