Instead of finding the least squares solution of , we will be finding it for where
→ design matrix
→ parameter vector
→ observation vector
Least-Squares Line
Suppose we are given data points, and we want to find a line that best fits the data points. Let the best fit line be the linear equation
And let the data points be . The graph should look something like this:
![best fit liney=beta_0 + beta_1 x](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_1.png)
Our goal is to determine the parameters and . Let's say that each data point is on the line. Then
![best fit line data points beta_0 + beta_1 x](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_2.jpg)
This is a linear system which we can write this as:
![linear system](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_3.jpg)
Then the least squares solution to will be .
General Linear Model
Since the data points are not actually on the line, then there are residual values. Those are also known as errors. So we introduce a vector called the residual vector , where
→
Our goal is to minimize the length of (the error), so that is approximately equal to . This means we are finding a least-squares solution of using .
Least-Squares of Other Curves
Let the data points be and we want to find the best fit using the function , where are parameters. Technically we are using a best fit quadratic function instead of a line now.
![best fit quadratic function](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_4.png)
Again, the data points don't actually lie on the function, so we add residue values where
![add residue values
to data points](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_5.jpg)
Since we are minimizing the length of , then we can find the least-squares solution using . This can also be applied to other functions.
Multiple Regression
Let the data points be and we want to use the best fit function , where are parameters.
![best fit function Multiple Regression](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_6.png)
Again, the data points don't actually lie on the function, so we add residue values where
![add residue values to data points of the function](https://dcvp84mxptlac.cloudfront.net/diagrams2/LA-7-5-X_7.jpg)
Since we are minimizing the length of , then we can find the least-squares solution using . This can also be applied to other multi-variable functions.