|
|
Output from imlsscp.sas |
Source
0 Graphs |
|---|
NOTE: Capture of log output started.
NOTE: %INCLUDE (level 1) file n:\psy6140\examples\iml\imlsscp.sas is file
n:\psy6140\examples\iml\imlsscp.sas.
1277 +title 'IMLSSCP: Computing Cross-product Summary Matrices'; 1278 + * ------- -----------------------------------------; 1279 +proc iml;
IML Ready
1280 + reset print log fuzz fw=4;
1281 +*[GREEN AND CARROLL, TABLE 2.3];
1282 +Y ={1 0 1 4 3 2 5 6 9 13 15 16};
Y 1 row 12 cols (numeric)
1 0 1 4 3 2 5 6 9 13 15 16
1283 +X1={1 2 2 3 5 5 6 7 10 11 11 12};
X1 1 row 12 cols (numeric)
1 2 2 3 5 5 6 7 10 11 11 12
1284 +X2={1 1 2 2 4 6 5 4 8 7 9 10};
X2 1 row 12 cols (numeric)
1 1 2 2 4 6 5 4 8 7 9 10
1285 +*-- Shape variables into a matrix; 1286 +A = t(Y)|| t(X1) || t(X2);
A 12 rows 3 cols (numeric)
1 1 1
0 2 1
1 2 2
4 3 2
3 5 4
2 5 6
5 6 5
6 7 4
9 10 8
13 11 7
15 11 9
16 12 10
1287 +reset fw=6; 1288 +*-- 1. Raw cross-product matrix, X'X ; 1289 +XPX = t(A) * A;
XPX 3 rows 3 cols (numeric)
823 702 542
702 639 497
542 497 397
1290 +*-- 2. (mean-corrected) SSCP matrix; 1291 +MEAN = A[:,];
MEAN 1 row 3 cols (numeric)
6.25 6.25 4.9167
1292 +n = nrow(A);
N 1 row 1 col (numeric)
12
1293 +p = ncol(A);
P 1 row 1 col (numeric)
3
1294 + * subtract col means and take crossproducts; 1295 +D = A - shape(MEAN, n, p);
D 12 rows 3 cols (numeric)
-5.25 -5.25 -3.917
-6.25 -4.25 -3.917
-5.25 -4.25 -2.917
-2.25 -3.25 -2.917
-3.25 -1.25 -0.917
-4.25 -1.25 1.0833
-1.25 -0.25 0.0833
-0.25 0.75 -0.917
2.75 3.75 3.0833
6.75 4.75 2.0833
8.75 4.75 4.0833
9.75 5.75 5.0833
1296 +XPX = t(D) * D;
XPX 3 rows 3 cols (numeric)
354.25 233.25 173.25
233.25 170.25 128.25
173.25 128.25 106.92
1297 +*-- 3. variance - covariance matrix; 1298 +COV = XPX / (n-1);
COV 3 rows 3 cols (numeric)
32.205 21.205 15.75
21.205 15.477 11.659
15.75 11.659 9.7197
1299 +*-- 4. correlation matrix; 1300 + * Extract standard deviations, divide left and right; 1301 +STD = diag(COV)##.5;
STD 3 rows 3 cols (numeric)
5.6749 0 0
0 3.9341 0
0 0 3.1176
1302 +CORR = inv(STD) * COV * inv(STD);
CORR 3 rows 3 cols (numeric)
1 0.9498 0.8902
0.9498 1 0.9506
0.8902 0.9506 1
1303 +*-- 5. labels for result;
1304 +label = {Y X1 X2};
LABEL 1 row 3 cols (character, size 2)
Y X1 X2
1305 +print COV[r=label c=label] CORR[r=label c=label];
COV Y X1 X2 CORR Y X1 X2
Y 32.205 21.205 15.75 Y 1 0.9498 0.8902
X1 21.205 15.477 11.659 X1 0.9498 1 0.9506
X2 15.75 11.659 9.7197 X2 0.8902 0.9506 1
1306 +quit;
Exiting IML.
NOTE: The PROCEDURE IML used 0.16 seconds.
1307 +
NOTE: %INCLUDE (level 1) ending.