Least Squares
Regression
Master the line of best fit, understand residuals, and learn how to measure the strength of linear relationships with data.
What Is Regression?
Regression is a statistical method for modeling the relationship between two quantitative variables. Given a set of data points, we want to find the straight line that best summarizes the trend in the data.
Scatterplots and Linear Patterns
Each dot represents one student. The dashed green line shows the general trend: more hours studied tends to predict a higher test score. But which line is the best one?
Why "Least Squares"?
Many lines could be drawn through a scatterplot. The least squares regression line (LSRL) is the unique line that minimizes the sum of squared residuals: the total squared vertical distance from each point to the line.
The LSRL Equation
The least squares regression line has the form:
The predicted change in \(y\) for each one-unit increase in \(x\).
The predicted value of \(y\) when \(x = 0\).
Interpreting the Slope
The slope \(b\) tells us the direction and rate of the linear relationship. A proper interpretation always includes context:
What Are Residuals?
A residual is the vertical distance between an observed data point and the regression line. It measures how far off our prediction is for that particular observation.
Reading a Residual Plot
Correlation vs. Regression
| Correlation \(r\) | Regression (LSRL) | |
|---|---|---|
| Purpose | Measures strength and direction | Predicts \(\hat{y}\) from \(x\) |
| Output | A single number: \(-1 \leq r \leq 1\) | An equation: \(\hat{y} = a + bx\) |
| Symmetry | \(r_{xy} = r_{yx}\) | Depends on which is \(x\) vs. \(y\) |
| Units | Unitless | Slope has units of \(y/x\) |
| Connection | Slope \(b = r \cdot \dfrac{s_y}{s_x}\), so \(r\) and \(b\) always share the same sign. | |
The Power of \(r^2\)
The coefficient of determination \(r^2\) tells us the proportion of variability in \(y\) that is explained by the linear relationship with \(x\).
How to Find the LSRL
Example: Finding the LSRL
A researcher collects data on hours of exercise per week (\(x\)) and resting heart rate (\(y\)) for 20 adults. Summary statistics:
Example: Equation and Prediction
Interpret the slope: For each additional hour of exercise per week, the model predicts a decrease of 3.12 bpm in resting heart rate, on average.
Predict for \(x = 6\) hours:
Coefficient of determination: \(r^2 = (-0.78)^2 = 0.6084\). About 60.8% of the variability in resting heart rate is explained by the linear relationship with hours of exercise.
Example: Computing Residuals
Using our LSRL \(\hat{y} = 86.04 - 3.12x\), suppose one adult exercises 6 hours/week and has an observed resting heart rate of 70 bpm.
Common Mistakes
Key Formulas at a Glance
| Concept | Formula | Interpretation |
|---|---|---|
| LSRL | \(\hat{y} = a + bx\) | Predicted \(y\) from \(x\) |
| Slope | \(b = r \cdot \dfrac{s_y}{s_x}\) | Change in \(\hat{y}\) per unit \(x\) |
| Intercept | \(a = \bar{y} - b\bar{x}\) | \(\hat{y}\) when \(x = 0\) |
| Residual | \(e = y - \hat{y}\) | Observed minus predicted |
| \(r^2\) | \(r^2\) | % of variability explained |
Question 1 of 5
A regression line is given by \(\hat{y} = 12.5 + 3.2x\). What is the predicted value of \(y\) when \(x = 5\)?
Question 2 of 5
If the observed value is \(y = 45\) and the predicted value is \(\hat{y} = 48\), what is the residual?
Question 3 of 5
If \(r = 0.9\), what does \(r^2 = 0.81\) tell us?
Question 4 of 5
Given \(\bar{x} = 10\), \(\bar{y} = 50\), \(s_x = 4\), \(s_y = 12\), and \(r = 0.6\), what is the slope of the LSRL?
Question 5 of 5
A residual plot shows a clear U-shaped curve. What does this suggest?