/* Lesson 12-1 */
/* File Name = les1201.sas 12/20/06 */
data gakusei;
infile 'all06be.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 09:44 Tuesday, December 19, 2006 プロット : SHINTYOU*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 48 オブザベーションが欠損値です.) SHINTYOU | 200 + | | A B A 180 + A BFCFDEBGA B B A A A | CAHELIVQLHDHEDB BC | AGAGJJFECCDEAA AA A A 160 + ADDGDIFDBACB | A ECBEDDA A A | A BAA 140 + ---+-----------+-----------+-----------+-----------+-- 20 40 60 80 100 TAIJYUU SAS システム 3 09:44 Tuesday, December 19, 2006 Principal Component Analysis 320 Observations 2 Variables Simple Statistics SHINTYOU TAIJYUU Mean 168.6884375 58.73687500 StD 8.0214734 9.24394996 SAS システム 4 09:44 Tuesday, December 19, 2006 Principal Component Analysis Covariance Matrix SHINTYOU TAIJYUU SHINTYOU 64.34403517 52.21149353 TAIJYUU 52.21149353 85.45061089 Total Variance = 149.79464606 Eigenvalues of the Covariance Matrix Eigenvalue Difference Proportion Cumulative PRIN1 128.165 106.535 0.855603 0.85560 PRIN2 21.630 . 0.144397 1.00000 SAS システム 5 09:44 Tuesday, December 19, 2006 Principal Component Analysis Eigenvectors PRIN1 PRIN2 SHINTYOU 0.633199 0.773989 TAIJYUU 0.773989 -.633199 SAS システム 6 09:44 Tuesday, December 19, 2006 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 . -31.0496 -5.20404 2 F 146.7 41.0 85 J 10000 Vodafone 6000 -27.6512 -5.78785 3 F 148.0 42.0 . J 50000 . -26.0541 -5.41487 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -25.2801 -6.04807 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . -23.0989 -6.54047 7 F 150.0 46.0 86 40000 . -21.6917 -6.39968 8 F 151.0 45.0 . J 20000 docomo 5000 -21.8325 -4.99249 9 F 151.0 50.0 . G 60000 J-PHONE . -17.9625 -8.15849 10 F 151.7 41.5 80 J 35000 . -24.0982 -2.23451 11 F 152.0 35.0 77 J 60000 DoCoMo 2000 -28.9392 2.11348 12 F 152.0 43.0 . J 20000 au 3500 -22.7473 -2.95211 13 F 152.0 44.0 . 45000 DoCoMo 4000 -21.9733 -3.58531 14 F 153.0 41.0 . J 125000 No . -23.6620 -0.91172 15 F 153.0 42.0 . G 0 Vodafone 1000 -22.8881 -1.54492 SAS システム 8 09:44 Tuesday, December 19, 2006 プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 48 オブザベーションが欠損値です.) PRIN2 | | 10 + A B A BA | AA CC CACBDABDAA B | A BC FA GDEGGDGHFCADD A 0 +-------------BBAABADCAJ-BGBFEEEIDACEC-G--A-----A--------- | AABCBCDC ADCA A BBBGEBCDC A A A | A AAAAA AAA A A ABBBABC A BB AAC -10 + A A | AB A A | | | | A A -20 + | A A ---+------------+------------+------------+------------+-- -40 -20 0 20 40 PRIN1 SAS システム 9 09:44 Tuesday, December 19, 2006 OBS SEX SHINTYOU TAIJYUU KYOUI JITAKU KODUKAI CARRYER TSUUWA PRIN1 PRIN2 1 F 148.9 . . J 60000 . . . 2 F 153.0 . . G 120000 DoCoMo 200 . . 3 F 155.0 . . J 20000 . . . <中略> SAS システム 7 09:21 Wednesday, December 20, 2006 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 308 M 176.0 66.0 . G 100000 docomo 5500 10.2513 1.0601 309 M 175.0 67.0 . J 45000 . 10.3920 -0.3471 310 M 179.9 63.0 . J 30000 . 10.3988 5.9782 311 M 174.0 68.0 . G 0 9000 10.5328 -1.7543 312 M 173.0 69.0 . J 60000 au 9000 10.6736 -3.1615 313 M 183.0 61.0 . J 100000 . 10.8137 9.6440 314 M 172.0 70.0 90 J 30000 . 10.8144 -4.5687 315 M 172.0 70.0 . J 20000 . 10.8144 -4.5687 316 M 177.0 66.0 87 G 40000 DoCoMo 6000 10.8845 1.8341 317 M 171.0 71.0 . G 160000 . 10.9552 -5.9759 318 M 176.0 67.0 83 G 0 . 11.0252 0.4269 319 M 181.0 63.0 . J 0 au 4000 11.0953 6.8296 320 M 175.0 68.0 80 150000 au 15000 11.1660 -0.9803 321 M 175.0 68.0 . J 0 DoCoMo 20000 11.1660 -0.9803 322 M 180.0 64.0 90 J 35000 . 11.2361 5.4224 323 M 180.0 64.0 90 G 60000 au 10000 11.2361 5.4224 324 M 179.0 65.0 . J 0 . 11.3769 4.0152 325 M 168.0 74.0 . G 120000 DDIp 15000 11.3776 -10.1974 326 M 178.0 66.0 95 J 30000 au 3000 11.5176 2.6081 327 M 173.8 69.6 90 J 30000 DoCoMo 13000 11.6446 -2.9222 328 M 177.0 67.0 . 4000 DoCoMo 8000 11.6584 1.2009 329 M 180.0 65.0 88 J 30000 . 12.0101 4.7892 330 M 180.0 65.0 . G 100000 . 12.0101 4.7892 331 M 179.0 66.0 . 30000 . 12.1508 3.3820 332 M 168.0 75.0 . G 150000 . 12.1516 -10.8306 333 M 173.0 71.0 100 G 0 . 12.2216 -4.4279 334 M 178.0 67.0 . J 0 . 12.2916 1.9749 335 M 172.0 72.0 89 G 150000 . 12.3624 -5.8351 336 M 172.0 72.0 . G 60000 au 3500 12.3624 -5.8351 337 M 177.0 68.0 . G 80000 . 12.4324 0.5677 338 M 182.0 64.0 . G 0 . 12.5025 6.9704 339 M 165.0 78.0 . G 0 2098 12.5739 -15.0522 340 M 170.0 74.0 90 J 0 . 12.6440 -8.6495 341 M 175.0 70.0 95 G 50000 8000 12.7140 -2.2467 342 M 178.0 68.0 . J 100000 DoCoMo 4000 13.0656 1.3417 343 M 184.0 65.0 . G 140000 au 10000 14.5429 7.8852 344 M 170.0 78.0 . 45000 Vodafone 10000 15.7399 -11.1822 345 M 175.0 74.0 . J 0 . 15.8100 -4.7795 346 M 179.9 70.0 . J 15000 DoCoMo 700 15.8167 1.5458 347 M 180.0 70.0 94 G 70000 au 5000 15.8800 1.6232 348 M 180.0 70.0 . J 40000 au 4000 15.8800 1.6232 349 M 180.0 70.0 . . . 15.8800 1.6232 350 M 180.0 70.0 . J 40000 DoCoMo 6500 15.8800 1.6232 351 M 180.0 70.0 . 5000 3000 15.8800 1.6232 352 M 178.7 71.2 95 0 . 15.9856 -0.1428 353 M 173.5 76.5 . G 100000 . 16.7951 -7.5235 354 M 184.0 68.0 85 30000 . 16.8648 5.9856 355 M 182.0 70.0 90 G 100000 . 17.1464 3.1712 356 M 185.0 68.0 93 J 0 . 17.4980 6.7596 357 M 175.0 77.0 95 G 130000 . 18.1319 -6.6791 358 M 179.1 74.2 . 0 au 4000 18.5609 -1.7328 359 M 175.0 79.0 . J 0 No 0 19.6799 -7.9455 360 M 176.5 78.0 96 J 10000 . 19.8557 -6.1513 361 M 177.0 78.0 . J 40000 . 20.1723 -5.7643 362 M 181.5 74.5 . G 120000 au 3000 20.3128 -0.0652 363 M 178.0 78.0 110 G 50000 . 20.8055 -4.9903 364 M 169.3 88.5 94 J 0 . 23.4236 -18.3726 365 M 186.0 82.0 . J 0 . 28.9671 -1.3312 366 M 182.0 90.0 100 J 40000 . 32.6262 -9.4928 367 M 178.0 95.0 . 1000 No . 33.9633 -15.7547 368 M 178.0 100.0 112 G 60000 . 37.8333 -18.9207
/* Lesson 12-2 */ /* File Name = les1202.sas 12/20/06 */ data gakusei; infile 'all06be.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
09:44 Tuesday, December 19, 2006
Principal Component Analysis
112 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3758929 58.65535714 86.54464286
StD 8.7487785 10.65456667 7.51681406
SAS システム 4
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Covariance Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 76.5411253 68.9044096 26.1186535
TAIJYUU 68.9044096 113.5197909 53.4470560
KYOUI 26.1186535 53.4470560 56.5024936
SAS システム 5
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Total Variance = 246.56340975
Eigenvalues of the Covariance Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 191.676 152.723 0.777391 0.77739
PRIN2 38.953 23.018 0.157983 0.93537
PRIN3 15.934 . 0.064626 1.00000
SAS システム 6
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.535900 -.663574 0.521997
TAIJYUU 0.744606 0.080040 -.662688
KYOUI 0.397962 0.743817 0.536995
SAS システム 7
09:44 Tuesday, December 19, 2006
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.8412 11.1579 0.07777
3 F 148.0 42.0 . J 50000 . . . .
4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -24.6451 6.7363 -3.25398
5 F 148.9 . . J 60000 . . . .
6 F 149.0 45.0 . G 60000 . . . .
7 F 150.0 46.0 86 40000 . -18.9517 10.1121 -0.97608
8 F 151.0 45.0 . J 20000 docomo 5000 . . .
9 F 151.0 50.0 . G 60000 J-PHONE . . . .
10 F 151.7 41.5 80 J 35000 . -23.7792 4.1610 -0.32856
11 F 152.0 35.0 77 J 60000 DoCoMo 2000 -29.6523 1.2102 2.52453
SAS システム 9
09:44 Tuesday, December 19, 2006
プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 256 オブザベーションが欠損値です.)
PRIN2 | |
20 + |
| A A A | A A A A
| AA ABABBB AC | A AC A A
0 +--------A----A-ABBDBEC-CAAACAEDABBCBAB-AA-------A----------------
| A A A B ABA BBBC B
| A | BA A
-20 + |
| A |
| |
-40 + |
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
SAS システム 10
09:44 Tuesday, December 19, 2006
プロット : PRIN3*PRIN2. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 256 オブザベーションが欠損値です.)
PRIN3 | |
10 + |
| A A A A A A A
| A A BAB D DBDC AABD A A
0 +----------------------A-A-A-A--B--A-AFBDCEBCBA-A-AAA-------------
| A A A A DB CBA AA
| A A AA A A AA A A
-10 + | A
| A | A
| |
-20 + |
---+-----------+-----------+-----------+-----------+-----------+--
-30 -20 -10 0 10 20
PRIN2
SAS システム 11
09:44 Tuesday, December 19, 2006
プロット : PRIN3*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 256 オブザベーションが欠損値です.)
PRIN3 | |
10 + |
| A | A A A A A A
| A A AAACA BB |BCDBC C D
0 +-----------AA--BDADCBB-AAAACAAEAB-AAA----------------------------
| A A AA B BA | B BBA AA
| A A AA A A AA A A
-10 + A |
| A | A
| |
-20 + |
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
/* Lesson 12-3 */
/* File Name = les1203.sas 12/20/06 */
data gakusei;
infile 'all06be.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
09:44 Tuesday, December 19, 2006
Principal Component Analysis
112 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3758929 58.65535714 86.54464286
StD 8.7487785 10.65456667 7.51681406
SAS システム 4
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Correlation Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 1.0000 0.7392 0.3972
TAIJYUU 0.7392 1.0000 0.6674
KYOUI 0.3972 0.6674 1.0000
SAS システム 5
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Eigenvalues of the Correlation Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 2.21344 1.60759 0.737814 0.73781
PRIN2 0.60585 0.42515 0.201951 0.93976
PRIN3 0.18071 . 0.060235 1.00000
SAS システム 6
09:44 Tuesday, December 19, 2006
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.560628 -.651397 0.511251
TAIJYUU 0.634287 -.059092 -.770836
KYOUI 0.532331 0.756432 0.380044
[注意] データによっては解釈が困難なことも有り得る。
[参考] 「J:\コンピュータによる統計解析6(林 篤裕)\」に以下のデータを置いておく。