Example 7: Perform a discriminant analysis on 244 subjects divided into 3 groups of 85, 93 and 66 respectively. The analysis uses three variables. The W and B SSCP matrices are given in the program below.
Tatsuoka's results: Proc IML results:
Eigenvalues - 1.080548 .324078 1.0805177 0.3241748
Eigenvectors - v1 v2 v1 v2
.3524 .9145 0.0060257 0.0147046
-.7331 .1960 -0.01254 0.0031524
.5818 -.3540 0.0099517 -0.005692
Chi-square - 243.19 67.37 243.21749 67.389473
degrees of freedom - 6 2 6 2
Standardized Coefficients - v*1 v*2 v*1 v*2
22.22 57.6 0.379566 0.976084
-48.7 13.0 -0.789904 0.2092569
30.1 -18.3 0.6268675 -0.377862
Sturcture Matrix - F1 F2 F1 F2
.3927 .9124 0.3216749 0.9369232
-.8577 .2387 -0.765185 0.2669573
.6012 -.2655 0.4674273 -0.258791
-------------------------------------------------------------------------------
proc iml;
start;
reset noname;
w = {3967.8301 351.6142 76.6342,
351.6142 4406.2517 235.4365,
76.6342 235.4365 2683.3164};
b = {1572.7441 -773.0506 273.6214,
-773.0506 2889.3193 -1405.9955,
273.6214 -1405.9955 691.6068};
upper = root(w);
lower = t(upper);
a = inv(lower)*b*inv(upper);
call eigen(l,uv,a);
v = inv(upper)*uv;
print "Raw Eigenvalues", l;
l = l(|{1 2}|);
print "Trimmed Eigenvalues", l;
d = diag(l);
v = v(|{1 2 3},{1 2}|);
print "Eigenvectors",v;
/* Canonical Correlations */
l1 = l(|1|);
l2 = l(|2|);
rc1 = sqrt(l1/(1+l1));
rc2 = sqrt(l2/(1+l2));
print "Canonical Correlations";
print rc1;
print rc2;
/* tests of significance */
n =244;
k = 3;
p = nrow(w);
t1 = 1 - rc1*rc1;
t2 = 1 - rc2*rc2;
lambda1 = t1*t2;
lambda2 = t2;
c1 = (n-1-(p+k)/2);
v1 = -c1*log(lambda1);
v2 = -c1*log(lambda2);
print "Chi-square";
print v1;
print v2;
df1 = p*(k-1);
df2 = (p-1)*(k-2);
print "degrees of freedom";
print df1;
print df2;
/* end tests of significance */
t1 = sqrt(diag(w));
t1 = t1(|{1 2},{1 2}|);
r = v*t1;
print "Standardized Weights",r;
m1 = t(v)*w*v;
m2 = inv(sqrt(diag(m1)));
m3 = inv(sqrt(diag(w)));
a = m3*w*v*m2;
print "Discriminant Structure Matrix",a;
finish;
run;
-------------------------------------------------------------------------------
Raw Eigenvalues
1.0805177
0.3241748
-0.000067
Trimmed Eigenvalues
1.0805177
0.3241748
Eigenvectors
0.0060257 0.0147046
-0.01254 0.0031524
0.0099517 -0.005692
Canonical Correlations
0.7206597
0.4947855
Chi-square
243.21749
67.389473
degrees of freedom
6
2
Standardized Weights
0.379566 0.976084
-0.789904 0.2092569
0.6268675 -0.377862
Discriminant Structure Matrix
0.3216749 0.9369232
-0.765185 0.2669573
0.4674273 -0.258791