How to pass from elements of a matrix to the matrix itself?

56 Views Asked by At

Doing multiple linear regression I have the following expression $$\frac{\partial S(\boldsymbol \beta)}{\partial \beta_j} = -2\sum_{i=1}^n x_{ij}(Y_i-\boldsymbol x_i^T\boldsymbol \beta)^2$$

then the book simply says "hence we can write it as $$\frac{\partial S(\boldsymbol \beta)}{\partial \boldsymbol\beta} = -2 \boldsymbol X^T(\boldsymbol Y - \boldsymbol X \boldsymbol \beta)^2$$

How do we go from one to the other? Especially without doing any passage

Example

For example let's take some elements.

For $j=0$ we have $\partial_{\beta_0}S(\boldsymbol \beta)= -2 \sum_{i=1}^n x_{i0}(Y_i-\boldsymbol x_i^T\boldsymbol \beta)$ now how on earth do we know that this element, which will be the first element of $\frac{\partial S(\boldsymbol \beta)}{\partial \boldsymbol\beta}$, relates to the above result?

Notation

$Y_i = \beta_0 + \beta_1x_{i1}+ \cdots + \beta_px_{ip}+\epsilon_i = \boldsymbol x_i^T \boldsymbol \beta+ \epsilon_i$ where $$\boldsymbol x_i^T = (1, x_{i1}, \cdots, x_{ip})_{1\times (p+ 1)}$$ $$\boldsymbol \beta = (\beta_0, \cdots, \beta_p)^T_{(p+1)\times 1}$$ Then, having $i=1,..,n$ we can write $$\boldsymbol Y = \boldsymbol X \boldsymbol \beta +\boldsymbol \epsilon$$ where $$\boldsymbol Y =(Y_1,\cdots,Y_n)^T_{n\times 1}$$ $$\boldsymbol X = (\boldsymbol{x_1^T, \cdots, x_n^T})_{n\times p}$$ $$\boldsymbol \epsilon = (\epsilon_1, \cdots, \epsilon_n)^T_{n \times 1}$$