How can I calculate Slope and Y-intercept in Multiple Regression?

478 Views Asked by At

What is the formula for Slope and Y-intercept in Multiple Linear Regression? We can easily find Slope and Y-intercept of Linear Regression meaning the data having only one Independent Variable?

Is there any general way to calculate it?

1

There are 1 best solutions below

0
On BEST ANSWER

Suppose you have the following regression function: $ y_i = \beta_{0} + \beta_{1} x_{i1} + \cdots + \beta_{p} x_{ip} + \varepsilon_i$, where $\varepsilon_i$ is the random part (white noise). Here you have $p+1$ parameters. To estimate the the parameters $b_0,b_1,\ldots, b_p$ we need the following matrix and vectors.

$\mathbf{y} = \begin{pmatrix} y_1 \\ y_2 \\ \vdots \\ y_n \end{pmatrix},X = \begin{pmatrix} 1 & x_{11} & \cdots & x_{1p} \\ 1 & x_{21} & \cdots & x_{2p} \\ \vdots & \vdots & \ddots & \vdots \\ 1 & x_{n1} & \cdots & x_{np} \end{pmatrix}, \textbf β = \begin{pmatrix} \beta_0 \\ \beta_1 \\ \beta_2 \\ \vdots \\ \beta_p \end{pmatrix}, $

Suppose you have the following data

enter image description here

Here is $p=2$ and $n=17$. Then the corresponding vector and matrix is

$\mathbf{y} = \begin{pmatrix} 251.3 \\ 251.3 \\ \vdots \\ 349.0 \end{pmatrix},X = \begin{pmatrix} 1 & 41.9 & 29.1 \\ 1 & 34.4 & 29.3 \\ \vdots & \vdots & \vdots \\ 1 & 77.8 & 32.9 \end{pmatrix}$

The estimated parameters are

$ \begin{pmatrix} \hat \beta_0 \\ \hat \beta_1 \\ \hat \beta_2 \\ \end{pmatrix}=\hat \beta=(\mathbf{X^{'}X)^{-1}}\cdot \mathbf{X^{'}}\cdot \mathbf{y}$

Here $X^{'}$ denotes the transpose of $X$ and $(X^{'}X)^{-1}$ the inverse of $X^{'}X$

The result is $\begin{pmatrix} \hat \beta_0 \\ \hat \beta_1 \\ \hat \beta_2 \\ \end{pmatrix}=\begin{pmatrix} −153.5 \\ 1.24 \\ 12.08 \\ \end{pmatrix}$