In linear regression, the relationship between the dependent variable and independent variables in is modeled by a linear hypothesis function:
where is redefined as an augmented dimensional vector containing as well as the independent variables, and is an argmented dimensional vector containing as well as the weights as the parameters, to be determined based on the given dataset.Geometrically, this linear regression function is a straight line if , a plane if , or a hyperplane if , in the dimensional space spanned by as well as . The function has an intercept along the dimension and a normal direction . When thresholded by the plane , the regression function becomes an equation , representing a point if , a straight line if , a plane or hyperplane if , in the d-dimensional space spanned by , as shown in the figure below for .
We denote by the matrix containing the augmented data points as its column vectors
(109) |
(110) |
Now the linear regression problem is simply to find the model parameter, here the weight vector , so that the model prediction
(111) |
If the number of data samples is equal to the number of unknown parameters, i.e., , then is a square and invertible matrix (assuming all samples are independent and therefore has a full rank), and the equation above can be solved to get the desired weight vector:
(113) |
Having found the parameter for the linear regression model , we can predict the outputs corresponding to any unlabed test dataset :
which is a linear combination of and
We further consider the evaluation of the linear regression
result in terms of how well it fits the training data. We
first rewrite the normal equation in Eq. (115)
as:
We further consider some quantitative measurement for evaluating
how well the linear regression model
fits
the given dataset. To do so, we first derive some properties
of the model based on its output
:
(120) |
(122) |
(123) |
We further find the mean of
(124) |
(125) |
(126) |
(127) |
(128) |
We can show that the total sum of squares is the sum of the explained
sum of squares and the residual sum of squares:
(129) |
(130) |
We can now measure the goodness of the model by the coefficient of determination, denoted by (R-squared), defined as the percentage of variance explained by the model:
(131) |
In the special case of 1-dimensional dataset , how closely the two variables and are correlated to each other can be measured by correlation coefficient defined as:
(132) |
We can further find the linear regression model
in
terms of the model parameters:
(133) |
or | (134) |
The coefficient of determination for the goodness of the
regression is closely related to the correlation coefficient
for correlation of the given data (but independent of the model), as
one would intuitively expect. Consider
(135) |
Example 1:
Find a linear regression function to fit the following points:
Example 2:
The figure below shows a set of data points fitted by a 1-D linear regression function , a straight line, with . The correlation coefficient is , and , .
Example 4:
The figure below shows a set of data points fitted by a 2-D linear regression function , a plane, with „ and and .