Example 4.3: Suppose that a sample of 25 observations is drawn from a bivariate normal population with unknown centroid mu and covariance matrix sigma = [16 8, 8 9].

If the sample centroid is found to be xbar' = [15.4 9.9], test the hypothesis that
mu' = [17 10] at the 5% significance level.

Stata

/* HO: mu eq {17\10}  H1: mu ne {17\10} */
scalar n=25
mat mu =(17\10)
mat xbar = (15.4\9.9)
mat sigma = (16,8\8,9)
mat x = xbar - mu
mat list mu, nonames
mat list xbar, nonames
mat list x, nonames
mat list sigma, nonames
mat Q = n * x'*syminv(sigma)*x
mat list Q
SAS IML
/* HO: mu eq {17,10}  H1: mu ne {17, 10} */
proc iml;
start;
n = 25;
mu = {17, 10};
xbar = {15.4, 9.9};
sigma = {16 8, 8 9};
x = xbar - mu;
print mu;
print xbar;
print x;
print sigma;
Q = n # T(x)*INV(sigma)*x;
print Q;
finish;
run;