Normal Equation Derivation Step Help

114 Views Asked by At

I was interested in seeing how the normal equations for least squares for linear regression are derived, and found this page: https://eli.thegreenplace.net/2014/derivation-of-the-normal-equation-for-linear-regression/

I am fine with most of the derivation except for two key lines. They derive the loss function as: enter image description here

And then simplify this to: enter image description here

I don't understand how $(X\theta)^T y - y^T (X\theta)$ simplifies to $-2(X\theta)^T y$.

1

There are 1 best solutions below

0
On BEST ANSWER

Notice that $-(X\theta)^T y = -(X\theta) \cdot y$ where $\cdot$ is the dot product. Similarly, $-y^T(X\theta) = -y \cdot (X\theta) = -(X\theta) \cdot y$ (since the dot product is symmetric).

Hence, the sum of these two values is $-2(X\theta)\cdot y = -2(X\theta)^Ty$