1

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?

Feyzi Bagirov
  • 1,292
  • 4
  • 28
  • 46
  • 1
    I think what you want is `n * d_mean %*% invS %*% t(d_mean)`. `%*%` is the matrix product, `*` the element-wise product. – Nairolf Nov 25 '18 at 22:57

1 Answers1

1

Try:

Tsq <- n * d_mean %*% invS %*% t(d_mean). 

%*% is the matrix product and * the element-wise product.

Nairolf
  • 2,418
  • 20
  • 34