How to solve such an equation?
$$2\pmb{X}^T(\pmb{X\hat{w}}-\pmb{y})=0$$
I read that the answer is the following, but why?
$$\pmb{\hat{w}} = (\pmb{X}^T\pmb{X})^{-1}\pmb{X}^T\pmb{y}$$
How to solve such an equation?
$$2\pmb{X}^T(\pmb{X\hat{w}}-\pmb{y})=0$$
I read that the answer is the following, but why?
$$\pmb{\hat{w}} = (\pmb{X}^T\pmb{X})^{-1}\pmb{X}^T\pmb{y}$$
$$2\pmb{X}^T(\pmb{X\hat{w}}-\pmb{y})=0$$
$$\pmb{X}^T(\pmb{X\hat{w}}-\pmb{y})=0$$
$$\pmb{X}^T\pmb{X\hat{w}}-\pmb{X}^T\pmb{y}=0$$
$$\pmb{X}^T\pmb{X\hat{w}}=\pmb{X}^T\pmb{y}$$
$$\pmb{\hat{w}} = (\pmb{X}^T\pmb{X})^{-1}\pmb{X}^T\pmb{y}$$
Oh, it turns out that it can be simplified to:
$$\pmb{X\hat{w}-y}=0$$ $$\pmb{X\hat{w}=y}$$ $$\pmb{X}^T\pmb{X\hat{w}}=\pmb{X}^T\pmb{y}$$ $$(\pmb{X}^T\pmb{X})(\pmb{X}^T\pmb{X})^{-1}\pmb{\hat{w}}=(\pmb{X}^T\pmb{X})^{-1}\pmb{X}^T\pmb{y}$$ $$\pmb{\hat{w}} = (\pmb{X}^T\pmb{X})^{-1}\pmb{X}^T\pmb{y}$$