I am trying to calculate T squared. I have the following parameters:
> invS #inverse variance covariance matrix
x1 x2
x1 0.005536320 -0.001167908
x2 -0.001167908 0.002635186
> n # number of rows
[1] 11
> d_mean
x1 x2
-9.363636 13.272727
When I am trying to calculate the T squared:
> Tsq <- n* d_mean*invS*t(d_mean)
...I get this error:
Error in n* d_mean*invS*t(d_mean) : non-conformable arrays
What am I doing wrong?
Try:
Tsq <- n * d_mean %*% invS %*% t(d_mean).
%*%
is the matrix product and *
the element-wise product.