Lesson 17: Least Squares Regression
April 1, 2026
Review:
- Scatterplots
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 temperature to predict sales
- Sample data
- Day 1: 70°, 45
- Day 2: 75°, 52
- Day 3: 80°, 54
- Day 4: 85°, 60
- 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: Iced Coffee Sales by Temp
- Use temperature to predict sales
- Sample data
- Day 1: 58°, 40
- Day 2: 62°, 44
- Day 3: 68°, 49
- Day 4: 72°, 53
- Day 5: 78°, 59
- Day 6: 82°, 63
- Day 7: 88°, 67
- Day 8: 92°, 73
- 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:
Problem 1 – Advertising and Sales (n = 8)
A retail chain studied the link between weekly advertising spend and sales (in $1,000s).
| Week | Advertising (x) | Sales (y) |
|---|---|---|
| 1 | 6 | 64 |
| 2 | 8 | 77 |
| 3 | 10 | 85 |
| 4 | 4 | 55 |
| 5 | 7 | 72 |
| 6 | 9 | 82 |
| 7 | 3 | 50 |
| 8 | 11 | 88 |
Task:
Calculate SSxx, SSyy and SSxy
Problem 2 – Training Hours and Productivity (n = 8)
An HR analyst examined whether more employee training hours lead to higher productivity (daily packages processed per worker).
| Dept | Training Hours (x) | Productivity (y) |
|---|---|---|
| A | 5 | 46 |
| B | 8 | 54 |
| C | 4 | 42 |
| D | 6 | 49 |
| E | 10 | 59 |
| F | 3 | 40 |
| G | 9 | 57 |
| H | 7 | 51 |
Task:
Calculate SSxx, SSyy and SSxy
Problem 3 – Price and Units Sold (n = 8)
A manufacturer tested different price points to estimate demand.
| Trial | Price (x) | Units Sold (y) |
|---|---|---|
| 1 | 40 | 210 |
| 2 | 35 | 250 |
| 3 | 45 | 190 |
| 4 | 50 | 160 |
| 5 | 30 | 280 |
| 6 | 55 | 150 |
| 7 | 25 | 310 |
| 8 | 60 | 130 |
Task:
Calculate SSxx, SSyy and SSxy