Is this sum of convex and concave functions a convex function? Is this a convex function in $X$, where all the entries are real and $Y,\beta$ are constants where $X,Y$ are rectangular matrices and $\beta$ is a constant vector and $A,B$ are constant p.s.d matrices:
$ (Y-X\beta)(Y-X\beta)^T +Tr(X^TAX) - Tr(X^TBX)$
I know that the first two terms are convex and the third term with the negative sign included becomes a concave function, but what about the convexity of the sum of the three terms, i.e the convexity of the sum of first two terms (convex part) + the third term (concave part)?
 A: Not in general, of course. For example, if $\beta$ is the zero vector, $A$ is the zero matrix, and $B$ is the identity matrix, then the function is not convex. So the answer  depends on the values of $\beta,A,B$. The value of $Y$ is not relevant, because it appears only in the terms that are linear in $X$ and therefore do not affect convexity. Only quadratic terms matter. And for a quadratic form, being convex is equivalent to being positive semidefinite. 
Note that $(X\beta)(X\beta)^T$ can be written as $\operatorname{Tr}(XCX^T)$ where $V=\beta\otimes \beta^T$ is the Kronecker product (or outer product), which is a positive semidefinite matrix of rank 1. So the matter reduces to the convexity of 
$$X\mapsto \operatorname{Tr}(XCX^T) + \operatorname{Tr}(X^T (A-B)X)$$ 
Unfortunately these two terms cannot be combined easily: the position of $X^T$ matters. In practical terms: if $A-B$ is positive semidefinite, then you have convexity. If $A-B$ is not positive definite, then it's unlikely that the sum is convex.
