Linear Regression Line on Two Independent Variables Example

Suppose we want to find the regression line of  
\[y\]
  on independent variabbles  
\[x_1 \: x_2, \:,..., x_k\]
  from the set of data points  
\[\{ (x_{i1j},x_{i2},...,x_{nk} ,y_i): i=1,2,...,n\}\]
.
The regression line will take the form  
\[y=\beta_0 + \beta_1x_1+...+\beta_kx_k\]
.
Form the matrix  
\[X=(x)_{ij}\]
  and the column vector  
\[\mathbf{Y}=(y)_j\]
.
The vector of coefficients is  
\[B=(X^TX)^{-1}(X^TY)\]
.
For the set of data points
\[(4,20,1),(10,6,4),(15,2,5),(12,8,4),(8,9,3),(16,8,4)(5,12,2),(7,15,1),(9,10,4),(10,10,2)\]
Then
\[\begin{equation} \begin{aligned} \begin{pmatrix}\beta_0\\ \beta_1 \\ \beta_2\end{pmatrix} &= \left( \left( \begin{array}{cccccccccc} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 4 & 10 & 15 & 12 & 8 & 16 & 5 & 7 & 9 & 10 \\ 20 & 6 & 2 & 8 & 9 & 8 & 2 & 15 & 10 & 10 \end{array} \right)\left( \begin{array}{ccc} 1 & 4 & 20 \\ 1 & 10 & 6 \\ 1 & 15 & 2 \\ 1 & 12 & 8 \\ 1 & 8 & 9 \\ 1 & 16 & 8 \\ 1 & 5 & 2 \\ 1 & 7 & 15 \\ 1 & 9 & 10 \\ 1 & 10 & 10 \end{array} \right) \right)^{-1} \\ & \left( \left( \begin{array}{cccccccccc} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 4 & 10 & 15 & 12 & 8 & 16 & 5 & 7 & 9 & 10 \\ 20 & 6 & 2 & 8 & 9 & 8 & 2 & 15 & 10 & 10 \end{array} \right) \begin{pmatrix}1\\4\\5\\4\\3\\4\\2\\1\\4\\2\end{pmatrix} \right)= \begin{pmatrix}4.190\\0.085\\-0.201\end{pmatrix} \end{aligned} \end{equation}\]
.
The regression line is  
\[y=4.190+0.085x_1-0.201x_2\]
.

Add comment

Security code
Refresh