In my econometrics textbook, I have this step which is not clear to me:
\begin{align} S &= e'e \\ &= (y-W\beta)'(y-W\beta) \\ &= \underbrace{y'}_{1\times T} \ \underbrace{y}_{T\times 1} -\underbrace{y'}_{1\times T} \ \underbrace{W\beta}_{(T\times2)(2\times1)} -\underbrace{\beta'W'y}_{(1\times2)(2\times T)(T\times1)} +\underbrace{\beta'W'W\beta}_{1\times1}, \end{align} or, since all the terms are scalars, $$S =y'y -2\beta'W'y +\beta'W'W\beta. \tag{2.5.6}$$
Basically, I don't understand how we go from $-y'W\beta -\beta'W'y$ to $-2\beta'W'y'$. Thanks in advance.
$y^\prime W \beta$ is a 1 by 1 matrix (a scalar). As such, it is equivalent to its own transpose (if you exchange rows and columns in a matrix with one row and one column, you have changed nothing).
So $$y^\prime W \beta = (y^\prime W \beta)^\prime = \beta^\prime W^\prime y$$