Solution (source code)

= Solution

Transform each observation to $Y_j=A^TX_j$. If $A^T$ has full row <rank> $m$, the transformed sample is <multivariate normal> with mean $A^T\mu$ and <positive-definite> <covariance matrix> $A^T\Sigma A$. Its <sample mean> is $A^T\bar X$ and its unbiased <sample covariance matrix> is $A^TSA$. The <Hotelling test of linear hypotheses> therefore uses
$$
\boxed{T_A^2=n(A^T\bar X)^T(A^TSA)^{-1}(A^T\bar X),\qquad
\frac{n-m}{m(n-1)}T_A^2\sim F_{m,n-m}\text{ under }H_0.}
$$
Here $n>m$ is required. Reject for a large scaled statistic using the relevant upper <F-distribution> quantile. If the rows of $A^T$ are dependent, choose a basis for their row space, use that basis as the contrast matrix, and replace $m$ by its <rank> $r$. The null hypothesis is unchanged, but redundant contrasts must not be treated as independent dimensions. <Rank> zero gives no restrictions and hence no nontrivial test.