/* Lesson 11-1 */ /* File Name = les1101.sas 12/13/06 */ data gakusei; infile 'all06be.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 14:11 Tuesday, December 12, 2006 Model: MODEL1 Dependent Variable: TAIJYUU Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 8975.29620 4487.64810 134.924 0.0001 Error 109 3625.40059 33.26056 C Total 111 12600.69679 Root MSE 5.76720 R-square 0.7123 Dep Mean 58.65536 Adj R-sq 0.7070 C.V. 9.83234 SAS システム 3 14:11 Tuesday, December 12, 2006 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -110.532541 10.74350068 -10.288 0.0001 SHINTYOU 1 0.685587 0.06817615 10.056 0.0001 KYOUI 1 0.629007 0.07934985 7.927 0.0001 SAS システム 4 14:11 Tuesday, December 12, 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.5086 -2.50864 3 F 148.0 42.0 . J 50000 . . . 4 F 148.0 43.0 80 J 50000 DoCoMo 4000 41.2549 1.74513 5 F 148.9 . . J 60000 . . . 6 F 149.0 45.0 . G 60000 . . . 7 F 150.0 46.0 86 40000 . 46.4001 -0.40009 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 . 43.7915 -2.29154 11 F 152.0 35.0 77 J 60000 DoCoMo 2000 42.1102 -7.11020 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 システム 6 14:11 Tuesday, December 12, 2006 プロット : TAIJYUU*SHINTYOU. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | A A A | B BABAB BACAA B 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 14:11 Tuesday, December 12, 2006 プロット : TAIJYUU*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | AA A | A A C BBF CACA 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 14:11 Tuesday, December 12, 2006 プロット : TAIJYUU*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A TAIJYUU | A A A | AAA BCABABA ABABC A | A B BAAAAAAABBAAFEBBABA C 50 + AA C DBCBEC CEA B | ABAA A | | | 0 + --+-----------+-----------+-----------+-----------+-----------+- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 9 14:11 Tuesday, December 12, 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 +----AAAA--C-DBCADB-AABAAAABAAEDB-BA-AB-BB----------A------------- l | A AAAA BD B A AAAABABA CA A A | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 10 14:11 Tuesday, December 12, 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-B-A--A--------- l | A A AA B AAACB A BAA B A AABBA A | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 140 150 160 170 180 190 SHINTYOU SAS システム 11 14:11 Tuesday, December 12, 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-CDDKCCAH-AABC---B--------A---------- l | AA B CA GABBD AA C A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 KYOUI SAS システム 12 14:11 Tuesday, December 12, 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-CFDCDAB-E----A---------------- l | A A BDABB CAADABCAA | -20 + ---+------------+------------+------------+------------+-- 20 40 60 80 100 TAIJYUU SAS システム 13 14:11 Tuesday, December 12, 2006 Univariate Procedure Variable=RESID1 Residual Moments N 112 Sum Wgts 112 Mean 0 Sum 0 Std Dev 5.715004 Variance 32.66127 Skewness 1.299099 Kurtosis 2.519207 USS 3625.401 CSS 3625.401 CV . Std Mean 0.540017 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 112 Num > 0 45 M(Sign) -11 Pr>=|M| 0.0467 Sgn Rank -430 Pr>=|S| 0.2134 W:Normal 0.916104 Pr<W 0.0001 SAS システム 17 14:11 Tuesday, December 12, 2006 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 4 1 * 1 8 1 0 1 01234 5 0 0 55667777788889 14 | 0 000000111111122223333444 24 +--+--+ -0 4444443333333333333332222222222221111111111100 46 *-----* -0 98877777766655555555 20 | -1 0 1 | ----+----+----+----+----+----+----+----+----+- Multiply Stem.Leaf by 10**+1 SAS システム 18 14:11 Tuesday, December 12, 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 12/13/06 */ data gakusei; infile 'all06be.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 14:11 Tuesday, December 12, 2006 Correlation Analysis 5 'VAR' Variables: SHINTYOU TAIJYUU KYOUI KODUKAI TSUUWA Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum SHINTYOU 70 172.5 5.9777 12077.1 156.0 185.0 TAIJYUU 70 64.4529 8.8266 4511.7 46.0000 100.0 KYOUI 70 88.7000 8.3133 6209.0 56.0000 112.0 KODUKAI 66 51909.1 56034.0 3426000 0 300000 TSUUWA 14 6632.1 4247.9 92850.0 350.0 15000.0 SAS システム 3 14:11 Tuesday, December 12, 2006 Correlation Analysis Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / Number of Observations SHINTYOU TAIJYUU KYOUI KODUKAI TSUUWA SHINTYOU 1.00000 0.41097 0.19202 0.10975 0.11552 0.0 0.0004 0.1113 0.3803 0.6941 70 70 70 66 14 TAIJYUU 0.41097 1.00000 0.65083 -0.03754 0.14591 0.0004 0.0 0.0001 0.7647 0.6187 70 70 70 66 14 KYOUI 0.19202 0.65083 1.00000 -0.12942 -0.38661 0.1113 0.0001 0.0 0.3003 0.1721 70 70 70 66 14 KODUKAI 0.10975 -0.03754 -0.12942 1.00000 0.53783 0.3803 0.7647 0.3003 0.0 0.0473 66 66 66 66 14 TSUUWA 0.11552 0.14591 -0.38661 0.53783 1.00000 0.6941 0.6187 0.1721 0.0473 0.0 14 14 14 14 14 SAS システム 6 14:11 Tuesday, December 12, 2006 Model: MODEL1 Dependent Variable: TAIJYUU Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 2733.55626 1366.77813 34.660 0.0001 Error 67 2642.09817 39.43430 C Total 69 5375.65443 Root MSE 6.27967 R-square 0.5085 Dep Mean 64.45286 Adj R-sq 0.4938 C.V. 9.74305 SAS システム 7 14:11 Tuesday, December 12, 2006 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -67.118947 22.18681240 -3.025 0.0035 SHINTYOU 1 0.438471 0.12886608 3.403 0.0011 KYOUI 1 0.630467 0.09266063 6.804 0.0001 SAS システム 10 14:11 Tuesday, December 12, 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 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 14:11 Tuesday, December 12, 2006 プロット : TAIJYUU*KYOUI. 凡例: A = 1 OBS, B = 2 OBS, ... TAIJYUU | 100 + A | A A | 75 + AA BA A A | A A C BAI DABB 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 14:11 Tuesday, December 12, 2006 プロット : TAIJYUU*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... TAIJYUU | 100 + A | A A | 75 + B A BA A | BA AADBABDCB B B | A AA A AACABCCCDAAAA 50 + A A AA | | 25 + --+-----------+-----------+-----------+-----------+-----------+- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 13 14:11 Tuesday, December 12, 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 AACAA A A a 0 +---------------A---A----A-CA-B-DB-BC-B-BA---------A-------------- l | AA A BACBCAABD A B | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of TAIJYUU SAS システム 14 14:11 Tuesday, December 12, 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 A BA A A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 155 160 165 170 175 180 185 SHINTYOU SAS システム 15 14:11 Tuesday, December 12, 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 AAAC A A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 KYOUI SAS システム 16 14:11 Tuesday, December 12, 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 FABBBAA A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 40 50 60 70 80 90 100 TAIJYUU SAS システム 17 14:11 Tuesday, December 12, 2006 Univariate Procedure Variable=RESID1 Residual Moments N 70 Sum Wgts 70 Mean 0 Sum 0 Std Dev 6.187995 Variance 38.29128 Skewness 1.28436 Kurtosis 2.087816 USS 2642.098 CSS 2642.098 CV . Std Mean 0.739607 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 70 Num > 0 28 M(Sign) -7 Pr>=|M| 0.1196 Sgn Rank -157.5 Pr>=|S| 0.3604 W:Normal 0.905397 Pr<W 0.0001 SAS システム 20 14:11 Tuesday, December 12, 2006 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 2 1 0 1 8 1 0 1 024 3 | 0 55555667788 11 | 0 001111123344 12 +--+--+ -0 44444433322221111111000 23 *-----* -0 9988777665555555555 19 +-----+ ----+----+----+----+--- Multiply Stem.Leaf by 10**+1 SAS システム 21 14:11 Tuesday, December 12, 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;