Example 4.4: The centroid and SSCP matrix for a sample of 22 observations from a bivariate normal population were
xbar' = [32.6 33.5] and s = [47.25 42.02, 42.02 111.09].

Test the hypothesis th mu' = [31 32] at the 1% level of significance.

Stata

/* HO: mu eq (31\32)  H1: mu ne (31\32) */
scalar n = 22
mat mu = (31\32)
mat xbar = (32.6\33.5)
mat s = (47.25, 42.02\42.02, 111.09)
scalar rows = rowsof(s)
mat x = xbar - mu
mat list mu, nonames
mat list xbar, nonames
mat list x, nonames
mat list s, nonames
scalar c = n * (n - 1)
mat T2 = c * x' * syminv(s) * x
mat list T2, nonames
scalar df2 = n - rows
scalar c = df2/((n - 1)*rows)
matrix F = c * T2
mat list F, nonames
display rows, df2
SAS IML
/* HO: mu eq {31,32}  H1: mu ne {31,32} */
proc iml;
start;
n = 22;
mu = {31, 32};
xbar = {32.6, 33.5};
s = {47.25 42.02, 42.02 111.09};
p = nrow(s);
x = xbar - mu;
print mu;
print xbar;
print x;
print s;
c = n * (n - 1);
T2 = c # T(x)*INV(s)*x;
print T2;
df2 = n - p;
c = df2/((n - 1)*p);
F = c # T2;
print F;
print p, df2;
finish;
run;