One of the benefits of least squares regression is that it is easy to generalize from its uses on scatter plots to 3D or even higher dimensional data.
Previously, we learned that when least squares regression is used on two-dimensional data the SSE is given by the formula This gives us a good idea of what a higher dimensional error function will look like.
If there are predictor variables and one response variable then a linear equation which outputs will take the form
Given this information, what is a reasonable formula for the error when there is more than one predictor variable?
Remember, the squared error of a single point is the squared difference between the -value and the predicted -value at that point. The SSE for the best-fit function is the sum of the squared errors for each point.
Earlier, we derived a formula for a best-fit line. Now, we will attempt to modify this formula so that it works for higher dimensional linear regression. Instead of outputting a best-fit line, this formula will now output a best-fit hyperplane--a linear equation in higher dimensions.
In the last chapter, we started our derivation by representing our best-fit equation with a vector. We can do so again with Now, we must create a matrix which, when multiplied with outputs a vector containing the predicted value of for each data point in the set.
Previously, we did this by making ’s first column the -values of all data points and its second column a line of ones. Now, we can achieve the same results for higher dimensions by adding another column to for each additional predictor variable. This is shown below for a data set with points and predictor variables: Once again, we will also initialize the vector to contain the -values of every data point.
As it turns out, from this point on the derivation is exactly the same as before. We have to find the vector for which is as close as possible to and once again we can do this by solving the equation After that, we have our answer. The elements of will give the coefficient values for the best-fit hyperplane.
Alfred is back, and this time he’s remembered there are multiple types of trees. He’s managed to compile a table of the seeds he planted each spring as well as the number of new sprouts each fall. Using this information, identify the matrix which he needs to create in the process of calculating a best-fit linear equation.
At this point, we can find a best-fit hyperplane for any conceivable data set, as long as there are more data points than predictors. But there’s one major problem. What if the points in a data set are very predictable, but not in a linear fashion?
As it turns out, there is a simple way to expand on our previous model. We can just add new, nonlinear terms to our function and update the rest of our math accordingly.
Generally, this is done by adding powers of the predictor variables, in which case this process is known as polynomial regression.
For instance, say we have a simple data set in which there is one predictor variable and one response variable . The only twist is that we suspect to be best represented by a second degree polynomial of .
Instead of representing the data with a best-fit line we should now represent it with a best-fit polynomial In many ways, this is the same as creating another predictor variable. We have taken each point in our data set and added another value, After this step, we can calculate the coefficients as we normally would in higher dimensional linear regression.
Franklin is in the business of building toy race cars and is analyzing the relationship between the weight and top speed of a car when all else is held equal. So far he’s managed to collect just five data points, but he’s convinced that the relationship should be modeled with a cubic polynomial.
Given the table below, which matrix must he construct in the process of calculating the best-fit curve?
1: 2: 3: