The normal equation of \(X\beta = y\) can be obtained using \({X^T}X\beta = {X^T}y\) which is equivalent to \(\beta = {\left( {{X^T}X} \right)^{ - 1}}{X^T}y\).
Find \({X^T}X\) as follows:
\(\begin{aligned}{X^T}X &= \left[ {\begin{aligned}1&1&1&1\\{ - 1}&0&1&2\end{aligned}} \right]\left[ {\begin{aligned}1&{ - 1}\\1&0\\1&1\\1&2\end{aligned}} \right]\\ &= \left[ {\begin{aligned}{1 + 1 + 1 + 1}&{ - 1 + 0 + 1 + 2}\\{ - 1 + 0 + 1 + 2}&{1 + 0 + 1 + 4}\end{aligned}} \right]\\ &= \left[ {\begin{aligned}4&2\\2&6\end{aligned}} \right]\end{aligned}\)
Find the inverse of \({X^T}X\) as follows:
\(\begin{aligned}{\left( {{X^T}X} \right)^{ - 1}} &= {\left[ {\begin{aligned}4&2\\2&6\end{aligned}} \right]^{ - 1}}\\ &= \frac{1}{{24 - 4}}\left[ {\begin{aligned}6&{ - 2}\\{ - 2}&4\end{aligned}} \right]\\ &= \frac{1}{{20}}\left[ {\begin{aligned}6&{ - 2}\\{ - 2}&4\end{aligned}} \right]\end{aligned}\)
Find \({X^T}y\) as follows:
\(\begin{aligned}{X^T}y &= \left[ {\begin{aligned}1&1&1&1\\{ - 1}&0&1&2\end{aligned}} \right]\left[ {\begin{aligned}0\\1\\2\\4\end{aligned}} \right]\\ &= \left[ {\begin{aligned}{0 + 1 + 2 + 4}\\{0 + 0 + 2 + 8}\end{aligned}} \right]\\ &= \left[ {\begin{aligned}7\\{10}\end{aligned}} \right]\end{aligned}\)