/* Lesson 12-1 */
/* File Name = les1201.sas 07/06/06 */
data gakusei;
infile 'all06ae.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 21:09 Monday, July 3, 2006 プロット : SHINTYOU*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 47 オブザベーションが欠損値です.) SHINTYOU | 200 + | | A B A 180 + A BFCFDDBGA B B A A A | CAGELITQKHCGECB BC | AFAGIIFECCDEAA AA A A 160 + ADDGDIFDBABB | A ECAEDDA A A | A BAA 140 + ---+-----------+-----------+-----------+-----------+-- 20 40 60 80 100 TAIJYUU SAS システム 3 21:09 Monday, July 3, 2006 Principal Component Analysis 307 Observations 2 Variables Simple Statistics SHINTYOU TAIJYUU Mean 168.7013029 58.71596091 StD 8.0649770 9.30512751 SAS システム 4 21:09 Monday, July 3, 2006 Principal Component Analysis Covariance Matrix SHINTYOU TAIJYUU SHINTYOU 65.04385451 52.83873731 TAIJYUU 52.83873731 86.58539801 Total Variance = 151.62925252 Eigenvalues of the Covariance Matrix Eigenvalue Difference Proportion Cumulative PRIN1 129.740 107.851 0.855639 0.85564 PRIN2 21.889 . 0.144361 1.00000 SAS システム 5 21:09 Monday, July 3, 2006 Principal Component Analysis Eigenvectors PRIN1 PRIN2 SHINTYOU 0.632560 0.774511 TAIJYUU 0.774511 -.632560 SAS システム 6 21:09 Monday, July 3, 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.0372 -5.25283 2 F 146.7 41.0 85 J 10000 Vodafone 6000 -27.6384 -5.83384 3 F 148.0 42.0 . J 50000 . -26.0415 -5.45954 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -25.2670 -6.09210 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . -23.0854 -6.58271 7 F 150.0 46.0 86 40000 . -21.6784 -6.44075 8 F 151.0 50.0 . G 60000 J-PHONE . -17.9478 -8.19648 <中略> SAS システム 8 21:09 Monday, July 3, 2006 プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ... (NOTE: 47 オブザベーションが欠損値です.) PRIN2 | | 10 + A B A BA | AA CB CACBDABDAA B | A BC E AGBEGGDFHFCACD A 0 +-------------BBAABADCAJ-BGBFEEDIDACDC-G--A-----A--------- | AAACBCDC ADCA A BBBFEBBDC A A A | A AAAAA AAA A A AABBABC A BA AAC -10 + A A | AB A A | | | | A A -20 + | A A ---+------------+------------+------------+------------+-- -40 -20 0 20 40 PRIN1 SAS システム 9 21:09 Monday, July 3, 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 システム 47 21:09 Monday, July 3, 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 312 M 179.0 65.0 . J 0 . 11.3816 4.0014 313 M 168.0 74.0 . G 120000 DDIp 15000 11.3940 -10.2112 314 M 173.8 69.6 90 J 30000 DoCoMo 13000 11.6550 -2.9358 315 M 177.0 67.0 . 4000 DoCoMo 8000 11.6655 1.1873 316 M 180.0 65.0 88 J 30000 . 12.0142 4.7759 317 M 180.0 65.0 . G 100000 . 12.0142 4.7759 318 M 179.0 66.0 . 30000 . 12.1561 3.3689 319 M 168.0 75.0 . G 150000 . 12.1686 -10.8438 320 M 173.0 71.0 100 G 0 . 12.2333 -4.4410 321 M 178.0 67.0 . J 0 . 12.2981 1.9618 322 M 172.0 72.0 89 G 150000 . 12.3753 -5.8481 323 M 177.0 68.0 . G 80000 . 12.4400 0.5547 324 M 182.0 64.0 . G 0 . 12.5048 6.9575 325 M 165.0 78.0 . G 0 2098 12.5944 -15.0650 326 M 170.0 74.0 90 J 0 . 12.6592 -8.6622 327 M 175.0 70.0 95 G 50000 8000 12.7239 -2.2594 328 M 178.0 68.0 . J 100000 DoCoMo 4000 13.0726 1.3292 329 M 184.0 65.0 . G 140000 au 10000 14.5444 7.8740 330 M 170.0 78.0 . 45000 Vodafone 10000 15.7572 -11.1925 331 M 175.0 74.0 . J 0 . 15.8220 -4.7897 332 M 179.9 70.0 . J 15000 DoCoMo 700 15.8235 1.5357 333 M 180.0 70.0 94 G 70000 au 5000 15.8867 1.6131 334 M 180.0 70.0 . J 40000 au 4000 15.8867 1.6131 335 M 180.0 70.0 . . . 15.8867 1.6131 336 M 180.0 70.0 . J 40000 DoCoMo 6500 15.8867 1.6131 337 M 180.0 70.0 . 5000 3000 15.8867 1.6131 338 M 178.7 71.2 95 0 . 15.9938 -0.1528 339 M 173.5 76.5 . G 100000 . 16.8094 -7.5328 340 M 184.0 68.0 85 30000 . 16.8679 5.9763 341 M 182.0 70.0 90 G 100000 . 17.1518 3.1622 342 M 185.0 68.0 93 J 0 . 17.5005 6.7508 343 M 175.0 77.0 95 G 130000 . 18.1455 -6.6873 344 M 179.1 74.2 . 0 au 4000 18.5704 -1.7407 345 M 175.0 79.0 . J 0 No 0 19.6945 -7.9525 346 M 176.5 78.0 96 J 10000 . 19.8688 -6.1581 347 M 177.0 78.0 . J 40000 . 20.1851 -5.7709 348 M 181.5 74.5 . G 120000 au 3000 20.3209 -0.0716 349 M 178.0 78.0 110 G 50000 . 20.8177 -4.9964 350 M 169.3 88.5 94 J 0 . 23.4468 -18.3765 351 M 186.0 82.0 . J 0 . 28.9762 -1.3305 352 M 182.0 90.0 100 J 40000 . 32.6421 -9.4891 353 M 178.0 95.0 . 1000 No . 33.9844 -15.7499 354 M 178.0 100.0 112 G 60000 . 37.8569 -18.9127
/* Lesson 12-2 */ /* File Name = les1202.sas 07/06/06 */ data gakusei; infile 'all06ae.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
21:09 Monday, July 3, 2006
Principal Component Analysis
111 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.2801802 58.58918919 86.46846847
StD 8.7293530 10.67974592 7.50735375
SAS システム 4
21:09 Monday, July 3, 2006
Principal Component Analysis
Covariance Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 76.2016036 68.8150565 25.5320966
TAIJYUU 68.8150565 114.0569730 53.3632924
KYOUI 25.5320966 53.3632924 56.3603604
SAS システム 5
21:09 Monday, July 3, 2006
Principal Component Analysis
Total Variance = 246.61893694
Eigenvalues of the Covariance Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 191.486 152.179 0.776443 0.77644
PRIN2 39.307 23.480 0.159382 0.93583
PRIN3 15.827 . 0.064174 1.00000
SAS システム 6
21:09 Monday, July 3, 2006
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.533729 -.663468 0.524351
TAIJYUU 0.747236 0.079692 -.659763
KYOUI 0.395945 0.743949 0.538301
SAS システム 7
21:09 Monday, July 3, 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.7089 11.1601 0.02298
3 F 148.0 42.0 . J 50000 . . . .
4 F 148.0 43.0 80 J 50000 DoCoMo 4000 -24.5003 6.7372 -3.30639
5 F 148.9 . . J 60000 . . . .
6 F 149.0 45.0 . G 60000 . . . .
7 F 150.0 46.0 86 40000 . -18.8155 10.1131 -1.00718
8 F 151.0 50.0 . G 60000 J-PHONE . . . .
<中略>
SAS システム 9
21:09 Monday, July 3, 2006
プロット : PRIN2*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 243 オブザベーションが欠損値です.)
PRIN2 | |
20 + |
| A A A | A A A A
| AA ABABBB AC | A AC A A
0 +--------A----A-ABBDBDD-CAAACADEABBCAAB-AA-------A----------------
| A A A B AAB BBAD B
| A | BA A
-20 + |
| A |
| |
-40 + |
---+-----------+-----------+-----------+-----------+-----------+--
-40 -20 0 20 40 60
PRIN1
SAS システム 10
21:09 Monday, July 3, 2006
プロット : PRIN3*PRIN2. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 243 オブザベーションが欠損値です.)
PRIN3 | |
10 + |
| A A AB A| A A A
| A A A BA D EADC AABD A A
0 +----------------------A---A-A--B--A--FBDCEBCBA-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
21:09 Monday, July 3, 2006
プロット : PRIN3*PRIN1. 凡例: A = 1 OBS, B = 2 OBS, ...
(NOTE: 243 オブザベーションが欠損値です.)
PRIN3 | |
10 + |
| A |AA A C A A
| A A AAACA BB |ACDBCAA A D
0 +-----------AA--BDADCAC-AAAABB-FA-AA-A----------------------------
| 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 07/06/06 */
data gakusei;
infile 'all06ae.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
21:09 Monday, July 3, 2006
Principal Component Analysis
111 Observations
3 Variables
Simple Statistics
SHINTYOU TAIJYUU KYOUI
Mean 167.2801802 58.58918919 86.46846847
StD 8.7293530 10.67974592 7.50735375
SAS システム 4
21:09 Monday, July 3, 2006
Principal Component Analysis
Correlation Matrix
SHINTYOU TAIJYUU KYOUI
SHINTYOU 1.0000 0.7381 0.3896
TAIJYUU 0.7381 1.0000 0.6656
KYOUI 0.3896 0.6656 1.0000
SAS システム 5
21:09 Monday, July 3, 2006
Principal Component Analysis
Eigenvalues of the Correlation Matrix
Eigenvalue Difference Proportion Cumulative
PRIN1 2.20698 1.59359 0.735659 0.73566
PRIN2 0.61338 0.43375 0.204462 0.94012
PRIN3 0.17964 . 0.059880 1.00000
SAS システム 6
21:09 Monday, July 3, 2006
Principal Component Analysis
Eigenvectors
PRIN1 PRIN2 PRIN3
SHINTYOU 0.560178 -.651641 0.511434
TAIJYUU 0.635557 -.057882 -.769881
KYOUI 0.531289 0.756316 0.381731
[注意] データによっては解釈が困難なことも有り得る。
[参考] 「J:\コンピュータによる統計解析2(林 篤裕)\」に以下のデータを置いておく。