Conditional expectation for a weighted squared random variable By the law of total expectation, the conditional expected value of X given Y is given by $$E(X)=E(E(X|Y))$$ Can someone please point me to the theory or identity showing the relation in the case we have the weighted squared shown below $$E(X^TQX)$$ I can easily find the result for the non-conditional case but not for the conditional case.
Thanks
 A: Note the identity you mention in the comments,
$$E[X′QX]=E[X]′QE[X]+\text{tr}(Q\text{cov}(X)),$$
where $Q$ is constant and $\text{cov}(X)$ is the variance-covariance matrix of $X$ can be shown as follows:
First recall that the trace is linear and invariant to cyclic product permutations, i.e.
$$\text{tr}(aA+bB)=a\text{tr}(A)+b\text{tr}(B),\quad a,b \text{ scalar}\\
\text{tr}(ABC)=\text{tr}(BCA)=\text{tr}(CAB).$$
Since $X′QX$ is a scalar and hence equal to its own trace, we have
$$E[X′QX]=E[\text{tr}(X′QX)]=E[\text{tr}(QXX′)]
=\text{tr}(QE[XX′])\\
=\text{tr}(Q(E[XX′]-E[X]E[X]'+E[X]E[X]'))\\
=\text{tr}(Q(\text{cov}(X)+E[X]E[X]'))\\
=\text{tr}(Q\text{cov}(X))+\text{tr}(QE[X]E[X]')\\
=\text{tr}(Q\text{cov}(X))+\text{tr}(E[X]'QE[X])\\
=\text{tr}(Q\text{cov}(X))+E[X]'QE[X].$$
Replacing $E[\cdot]$ with $E[\cdot|Y]$ in the above gives the analogous conditional identity
$$E[X′QX|Y]=\text{tr}(Q\text{cov}(X|Y))+E[X|Y]'QE[X|Y] \quad (1).$$
Finally, as discussed in comments, if you wish to write $E[X′QX]$ in terms of conditional expectations, we have by LIE
$$E[X′QX]=E[E[X′QX|Y]],$$
where the inner expectation is as given in $(1)$.
