Can someone help me with the following problem from regression analysis how can I prove it because I have been confused.
If we have the vector $x_n=[x_{n1}, x_{n2}, ... , x_{nl} ]^T$ where $n = 1,2,...,N$
How can I prove that: $X^TX = \sum_{n=1}^{N} x_nx_n^T$
By the definition of matrix multiplication, we have $$(X^TX)_{ij} = \sum_{n=1}^N X^T_{in}X_{nj} = \sum_{n=1}^{N}X_{ni}X_{nj}.$$ $x_n$ is an $n\times 1$ matrix with components $$ (x_n)_{i1} = X_{ni}$$ (which I presume was what was intended by $x_n=[x_{n1}, x_{n2}, ... , x_{nl} ]^T$... there should have been capital $X$'s inside the brackets).
So, again by definition of matrix multiplication, $$ (x_n x_n^T)_{ij} = \sum_{k=1}^1(x_n)_{ik}(x_n^T)_{kj} = \sum_{k=1}^1(x_n)_{ik}(x_n)_{jk} =(x_n)_{i1}(x_n)_{j1}=X_{ni}X_{nj},$$ so $$ \left(\sum_{n=1}^N x_nx_n^T \right)_{ij}=\sum_{n=1}^N (x_nx_n^T)_{ij} = \sum_{n=1}^N X_{ni} X_{nj} = (X^TX)_{ij}$$