Lesson 21: Least Squares Regression
November 18, 2026
Review:
- Scatterplots
- Schedule
- Week of Nov 23: Happy Thanksgiving!
- Week of Nov 30: Linear Regression
- Week of Dec 7: Exam 5
- 10:30a on Mon 14 Dec: All-Purpose Make-Up Exam
Presentation:
- Least Squares Regression
- Find a line of best fit for a set of points
- Least Squares Regression Proof: MethodLeastSquares
- Example 1: Lemonade Stand
- Use distance to predict fare
- Sample data (x=miles, y=fare $)
- Ride 1: 2, 7
- Ride 2: 3, 11
- Ride 3: 5, 15
- Ride 4: 7, 16
- Ride 5: 8, 21
- Scatterplot
- Table setup
- columns: x, y, x^2, y^2, xy
- sums: ∑x, ∑y, ∑x^2, ∑y^2, ∑xy
- Sum of Squares calculations
- SSxx = ∑x² – (∑x)²/n
- SSyy = ∑y² – (∑y)²/n
- SSxy = ∑xy – (∑x*∑y)/n
- Example 2: Used car price by vehicle age
- Use temperature to predict sales
- Sample data (x=age in yrs, y=$1000s)
- Car 1: 1, 28
- Car 2: 2, 23
- Car 3: 4, 17
- Car 4: 5, 16
- Car 5: 8, 6
- Scatter Plot
- Table setup
- columns: x, y, x^2, y^2, xy
- sums: ∑x, ∑y, ∑x^2, ∑y^2, ∑xy
- Sum of Squares calculations
- SSxx = ∑x² – (∑x)²/n
- SSyy = ∑y² – (∑y)²/n
- SSxy = ∑xy – (∑x*∑y)/n
- We will use these Sum of Squares calculations (next time) to determine
- linear equation y = ax + b
- Pearson correlation coefficient
- R-Squared
Activity:
For each problem below, calculate SSxx, SSyy and SSxy.
Problem 1 – Advertising and Sales (n = 6)
A retail chain studied weekly advertising spend and sales (both in $1,000s).
| Week | Advertising (x) | Sales (y) |
|---|---|---|
| 1 | 1 | 35 |
| 2 | 2 | 37 |
| 3 | 3 | 47 |
| 4 | 5 | 58 |
| 5 | 6 | 61 |
| 6 | 7 | 62 |
Problem 2 – Training Hours and Productivity (n = 6)
An HR analyst examined whether more training hours lead to higher productivity (daily packages processed per worker).
| Dept | Training Hours (x) | Productivity (y) |
|---|---|---|
| A | 2 | 42 |
| B | 4 | 39 |
| C | 6 | 49 |
| D | 8 | 51 |
| E | 10 | 55 |
| F | 12 | 46 |
Problem 3 – Price and Units Sold (n = 6)
A manufacturer tested different price points ($) to estimate demand.
| Trial | Price (x) | Units Sold (y) |
|---|---|---|
| 1 | 4 | 72 |
| 2 | 5 | 57 |
| 3 | 6 | 52 |
| 4 | 8 | 32 |
| 5 | 9 | 27 |
| 6 | 10 | 24 |
Problem 4 – Experience and Salary (n = 6)
An HR department compared employees’ years of experience with their annual salary (in $1,000s).
| Employee | Experience (x) | Salary (y) |
|---|---|---|
| 1 | 1 | 46 |
| 2 | 2 | 53 |
| 3 | 4 | 59 |
| 4 | 6 | 60 |
| 5 | 8 | 70 |
| 6 | 9 | 72 |
Problem 5 – Wait Time and Customer Satisfaction (n = 6)
A bank recorded customers’ average wait time (minutes) and their satisfaction score (0–100).
| Branch | Wait Time (x) | Satisfaction (y) |
|---|---|---|
| A | 2 | 84 |
| B | 4 | 70 |
| C | 5 | 76 |
| D | 7 | 58 |
| E | 8 | 53 |
| F | 10 | 55 |
Problem 6 – CEO Tenure and Stock Return (n = 6)
An investor wondered whether companies with longer-serving CEOs earn higher annual stock returns (%).
| Company | CEO Tenure, years (x) | Stock Return % (y) |
|---|---|---|
| 1 | 2 | 12 |
| 2 | 3 | 6 |
| 3 | 5 | 10 |
| 4 | 6 | 4 |
| 5 | 8 | 14 |
| 6 | 12 | 8 |