Chapter 5 of 7

A Continuous Second Variable

What changes when both predictors are numbers

So far our second variable was binary — goalkeeper or outfield. But what if the second variable is also continuous, like age?

4681012Annual Salary (M€)01020304050Market Value (M€)Age2034

The colour reveals a pattern: younger players tend to have higher market values at any salary level, while older players are worth less. Age carries information that salary alone misses.


With two continuous predictors, the regression ‘line’ becomes a flat surface — a plane in three dimensions.

357911202428321020304050Salary (M€)AgeValue (M€)

Drag to rotate

Estimated regression equation
y^=58.4+3.78×salary2.19×age\hat{y} = 58.4 + 3.78 \times \text{salary} -2.19 \times \text{age}

The model finds the flat plane that minimises the sum of squared vertical distances from each point to the surface. Drag the plot to rotate and explore the plane from different angles.


b₁: holding age constant, each extra €1M in salary changes value by b₁. b₂: holding salary constant, each extra year of age changes value by b₂.

Salary effect (age held at mean) 4681012Salary (M€)01020304050b₁ = 3.78
Age effect (salary held at mean) 20253035Age (years)01020304050b₂ = -2.19
Full estimated equation
y^=58.4baseline+3.78salary effect×salary2.19age effect×age\hat{y} = \underbrace{58.4}_{\text{baseline}} + \underbrace{3.78}_{\text{salary effect}} \times \text{salary} \underbrace{ -2.19}_{\text{age effect}} \times \text{age}

Each extra €1M in salary adds 3.78 M€ to predicted value for players of the same age. Each extra year of age changes value by -2.19 M€ for players on the same salary.


Plug in any salary and age to get a prediction. Watch how the regression line shifts as you change the age.

4681012Annual Salary (M€)01020304050Market Value (M€)age = 26
Predicted Market Value 0.0 M€
Substituted equation
y^=58.4+3.78×7.02.19×26=28.0\hat{y} = 58.4 + 3.78 \times 7.0 -2.19 \times 26 = 28.0

With a binary second variable we got two lines. With a continuous second variable we get a whole family of lines — one for every age.

4681012Annual Salary (M€)01020304050Market Value (M€)age 22age 26age 30age 34
Age 22
Age 26
Age 30
Age 34

All lines have the same slope (3.78). The only difference is the height — each year of age shifts the line by -2.19. This is exactly the additive assumption: the salary effect is the same at every age.

Salary Only R² 25.1%
Salary + Age R² 97.2%

Built with SvelteKit + D3.js