/* Lesson 13-1 */
/* File Name = les1301.sas 07/12/07 */
data gakusei;
infile 'all07ae.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 10:30 Monday, July 9, 2007 プロット : SHINTYOU*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 49 オブザベーションが欠損値です.) SHINTYOU | 200 + | | A B A A 180 + A BFCFDEBGA B B A A A | CAHELIVQLHDHEDB BC A | AGAGJJGFCCDEAA AA A A 160 + ADEHDIFDBACB | A ECBEDDA A A | A BAA 140 + ---+-----------+-----------+-----------+-----------+-- 20 40 60 80 100 TAIJYUU SAS システム 3 10:30 Monday, July 9, 2007 Principal Component Analysis 326 Observations 2 Variables Simple Statistics SHINTYOU TAIJYUU Mean 168.6926380 58.78466258 StD 8.0313352 9.33278478 SAS システム 4 10:30 Monday, July 9, 2007 Principal Component Analysis Covariance Matrix SHINTYOU TAIJYUU SHINTYOU 64.50234563 52.81268674 TAIJYUU 52.81268674 87.10087173 Total Variance = 151.60321737 Eigenvalues of the Covariance Matrix Eigenvalue Difference Proportion Cumulative PRIN1 129.810 108.016 0.856245 0.85625 PRIN2 21.794 . 0.143755 1.00000 SAS システム 5 10:30 Monday, July 9, 2007 Principal Component Analysis Eigenvectors PRIN1 PRIN2 SHINTYOU 0.628802 0.777565 TAIJYUU 0.777565 -.628802 SAS システム 6 10:30 Monday, July 9, 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 . -31.0594 -5.35312 2 F 146.7 41.0 85 J 10000 Vodafone 6000 -27.6578 -5.91767 3 F 148.0 42.0 . J 50000 . -26.0627 -5.53564 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -25.2852 -6.16444 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . -23.1013 -6.64448 7 F 150.0 46.0 86 40000 . -21.6949 -6.49572 8 F 151.0 45.0 . J 20000 docomo 5000 -21.8436 -5.08935 9 F 151.0 50.0 . G 60000 J-PHONE . -17.9558 -8.23336 10 F 151.7 41.5 80 J 35000 . -24.1250 -2.34424 11 F 152.0 35.0 77 J 60000 DoCoMo 2000 -28.9905 1.97624 12 F 152.0 43.0 . J 20000 au 3500 -22.7700 -3.05418 13 F 152.0 44.0 . 45000 DoCoMo 4000 -21.9924 -3.68298 14 F 153.0 41.0 . J 125000 No . -23.6963 -1.01901 15 F 153.0 42.0 . G 0 Vodafone 1000 -22.9187 -1.64781 SAS システム 8 10:30 Monday, July 9, 2007 プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 49 オブザベーションが欠損値です.) 20 + | | | PRIN2 | A | A | BB DACBBACCAA B | C GBAFCCFHDFFHCBED A A 0 +---------A---BBBBDAFCAJ-CHFGFEHNDACGC-G-AA-----A--------- | A AAAABBACECAADCB C CBCDDBCEE 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 10:30 Monday, July 9, 2007 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 153.0 . . 50000 5000 . . ≪中略≫ SAS システム 47 10:30 Monday, July 9, 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 312 M 171.0 70 89 J 60000 . 10.1715 -5.25811 313 M 176.0 66 . G 100000 docomo 5500 10.2053 1.14493 314 M 179.9 63 . J 30000 . 10.3249 6.06384 315 M 175.0 67 . J 45000 . 10.3540 -0.26144 316 M 174.0 68 . G 0 9000 10.5028 -1.66781 317 M 173.0 69 . J 60000 au 9000 10.6516 -3.07417 318 M 183.0 61 . J 100000 . 10.7191 9.73190 319 M 172.0 70 90 J 30000 . 10.8003 -4.48054 320 M 172.0 70.0 . J 20000 . 10.8003 -4.4805 321 M 177.0 66.0 87 G 40000 DoCoMo 6000 10.8341 1.9225 322 M 171.0 71.0 . G 160000 . 10.9491 -5.8869 323 M 176.0 67.0 83 G 0 . 10.9828 0.5161 324 M 181.0 63.0 . J 0 au 4000 11.0166 6.9192 325 M 175.0 68.0 80 150000 au 15000 11.1316 -0.8902 326 M 175.0 68.0 . J 0 DoCoMo 20000 11.1316 -0.8902 327 M 180.0 64.0 90 J 35000 . 11.1654 5.5128 328 M 180.0 64.0 90 G 60000 au 10000 11.1654 5.5128 329 M 179.0 65.0 . J 0 . 11.3141 4.1064 330 M 168.0 74.0 . G 120000 DDIp 15000 11.3954 -10.1060 331 M 178.0 66.0 95 J 30000 au 3000 11.4629 2.7001 332 M 177.0 67.0 . 4000 DoCoMo 8000 11.6116 1.2937 333 M 173.8 69.6 90 J 30000 DoCoMo 13000 11.6212 -2.8294 334 M 180.0 65.0 88 J 30000 . 11.9429 4.8840 335 M 180.0 65.0 . G 100000 . 11.9429 4.8840 336 M 179.0 66 . 30000 . 12.0917 3.4776 337 M 168.0 75 . G 150000 . 12.1729 -10.7348 338 M 173.0 71 100 G 0 . 12.2067 -4.3318 339 M 178.0 67 . J 0 . 12.2405 2.0713 340 M 172.0 72 89 G 150000 . 12.3555 -5.7381 341 M 172.0 72 . G 60000 au 3500 12.3555 -5.7381 342 M 177.0 68 . G 80000 . 12.3892 0.6649 343 M 182.0 64 . G 0 . 12.4230 7.0679 344 M 165.0 78.0 . G 0 2098 12.6192 -14.9539 345 M 170.0 74.0 90 J 0 . 12.6530 -8.5509 346 M 175.0 70.0 95 G 50000 8000 12.6867 -2.1478 347 M 178.0 68.0 . J 100000 DoCoMo 4000 13.0180 1.4425 348 M 184.0 65.0 . G 140000 au 10000 14.4581 7.9943 349 M 170.0 78.0 . 45000 Vodafon 10000 15.7632 -11.0661 350 M 179.9 70.0 . J 15000 DoCoMo 700 15.7679 1.6622 351 M 175.0 74.0 . J 0 . 15.7970 -4.6631 352 M 180.0 70.0 94 G 70000 au 5000 15.8308 1.73998 353 M 180.0 70.0 . J 40000 au 4000 15.8308 1.73998 354 M 180.0 70.0 . . . 15.8308 1.73998 355 M 180.0 70.0 . J 40000 DoCoMo 6500 15.8308 1.73998 356 M 180.0 70.0 . 5000 3000 15.8308 1.73998 357 M 178.7 71.2 95 0 . 15.9464 -0.02542 358 M 184.0 68.0 85 30000 . 16.7908 6.10784 359 M 173.5 76.5 . G 100000 . 16.7977 -7.40141 360 M 182.0 70.0 90 G 100000 . 17.0884 3.2951 361 M 185.0 68.0 93 J 0 . 17.4196 6.8854 362 M 175.0 77.0 95 G 130000 . 18.1297 -6.5495 363 M 179.1 74.2 . 0 au 4000 18.5306 -1.6008 364 M 175.0 79.0 . J 0 No 0 19.6848 -7.8071 365 M 176.5 78.0 96 J 10000 . 19.8505 -6.0119 366 M 177.0 78.0 . J 40000 . 20.1649 -5.6231 367 M 181.5 74.5 . G 120000 au 3000 20.2730 0.0767 368 M 185.0 72.0 . J 30000 7000 20.5299 4.3702 369 M 178.0 78.0 110 G 50000 . 20.7937 -4.8456 370 M 173.0 84.0 46 G 350000 . 22.3150 -12.5062 371 M 169.3 88.5 94 J 0 . 23.4875 -18.2128 372 M 186.0 82.0 . J 0 . 28.9343 -1.1403 373 M 182.0 90.0 100 J 40000 . 32.6397 -9.2809 374 M 178.0 95.0 . 1000 No . 34.0123 -15.5352 375 M 178.0 100.0 112 G 60000 . 37.9001 -18.6792
/* Lesson 13-2 */ /* File Name = les1302.sas 07/12/07 */ data gakusei; infile 'all07ae.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
10:30 Monday, July 9, 2007
Principal Component Analysis
114 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3517544 58.79298246 86.17543860
StD 8.7227627 10.86282708 8.36262822
SAS システム 4
10:30 Monday, July 9, 2007
Principal Component Analysis
Covariance Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 76.0865898 69.6653222 23.7439373
TAIJYUU 69.6653222 118.0010123 43.5906226
KYOUI 23.7439373 43.5906226 69.9335507
SAS システム 5
10:30 Monday, July 9, 2007
Principal Component Analysis
Total Variance = 264.02115277
Eigenvalues of the Covariance Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 189.966 138.636 0.719512 0.71951
PRIN2 51.330 28.606 0.194417 0.91393
PRIN3 22.724 . 0.086070 1.00000
SAS システム 6
10:30 Monday, July 9, 2007
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.539085 -.407903 0.736887
TAIJYUU 0.751825 -.161336 -.639320
KYOUI 0.379667 0.898658 0.219698
SAS システム 7
10:30 Monday, July 9, 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.9565 10.2382 -4.10085
3 F 148.0 42.0 . J 50000 . . . .
4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -24.6504 4.8920 -5.52002
5 F 148.9 . . J 60000 . . . .
6 F 149.0 45.0 . G 60000 . . . .
7 F 150.0 46.0 86 40000 . -19.0388 8.9841 -4.64602
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.7835 3.6248 -1.83456
11 F 152.0 35.0 77 J 60000 DoCoMo 2000 -29.6477 1.8551 1.88299
12 F 152.0 43.0 . J 20000 au 3500 . . .
13 F 152.0 44.0 . 45000 DoCoMo 4000 . . .
14 F 153.0 41.0 . J 125000 No . . . .
15 F 153.0 42.0 . G 0 Vodafone 1000 . . .
SAS システム 9
10:30 Monday, July 9, 2007
プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 261 オブザベーションが欠損値です.)
PRIN2 | |
20 + |
| A | A A A A
| AA AAB BDA D | A AC A
0 +--------A----A-ABCDAED-DAAADAEDABDCBAC-AA-A-----A----------------
| A A A A A C BAAB A A
| A A | A AA
-20 + |
| A |
| |
-40 + | A
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
SAS システム 10
10:30 Monday, July 9, 2007
プロット : PRIN3*PRIN2. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 261 オブザベーションが欠損値です.)
PRIN3 | |
10 + A A A |
| AA A AB B |AA
| AA C BCFECA 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
10:30 Monday, July 9, 2007
プロット : PRIN3*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 261 オブザベーションが欠損値です.)
PRIN3 | |
10 + | A A A
| |AB B C B
| A A AC BB B |ABBCBAA C
0 +---------------ACABEBB-BCAABAABBAAB-B-------A--------------------
| AAA ABBA BA A A CAAABA AA
| A A AA | A A
-10 + A A |
| | A
| | A
-20 + | A
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
/* Lesson 13-3 */
/* File Name = les1303.sas 07/12/07 */
data gakusei;
infile 'all07ae.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
10:30 Monday, July 9, 2007
Principal Component Analysis
114 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.3517544 58.79298246 86.17543860
StD 8.7227627 10.86282708 8.36262822
SAS システム 4
10:30 Monday, July 9, 2007
Principal Component Analysis
Correlation Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 1.0000 0.7352 0.3255
TAIJYUU 0.7352 1.0000 0.4799
KYOUI 0.3255 0.4799 1.0000
SAS システム 5
10:30 Monday, July 9, 2007
Principal Component Analysis
Eigenvalues of the Correlation Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 2.04697 1.33665 0.682322 0.68232
PRIN2 0.71032 0.46760 0.236772 0.91909
PRIN3 0.24272 . 0.080906 1.00000
SAS システム 6
10:30 Monday, July 9, 2007
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.599200 -.483881 0.637823
TAIJYUU 0.640769 -.187770 -.744418
KYOUI 0.479974 0.854752 0.197544
[注意] データによっては解釈が困難なことも有り得る。
[参考] 「J:\コンピュータによる統計解析02(林 篤裕)\」に以下のデータを置いておく。