One very cool thing about our formula for the least squares regression line, \(\mathtt{\left(X^{T}X\right)^{-1}X^{T}y}\), is that it is the same no matter whether we have one independent variable (univariate) or many independent variables (multivariate).

Consider these data, showing the selling prices of some grandfather clocks at auction. The first scatter plot shows the age of the clock in years on the x-axis (100–200), and the second shows the number of bidders on the x-axis (0–20). Price (in pounds or dollars) is on the y-axis on each plot (500–2500).

Age (years) | Bidders | Price ($) |
---|---|---|

127 | 13 | 1235 |

115 | 12 | 1080 |

127 | 7 | 845 |

150 | 9 | 1522 |

156 | 6 | 1047 |

182 | 11 | 1979 |

156 | 12 | 1822 |

132 | 10 | 1253 |

137 | 9 | 1297 |

113 | 9 | 946 |

137 | 15 | 1713 |

117 | 11 | 1024 |

137 | 8 | 1147 |

153 | 6 | 1092 |

117 | 13 | 1152 |

126 | 10 | 1336 |

170 | 14 | 2131 |

182 | 8 | 1550 |

162 | 11 | 1884 |

184 | 10 | 2041 |

143 | 6 | 854 |

159 | 9 | 1483 |

108 | 14 | 1055 |

175 | 8 | 1545 |

108 | 6 | 729 |

179 | 9 | 1792 |

111 | 15 | 1175 |

187 | 8 | 1593 |

111 | 7 | 785 |

115 | 7 | 744 |

194 | 5 | 1356 |

168 | 7 | 1262 |

You can see in the notebook below that the first regression line, for the price of a clock as a function of its age, is approximately \(\mathtt{10.5x-192}\). The second regression line, for the price of a clock as a function of the number of bidders at auction, is approximately \(\mathtt{55x+806}\). As mentioned above, each of these univariate least squares regression lines can be calculated with the formula \(\mathtt{\left(X^{T}X\right)^{-1}X^{T}y}\).

Combining both age and number of bidders together, we can calculate, using the same formula, a multivariate least squares regression equation. This of course is no longer a line. In the case of two input variables as we have here, our line becomes a plane.

Our final regression equation becomes \(\mathtt{12.74x_{1}+85.82x_{2}-1336.72}\), with \(\mathtt{x_1}\) representing the age of a clock and \(\mathtt{x_2}\) representing the number of bidders.