/* Lesson 12-1 */
/* File Name = les1201.sas 07/12/07 */
data gakusei;
infile 'all07be.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
proc print data=gakusei(obs=10);
run;
proc plot data=gakusei; : 散布図
plot shintyou*taijyuu; : 元の変量のプロット
run; :
proc princomp cov data=gakusei out=outprin; : 主成分分析(分散共分散行列)
var shintyou taijyuu; : 2変量
run; :
proc print data=outprin(obs=15); : 結果の出力
run; :
proc plot data=outprin; : 散布図
plot prin2*prin1/vref=0 href=0; : 主成分得点のプロット
run; :
: 参考までに、
proc sort data=outprin; : 説明のためにソートしてみる
by prin1; : 第一主成分で
run; :
proc print data=outprin; : 体重がややが効いていることの確認
run; :
SAS システム 2 11:28 Tuesday, December 18, 2007 プロット : SHINTYOU*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 51 オブザベーションが欠損値です.) SHINTYOU | 200 + | | A B A A 180 + A BFCFDEBGA B B A A A | CAIELIVQLHDHEDB BC A | AGAGJJHFCCDEAA AA A A 160 + ADFHDIFDBACB | A ECBEDEA A A | A BAA 140 + ---+-----------+-----------+-----------+-----------+-- 20 40 60 80 100 TAIJYUU SAS システム 3 11:28 Tuesday, December 18, 2007 Principal Component Analysis 330 Observations 2 Variables Simple Statistics SHINTYOU TAIJYUU Mean 168.6387879 58.69636364 StD 8.0216280 9.31751230 SAS システム 4 11:28 Tuesday, December 18, 2007 Principal Component Analysis Covariance Matrix SHINTYOU TAIJYUU SHINTYOU 64.34651524 52.71886488 TAIJYUU 52.71886488 86.81603537 Total Variance = 151.16255061 Eigenvalues of the Covariance Matrix Eigenvalue Difference Proportion Cumulative PRIN1 129.484 107.805 0.856588 0.85659 PRIN2 21.679 . 0.143412 1.00000 SAS システム 5 11:28 Tuesday, December 18, 2007 Principal Component Analysis Eigenvectors PRIN1 PRIN2 SHINTYOU 0.629116 0.777312 TAIJYUU 0.777312 -.629116 SAS システム 6 11:28 Tuesday, December 18, 2007 S H T K C I A J O A T N I K I D R S P P T J Y T U R U R R O S Y Y O A K Y U I I B E O U U K A E W N N S X U U I U I R A 1 2 1 F 145.0 38.0 . J 10000 . -30.9591 -5.35430 2 F 146.7 41.0 85 J 10000 Vodafone 6000 -27.5576 -5.92021 3 F 148.0 42.0 . J 50000 . -25.9625 -5.53882 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -25.1852 -6.16794 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . -23.0014 -6.64886 7 F 150.0 46.0 86 40000 . -21.5950 -6.50066 8 F 150.0 . . J 10000 softbank 80 . . 9 F 151.0 45.0 . J 20000 docomo 5000 -21.7432 -5.09424 10 F 151.0 50.0 . G 60000 J-PHONE . -17.8566 -8.23982 11 F 151.7 41.5 80 J 35000 . -24.0234 -2.34821 12 F 152.0 35.0 77 J 60000 DoCoMo 2000 -28.8872 1.97423 13 F 152.0 43.0 . J 20000 au 3500 -22.6687 -3.05869 14 F 152.0 44.0 . 45000 DoCoMo 4000 -21.8914 -3.68781 15 F 153.0 41.0 . J 125000 No . -23.5942 -1.02315 SAS システム 8 11:28 Tuesday, December 18, 2007 プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 51 オブザベーションが欠損値です.) 20 + | | | PRIN2 | A | A | BB DACBBACCAA B | D DDAGCDEHDGFHCBDE A A 0 +---------A---BBBBBCFCAJ-BHGHFEGODACGBAG-AA-----A--------- | A AAAABBACEDAADCB C CBAEEBCEE A AA | AAA AA A A B B|BA A A AAB A | A | AA A A | | A A -20 + | A A ---+------------+------------+------------+------------+-- -40 -20 0 20 40 PRIN1 SAS システム 9 11:28 Tuesday, December 18, 2007 S H T K C I A J O A T N I K I D R S P P T J Y T U R U R R O S Y Y O A K Y U I I B E O U U K A E W N N S X U U I U I R A 1 2 1 F 148.9 . . J 60000 . . . 2 F 150.0 . . J 10000 softbank 80 . . 3 F 153.0 . . G 120000 DoCoMo 200 . . ≪中略≫ SAS システム 47 11:28 Tuesday, December 18, 2007 S H T K C I A J O A T N I K I D R S P P T J Y T U R U R R O S Y Y O A K Y U I I B E O U U K A E W N N S X U U I U I R A 1 2 315 M 173.0 68.0 93 30000 au 350 9.9755 -2.46304 316 M 173.0 68.0 . J 30000 . 9.9755 -2.46304 317 M 177.0 65.0 . G 60000 . 10.1601 2.53355 318 M 171.0 70.0 89 J 60000 . 10.2719 -5.27590 319 M 176.0 66.0 . G 100000 docomo 5500 10.3083 1.12712 320 M 179.9 63.0 . J 30000 . 10.4299 6.04599 321 M 175.0 67.0 . J 45000 . 10.4565 -0.27930 322 M 174.0 68.0 . G 0 9000 10.6046 -1.68573 323 M 173.0 69.0 . J 60000 au 9000 10.7528 -3.09216 324 M 183.0 61.0 . J 100000 . 10.8255 9.71388 325 M 172.0 70.0 90 J 30000 . 10.9010 -4.49859 326 M 172.0 70.0 . J 20000 . 10.9010 -4.49859 327 M 177.0 66.0 87 G 40000 DoCoMo 6000 10.9374 1.90443 328 M 171.0 71.0 . G 160000 . 11.0492 -5.90501 329 M 176.0 67.0 83 G 0 . 11.0856 0.4980 330 M 181.0 63.0 . J 0 au 4000 11.1219 6.9010 331 M 175.0 68.0 80 150000 au 15000 11.2338 -0.9084 332 M 175.0 68.0 . J 0 DoCoMo 20000 11.2338 -0.9084 333 M 180.0 64.0 90 J 35000 . 11.2701 5.4946 334 M 180.0 64.0 90 G 60000 au 10000 11.2701 5.4946 335 M 179.0 65.0 . J 0 . 11.4183 4.0882 336 M 168.0 74.0 . G 120000 DDIp 15000 11.4938 -10.1243 337 M 178.0 66.0 95 J 30000 au 3000 11.5665 2.6817 338 M 177.0 67.0 . 4000 DoCoMo 8000 11.7147 1.2753 339 M 173.8 69.6 90 J 30000 DoCoMo 13000 11.7225 -2.8478 340 M 180.0 65.0 88 J 30000 . 12.0474 4.8655 341 M 180.0 65.0 . G 100000 . 12.0474 4.8655 342 M 179.0 66.0 . 30000 . 12.1956 3.4591 343 M 168.0 75.0 . G 150000 . 12.2711 -10.7534 344 M 173.0 71.0 100 G 0 . 12.3075 -4.3504 345 M 178.0 67.0 . J 0 . 12.3438 2.0526 346 M 172.0 72.0 89 G 150000 . 12.4557 -5.7568 347 M 172.0 72.0 . G 60000 au 3500 12.4557 -5.7568 348 M 177.0 68.0 . G 80000 . 12.4920 0.6462 349 M 182.0 64.0 . G 0 . 12.5283 7.0492 350 M 165.0 78.0 . G 0 2098 12.7157 -14.9727 351 M 170.0 74.0 90 J 0 . 12.7521 -8.5697 352 M 175.0 70.0 95 G 50000 8000 12.7884 -2.1667 353 M 178.0 68.0 . J 100000 DoCoMo 4000 13.1211 1.4235 354 M 184.0 65.0 . G 140000 au 10000 14.5639 7.9747 355 M 170.0 78.0 . 45000 Vodafone 10000 15.8613 -11.0861 356 M 179.9 70.0 . J 15000 DoCoMo 700 15.8711 1.6422 357 M 175.0 74.0 . J 0 . 15.8976 -4.6831 358 M 180.0 70.0 94 G 70000 au 5000 15.9340 1.7199 359 M 180.0 70.0 . J 40000 au 4000 15.9340 1.7199 360 M 180.0 70.0 . . . 15.9340 1.7199 361 M 180.0 70.0 . J 40000 DoCoMo 6500 15.9340 1.71991 362 M 180.0 70.0 . 5000 3000 15.9340 1.71991 363 M 178.7 71.2 95 0 . 16.0489 -0.04554 364 M 184.0 68.0 85 30000 . 16.8958 6.08738 365 M 173.5 76.5 . G 100000 . 16.8972 -7.42187 366 M 182.0 70.0 90 G 100000 . 17.1922 3.27453 367 M 185.0 68.0 93 J 0 . 17.5249 6.86470 368 M 175.0 77.0 95 G 130000 . 18.2296 -6.57046 369 M 179.1 74.2 . 0 au 4000 18.6325 -1.6220 370 M 175.0 79.0 . J 0 No 0 19.7842 -7.8287 371 M 176.5 78.0 96 J 10000 . 19.9506 -6.0336 372 M 177.0 78.0 . J 40000 . 20.2651 -5.6450 373 M 181.5 74.5 . G 120000 au 3000 20.3755 0.0549 374 M 185.0 72.0 . J 30000 7000 20.6342 4.3482 375 M 178.0 78.0 110 G 50000 . 20.8942 -4.8676 376 M 173.0 84.0 46 G 350000 . 22.4125 -12.5289 377 M 169.3 88.5 94 J 0 . 23.5827 -18.2360 378 M 186.0 82.0 . J 0 . 29.0364 -1.1656 379 M 182.0 90.0 100 J 40000 . 32.7384 -9.3078 380 M 178.0 95.0 . 1000 No . 34.1085 -15.5626 381 M 178.0 100.0 112 G 60000 . 37.9951 -18.7082
/* Lesson 12-2 */ /* File Name = les1202.sas 07/12/07 */ data gakusei; infile 'all07be.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; proc print data=gakusei(obs=10); run; proc princomp cov data=gakusei out=outprin; : 主成分分析(分散共分散行列) var shintyou taijyuu kyoui; : 3変量 run; : proc print data=outprin(obs=15); : 結果の出力 run; : proc plot data=outprin; : 散布図 plot prin2*prin1/vref=0 href=0; : 主成分得点のプロット plot prin3*prin2/vref=0 href=0; : plot prin3*prin1/vref=0 href=0; : run; :
SAS システム 3
11:28 Tuesday, December 18, 2007
Principal Component Analysis
115 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3052174 58.69043478 86.12173913
StD 8.6987481 10.87084443 8.34576038
SAS システム 4
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Covariance Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 75.6682182 69.6030328 23.8230435
TAIJYUU 69.6030328 118.1752586 43.8415256
KYOUI 23.8230435 43.8415256 69.6517162
SAS システム 5
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Total Variance = 263.49519298
Eigenvalues of the Covariance Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 190.029 139.130 0.721184 0.72118
PRIN2 50.898 28.330 0.193167 0.91435
PRIN3 22.568 . 0.085649 1.00000
SAS システム 6
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.537350 -.409331 0.737363
TAIJYUU 0.752663 -.161672 -.638248
KYOUI 0.380465 0.897948 0.221214
SAS システム 7
11:28 Tuesday, December 18, 2007
S
H T K C
I A J O A T
N I K I D R S P P P
T J Y T U R U R R R
O S Y Y O A K Y U I I I
B E O U U K A E W N N N
S X U U I U I R A 1 2 3
1 F 145.0 38.0 . J 10000 . . . .
2 F 146.7 41.0 85 J 10000 Vodafone 6000 -24.8139 10.2871 -4.15078
3 F 148.0 42.0 . J 50000 . . . .
4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -24.5124 4.9419 -5.57477
5 F 148.9 . . J 60000 . . . .
6 F 149.0 45.0 . G 60000 . . . .
7 F 150.0 46.0 86 40000 . -18.8969 9.0259 -4.68751
8 F 150.0 . . J 10000 softbank 80 . . .
9 F 151.0 45.0 . J 20000 docomo 5000 . . .
10 F 151.0 50.0 . G 60000 J-PHONE . . . .
11 F 151.7 41.5 80 J 35000 . -23.6532 3.6699 -1.88916
12 F 152.0 35.0 77 J 60000 DoCoMo 2000 -29.5257 1.9041 1.81702
13 F 152.0 43.0 . J 20000 au 3500 . . .
14 F 152.0 44.0 . 45000 DoCoMo 4000 . . .
15 F 153.0 41.0 . J 125000 No . . . .
SAS システム 9
11:28 Tuesday, December 18, 2007
プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 266 オブザベーションが欠損値です.)
PRIN2 | |
20 + |
| A | A A A A
| AA BB BDA D | A AC A
0 +--------A----A-ABCEAED-DAAADADEABCDBAC-AA-A-----A----------------
| A AA A A C B BB A A
| AA | A AA
-20 + |
| A |
| |
-40 + | A
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
SAS システム 10
11:28 Tuesday, December 18, 2007
プロット : PRIN3*PRIN2. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 266 オブザベーションが欠損値です.)
PRIN3 | |
10 + A A A |
| AA A AB B |AA
| AA C BDFECA AA
0 +--------------------------------A---B-A--AA-BEDEDCBDA-----B------
| A A ACBAAEBBA ABA A
| A A AA B
-10 + A| A
| | A
| |A
-20 + A |
-+--------+--------+--------+--------+--------+--------+--------+-
-50 -40 -30 -20 -10 0 10 20
PRIN2
SAS システム 11
11:28 Tuesday, December 18, 2007
プロット : PRIN3*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 266 オブザベーションが欠損値です.)
PRIN3 | |
10 + | A A A
| |AB B C B
| A A AD BB B |ABBCBAA C
0 +---------------ABBBEBAABCAABA-CBAAB-AA------A--------------------
| AAA ABBA BA A A CAAAAB AA
| A A AA | A A
-10 + A A |
| | A
| | A
-20 + | A
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
/* Lesson 12-3 */
/* File Name = les1203.sas 07/12/07 */
data gakusei;
infile 'all07be.prn'
firstobs=2;
input sex $ shintyou taijyuu kyoui
jitaku $ kodukai carryer $ tsuuwa;
proc print data=gakusei(obs=10);
run; :
proc princomp data=gakusei out=outprin; : 相関係数を使って
var shintyou taijyuu kyoui; :
run; :
proc print data=outprin(obs=15);
run;
proc plot data=outprin;
plot prin2*prin1/vref=0 href=0;
plot prin3*prin2/vref=0 href=0;
plot prin3*prin1/vref=0 href=0;
run;
SAS システム 3
11:28 Tuesday, December 18, 2007
Principal Component Analysis
115 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3052174 58.69043478 86.12173913
StD 8.6987481 10.87084443 8.34576038
SAS システム 4
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Correlation Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 1.0000 0.7361 0.3282
TAIJYUU 0.7361 1.0000 0.4832
KYOUI 0.3282 0.4832 1.0000
SAS システム 5
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Eigenvalues of the Correlation Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 2.05121 1.34402 0.683735 0.68374
PRIN2 0.70719 0.46559 0.235730 0.91947
PRIN3 0.24160 . 0.080534 1.00000
SAS システム 6
11:28 Tuesday, December 18, 2007
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.598611 -.485960 0.636795
TAIJYUU 0.640369 -.187274 -.744887
KYOUI 0.481240 0.853681 0.199089
[注意] データによっては解釈が困難なことも有り得る。
[参考] 「J:\コンピュータによる統計解析06(林 篤裕)\」に以下のデータを置いておく。