/* Lesson 11-1 */ /* File Name = les1101.sas 06/29/06 */ data gakusei; infile 'all06ae.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; if sex^='M' & sex^='F' then delete; proc print data=gakusei(obs=10); run; proc reg data=gakusei; : 回帰分析 model taijyuu=shintyou kyoui; : 複数変量を指定 output out=outreg1 predicted=pred1 residual=resid1; : 結果項目の保存 run; : proc print data=outreg1(obs=15); run; : proc plot data=outreg1; : 散布図を描く where shintyou^=. and taijyuu^=. and kyoui^=.; : 解析に使ったデータのみ plot taijyuu*shintyou; : plot taijyuu*kyoui; : plot taijyuu*pred1; : 観測値と予測値 plot resid1*pred1 /vref=0; : 残差と予測値(残差解析) plot resid1*shintyou/vref=0; : 残差と説明変量(残差解析) plot resid1*kyoui /vref=0; : 残差と説明変量(残差解析) plot resid1*taijyuu /vref=0; : 残差と目的変量(残差解析) run; : : proc univariate data=outreg1 plot normal; : 残差を正規プロットして確かめる var resid1; : run; :
SAS システム 2 22:29 Wednesday, June 28, 2006 Model: MODEL1 Dependent Variable: TAIJYUU Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 8949.26487 4474.63244 134.351 0.0001 Error 108 3597.00215 33.30558 C Total 110 12546.26703 Root MSE 5.77110 R-square 0.7133 Dep Mean 58.58919 Adj R-sq 0.7080 C.V. 9.85011 SAS システム 3 22:29 Wednesday, June 28, 2006 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -111.760175 10.83266082 -10.317 0.0001 SHINTYOU 1 0.690656 0.06844278 10.091 0.0001 KYOUI 1 0.633945 0.07958346 7.966 0.0001 SAS システム 4 22:29 Wednesday, June 28, 2006 S H T K C I A J O A T R N I K I D R S P E T J Y T U R U R S O S Y Y O A K Y U E I B E O U U K A E W D D S X U U I U I R A 1 1 1 F 145.0 38.0 . J 10000 . . . 2 F 146.7 41.0 85 J 10000 Vodafone 6000 43.4444 -2.44443 3 F 148.0 42.0 . J 50000 . . . 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 41.1726 1.82744 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . . . 7 F 150.0 46.0 86 40000 . 46.3575 -0.35754 8 F 151.0 50.0 . G 60000 J-PHONE . . . 9 F 151.7 41.5 80 J 35000 . 43.7280 -2.22799 10 F 152.0 35.0 77 J 60000 DoCoMo 2000 42.0333 -7.03335 11 F 152.0 43.0 . J 20000 au 3500 . . 12 F 152.0 44.0 . 45000 DoCoMo 4000 . . 13 F 153.0 41.0 . J 125000 No . . . 14 F 153.0 42.0 . G 0 Vodafone 1000 . . 15 F 153.0 46.5 87 G 10000 . 49.0635 -2.56346 SAS システム 6 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*SHINTYOU. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | A A A | B BABAB BACAA A B A AA | A A B A B BBA BAGBC ACAA AABBA 50 + A A ADB CCEAC BBACB A | A A B A A | | | 0 + --+-----------+-----------+-----------+-----------+-----------+- 140 150 160 170 180 190 SHINTYOU SAS システム 7 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | AA A | A A C BBF CABA A A | A A C C AAF FBK AAAA A 50 + A A AA E JCHBBA | A A B B | | | 0 + ---+-------+-------+-------+-------+-------+-------+-------+-- 50 60 70 80 90 100 110 120 KYOUI SAS システム 8 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | A A A | AAA BCABABA ABABAA A | A B BAAAAAAABBAAFEBABBA AB 50 + B CACBCDCC CEA B | AAAB A | | | 0 + --+-----------+-----------+-----------+-----------+-----------+- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 9 22:29 Wednesday, June 28, 2006 プロット : RESID1*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | A B BAAA AAA ABAAA A A a 0 +---A-AB---CACBCCBB-AABAAAABAAEDB-BA--B-BAA---------A------------- l | A AAAA BD B A AAAAABBAAAC A | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 10 22:29 Wednesday, June 28, 2006 プロット : RESID1*SHINTYOU. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | B B A BBBAB ABAA a 0 +----------A-A-A-A-AAACB-CBDAB-BABBC-A-DAB-CAC-A-C-A-A--A--------- l | A A AA B AAACB A BAA B A ACBA A | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 140 150 160 170 180 190 SHINTYOU SAS システム 11 22:29 Wednesday, June 28, 2006 プロット : RESID1*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | B A A B A C ABD B a 0 +-----------------------B-A-G-CDDKCBAH-AABC---B--------A---------- l | AA B CA GACBD AA B A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 KYOUI SAS システム 12 22:29 Wednesday, June 28, 2006 プロット : RESID1*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | AA A A u | A BAAAB B BBBA AA a 0 +----------------BABDCCFDAB-CFDCCAB-E----A---------------- l | A A BDABB CAADABD A | -20 + ---+------------+------------+------------+------------+-- 20 40 60 80 100 TAIJYUU SAS システム 13 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Moments N 111 Sum Wgts 111 Mean 0 Sum 0 Std Dev 5.718393 Variance 32.70002 Skewness 1.279598 Kurtosis 2.460804 USS 3597.002 CSS 3597.002 CV . Std Mean 0.542766 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 111 Num > 0 44 M(Sign) -11.5 Pr>=|M| 0.0363 Sgn Rank -424 Pr>=|S| 0.2137 W:Normal 0.918304 Pr<W 0.0001 SAS システム 17 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 4 1 * 1 8 1 0 1 01234 5 0 0 55567777788889 14 | 0 00000111111122223333444 23 +--+--+ -0 44444443333333333333222222222222221111111111000 47 *-----* -0 9987777776666655555 19 | -1 0 1 | ----+----+----+----+----+----+----+----+----+-- Multiply Stem.Leaf by 10**+1 SAS システム 18 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Normal Probability Plot 22.5+ * | * | ***+*+++++ | +*******+ | +++******* | ************* |* * * ***+*****+ -12.5+++++++++ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
/* Lesson 11-2 */ /* File Name = les1102.sas 06/29/06 */ data gakusei; infile 'all06ae.prn' firstobs=2; input sex $ shintyou taijyuu kyoui jitaku $ kodukai carryer $ tsuuwa; if sex^='M' & sex^='F' then delete; : 性別不明は除外 if shintyou=. | taijyuu=. | kyoui=. then delete; : 欠損のあるデータは除外 proc print data=gakusei(obs=10); run; proc corr data=gakusei; : 相関係数 where sex='M'; : 男性について run; : : proc reg data=gakusei; : 回帰分析 model taijyuu=shintyou kyoui; : where sex='M'; : 男性について output out=outreg1 predicted=pred1 residual=resid1; : run; : proc print data=outreg1(obs=15); run; proc plot data=outreg1; where sex='M'; : 対象データについて plot taijyuu*shintyou; plot taijyuu*kyoui; plot taijyuu*pred1; plot resid1*(pred1 shintyou kyoui taijyuu)/vref=0; : まとめて記述 /* plot resid1*pred1 /vref=0; plot resid1*shintyou/vref=0; plot resid1*kyoui /vref=0; plot resid1*taijyuu /vref=0; */ run; proc univariate data=outreg1 plot normal; var resid1; run;
SAS システム 2 22:29 Wednesday, June 28, 2006 Correlation Analysis 5 'VAR' Variables: SHINTYOU TAIJYUU KYOUI KODUKAI TSUUWA Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum SHINTYOU 69 172.5 5.9843 11899.1 156.0 185.0 TAIJYUU 69 64.4304 8.8892 4445.7 46.0000 100.0 KYOUI 69 88.6087 8.3388 6114.0 56.0000 112.0 KODUKAI 65 52246.2 56402.6 3396000 0 300000 TSUUWA 13 6911.5 4285.4 89850.0 350.0 15000.0 SAS システム 3 22:29 Wednesday, June 28, 2006 Correlation Analysis Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / Number of Observations SHINTYOU TAIJYUU KYOUI KODUKAI TSUUWA SHINTYOU 1.00000 0.41125 0.18373 0.11592 0.18308 0.0 0.0004 0.1307 0.3578 0.5494 69 69 69 65 13 TAIJYUU 0.41125 1.00000 0.65178 -0.03654 0.18106 0.0004 0.0 0.0001 0.7726 0.5539 69 69 69 65 13 KYOUI 0.18373 0.65178 1.00000 -0.12556 -0.34058 0.1307 0.0001 0.0 0.3190 0.2548 69 69 69 65 13 KODUKAI 0.11592 -0.03654 -0.12556 1.00000 0.53593 0.3578 0.7726 0.3190 0.0 0.0591 65 65 65 65 13 TSUUWA 0.18308 0.18106 -0.34058 0.53593 1.00000 0.5494 0.5539 0.2548 0.0591 0.0 13 13 13 13 13 SAS システム 6 22:29 Wednesday, June 28, 2006 Model: MODEL1 Dependent Variable: TAIJYUU Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 2755.14865 1377.57433 34.728 0.0001 Error 66 2618.07744 39.66784 C Total 68 5373.22609 Root MSE 6.29824 R-square 0.5128 Dep Mean 64.43043 Adj R-sq 0.4980 C.V. 9.77526 SAS システム 7 22:29 Wednesday, June 28, 2006 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -69.177750 22.40914177 -3.087 0.0030 SHINTYOU 1 0.448119 0.12984037 3.451 0.0010 KYOUI 1 0.635714 0.09317892 6.823 0.0001 SAS システム 10 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*SHINTYOU. 凡例: A = 1 OBS, B = 2 OBS, ... TAIJYUU | 100 + A | A A | 75 + A A A A A AA | B B A D A A A B C A A D A A A | A A A A B A B A D B C A AAA A A A AA A 50 + A B A | | 25 + --+---------+---------+---------+---------+---------+---------+- 155 160 165 170 175 180 185 SHINTYOU SAS システム 11 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... TAIJYUU | 100 + A | A A | 75 + AA BA A A | A A C BAI DAAB A | A A B C AAD EBF AA A 50 + A A A A | | 25 + ---+-------+-------+-------+-------+-------+-------+-------+-- 50 60 70 80 90 100 110 120 KYOUI SAS システム 12 22:29 Wednesday, June 28, 2006 プロット : TAIJYUU*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... TAIJYUU | 100 + A | A A | 75 + B AAB A | BA A EABBDC BA B | A AA A AACABADDDAAAA 50 + A A AA | | 25 + --+-----------+-----------+-----------+-----------+-----------+- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 13 22:29 Wednesday, June 28, 2006 プロット : RESID1*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A A BA A DAA AA a 0 +---------------A---A----A-CA-AADAABC--BAB----------A------------- l | AA A B CCCAABD B | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 14 22:29 Wednesday, June 28, 2006 プロット : RESID1*SHINTYOU. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A B A C A B A B AA a 0 +----A-------A-----------A-B---A-C-A-A-B--AC---A-BA--B-A-A---A---- l | A B A A A B C A B A B A A BA A A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 155 160 165 170 175 180 185 SHINTYOU SAS システム 15 22:29 Wednesday, June 28, 2006 プロット : RESID1*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A B A B BD B a 0 +-----------------------B-A-B---ABABAF-AAAC---A--------A---------- l | A B CBBAF AAAB A A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 KYOUI SAS システム 16 22:29 Wednesday, June 28, 2006 プロット : RESID1*TAIJYUU. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A A B AAAC A A AA a 0 +----------A-------A--ADACB-DA-B-CB------A------------------------ l | A A CAAB FABBBA A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 40 50 60 70 80 90 100 TAIJYUU SAS システム 17 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Moments N 69 Sum Wgts 69 Mean 0 Sum 0 Std Dev 6.204929 Variance 38.50114 Skewness 1.25678 Kurtosis 1.998083 USS 2618.077 CSS 2618.077 CV . Std Mean 0.746986 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 69 Num > 0 27 M(Sign) -7.5 Pr>=|M| 0.0912 Sgn Rank -153.5 Pr>=|S| 0.3625 W:Normal 0.908577 Pr<W 0.0001 SAS システム 20 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 2 1 0 1 8 1 0 1 024 3 | 0 55555677788 11 | 0 00111123344 11 +--+--+ -0 444444333322211111111000 24 *-----* -0 998877766555555555 18 +-----+ ----+----+----+----+---- Multiply Stem.Leaf by 10**+1 SAS システム 21 22:29 Wednesday, June 28, 2006 Univariate Procedure Variable=RESID1 Residual Normal Probability Plot 22.5+ * | * + | *+*++++++ 7.5+ *******+ | +++******* | ************* -7.5+ * * * *******+ +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
where sex='M' and taijyuu<85;