/* Lesson 11-1 */ /* File Name = les1101.sas 12/18/03 */ data gakusei; infile 'all03b.prn' firstobs=2; input sex $ height weight chest jitaku $ kodukai carrier $ tsuuwa; proc print data=gakusei(obs=10); run; proc reg data=gakusei; : 回帰分析 model weight=height chest; : 複数変量を指定 output out=outreg1 predicted=pred1 residual=resid1; : 結果項目の保存 run; : proc print data=outreg1(obs=15); run; : proc plot data=outreg1; : 散布図を描く where weight^=. and height^=. and chest^=.; : 解析に使ったデータのみ plot weight*height; : plot weight*chest; : plot weight*pred1; : 観測値と予測値 plot resid1*pred1 /vref=0; : 残差と予測値(残差解析) plot resid1*height/vref=0; : 残差と説明変量(残差解析) plot resid1*chest /vref=0; : 残差と説明変量(残差解析) plot resid1*weight/vref=0; : 残差と目的変量(残差解析) run; : : proc univariate data=outreg1 plot normal; : 残差を正規プロットして確かめる var resid1; : run; :
SAS システム 2 08:31 Thursday, December 18, 2003 Model: MODEL1 Dependent Variable: WEIGHT Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 7083.97446 3541.98723 88.313 0.0001 Error 84 3369.01266 40.10729 C Total 86 10452.98713 Root MSE 6.33303 R-square 0.6777 Dep Mean 59.43908 Adj R-sq 0.6700 C.V. 10.65466 SAS システム 3 08:31 Thursday, December 18, 2003 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -110.236728 13.63577170 -8.084 0.0001 HEIGHT 1 0.675654 0.08535145 7.916 0.0001 CHEST 1 0.647180 0.09185838 7.045 0.0001 SAS システム 4 08:31 Thursday, December 18, 2003 K C H W J O A T R E E C I D R S P E I I H T U R U R S O S G G E A K I U E I B E H H S K A E W D D S X T T T U I R A 1 1 1 F 145.0 38.0 . J 10000 . . . 2 F 148.0 42.0 . J 50000 . . . 3 F 148.0 43.0 80 J 50000 DoCoMo 4000 41.5345 1.4655 4 F 148.9 . . J 60000 . . . 5 F 149.0 45.0 . G 60000 . . . 6 F 150.0 46.0 86 40000 . 46.7689 -0.7689 7 F 151.0 50.0 . G 60000 J-PHONE . . . 8 F 151.7 41.5 80 J 35000 . 44.0344 -2.5344 9 F 152.0 35.0 77 J 60000 DoCoMo 2000 42.2955 -7.2955 SAS システム 6 08:31 Thursday, December 18, 2003 プロット : WEIGHT*HEIGHT. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A WEIGHT | A A A | B BABAB AAAA A A A AA | A A A A B BA BAFBC ABA ABBA 50 + A A ACA AAC C BB CB A | A B A | | | 0 + --+-----------+-----------+-----------+-----------+-----------+-- 140 150 160 170 180 190 HEIGHT SAS システム 7 08:31 Thursday, December 18, 2003 プロット : WEIGHT*CHEST. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A WEIGHT | B A | A C ABF AA B A A | A A B C A ACBDBI AB A 50 + A A B A DDAHAAA | A B A | | | 0 + -+--------+--------+--------+--------+--------+--------+--------+ 50 60 70 80 90 100 110 120 CHEST SAS システム 8 08:31 Thursday, December 18, 2003 プロット : WEIGHT*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... 100 + A | A A WEIGHT | A A A | A A CBBBA AA CA A | A B AA B AABB AFEABB AB 50 + B BBAC CBCDA B | B A A | | | 0 + --+---------+---------+---------+---------+---------+---------+-- 30 40 50 60 70 80 90 Predicted Value of WEIGHT SAS システム 9 08:31 Thursday, December 18, 2003 プロット : RESID1*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | A B AA B A A BABA A A a 0 +--------------A-A--BBAB-BAAA-AABB-ADDAA-AA-BA--------A----------- l | A B AABCA B ABAABB ABA A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 30 40 50 60 70 80 90 Predicted Value of WEIGHT SAS システム 10 08:31 Thursday, December 18, 2003 プロット : RESID1*HEIGHT. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | B A A BBBAB AAAA a 0 +------------A-A-A-A-ABA-A-B-B-BA-BB-A-CAB-BAB---B-A-A--A--------- l | A A AA B AA CC A BAA A ABBA A | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 140 150 160 170 180 190 HEIGHT SAS システム 11 08:31 Thursday, December 18, 2003 プロット : RESID1*CHEST. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | A A A A u | B A A A A B ABD B a 0 +-----------------------A---C-BCBGBCAG-A--B---B--------A---------- l | AA B CA FABBC AAB A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 CHEST SAS システム 12 08:31 Thursday, December 18, 2003 プロット : RESID1*WEIGHT. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | A i 20 + A d | AA A A u | A B AAB B ABBA AA a 0 +----------------AA-BBBDB-B-AEDBD-A-C----A---------------- l | A A BDABB B AEAAC A | -20 + ---+------------+------------+------------+------------+-- 20 40 60 80 100 WEIGHT SAS システム 13 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Moments N 87 Sum Wgts 87 Mean 0 Sum 0 Std Dev 6.258959 Variance 39.17457 Skewness 1.174768 Kurtosis 1.685893 USS 3369.013 CSS 3369.013 CV . Std Mean 0.671031 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 87 Num > 0 33 M(Sign) -10.5 Pr>=|M| 0.0314 Sgn Rank -224 Pr>=|S| 0.3460 W:Normal 0.916997 Pr< W 0.0001 SAS システム 14 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Quantiles(Def=5) 100% Max 23.51358 99% 23.51358 75% Q3 4.161861 95% 11.38162 50% Med -1.57478 90% 7.588498 25% Q1 -4.58083 10% -6.89913 0% Min -9.78758 5% -7.29554 1% -9.78758 Range 33.30116 Q3-Q1 8.742691 Mode -6.9906 SAS システム 17 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 4 1 0 1 7 1 0 1 01134 5 | 0 5556777778888 13 | 0 0001111233444 13 +--+--+ -0 44433333333333332222222111111000 32 *-----* -0 998777776666666555555 21 +-----+ -1 0 1 | ----+----+----+----+----+----+-- Multiply Stem.Leaf by 10**+1 SAS システム 18 08:31 Thursday, December 18, 2003 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/18/03 */ data gakusei; infile 'all03b.prn' firstobs=2; input sex $ height weight chest jitaku $ kodukai carrier $ tsuuwa; proc print data=gakusei(obs=10); run; : proc corr data=gakusei; : 相関係数 where sex='M'; : 男性について run; : : proc reg data=gakusei; : 回帰分析 where sex='M'; : 男性について model weight=height chest; : output out=outreg1 predicted=pred1 residual=resid1; : run; : proc print data=outreg1(obs=15); run; proc plot data=outreg1; where sex='M' and weight^=. and height^=. and chest^=.; : 対象データについて plot weight*height; plot weight*chest; plot weight*pred1; plot resid1*(pred1 height chest weight)/vref=0; : まとめて記述 /* plot resid1*pred1 /vref=0; plot resid1*height/vref=0; plot resid1*chest /vref=0; plot resid1*weight/vref=0; */ run; proc univariate data=outreg1 plot normal; var resid1; run;
SAS システム 3 08:31 Thursday, December 18, 2003 Correlation Analysis Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / Number of Observations HEIGHT WEIGHT CHEST KODUKAI TSUUWA HEIGHT 1.00000 0.45178 0.21465 0.07419 -0.13281 0.0 0.0001 0.1026 0.3496 0.5178 173 173 59 161 26 WEIGHT 0.45178 1.00000 0.66778 -0.02953 0.08888 0.0001 0.0 0.0001 0.7100 0.6659 173 173 59 161 26 CHEST 0.21465 0.66778 1.00000 -0.12322 0.86603 0.1026 0.0001 0.0 0.3701 0.3333 59 59 59 55 3 KODUKAI 0.07419 -0.02953 -0.12322 1.00000 -0.07180 0.3496 0.7100 0.3701 0.0 0.7330 161 161 55 164 25 TSUUWA -0.13281 0.08888 0.86603 -0.07180 1.00000 0.5178 0.6659 0.3333 0.7330 0.0 26 26 3 25 26 SAS システム 6 08:31 Thursday, December 18, 2003 Model: MODEL1 Dependent Variable: WEIGHT Analysis of Variance Sum of Mean Source DF Squares Square F Value Prob>F Model 2 2670.74675 1335.37337 30.720 0.0001 Error 56 2434.28885 43.46944 C Total 58 5105.03559 Root MSE 6.59314 R-square 0.5232 Dep Mean 64.52034 Adj R-sq 0.5061 C.V. 10.21869 SAS システム 7 08:31 Thursday, December 18, 2003 Parameter Estimates Parameter Standard T for H0: Variable DF Estimate Error Parameter=0 Prob > |T| INTERCEP 1 -67.355995 24.32863116 -2.769 0.0076 HEIGHT 1 0.430400 0.14291427 3.012 0.0039 CHEST 1 0.651915 0.10151936 6.422 0.0001 SAS システム 10 08:31 Thursday, December 18, 2003 プロット : WEIGHT*CHEST. 凡例: A = 1 OBS, B = 2 OBS, ... WEIGHT | 100 + A | A A | 75 + AA C A A | A C AAH AA B A | A A A C A ACBCBE AA A 50 + A A A A | | 25 + -+--------+--------+--------+--------+--------+--------+--------+ 50 60 70 80 90 100 110 120 CHEST SAS システム 11 08:31 Thursday, December 18, 2003 プロット : WEIGHT*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... WEIGHT | 100 + A | A A | 75 + AA AAAA A | AA A DAAACABA B | A AA AAAAAABBDDB BA 50 + A A A A | | 25 + --+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of WEIGHT SAS システム 12 08:31 Thursday, December 18, 2003 プロット : RESID1*PRED1. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A A AA A CBA AA a 0 +---------------A---A----A-AAAAABB-AC--A-AA---------A------------- l | A A A AADBB BBB B | -20 + ---+-----------+-----------+-----------+-----------+-----------+-- 40 50 60 70 80 90 Predicted Value of WEIGHT SAS システム 13 08:31 Thursday, December 18, 2003 プロット : RESID1*HEIGHT. 凡例: 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 A AA a 0 +----A-------A-----------A-B---A-B-A-A-A--AB-----AA--A-A-A---A---- l | A B A A B C A B A A A BA A A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 155 160 165 170 175 180 185 HEIGHT SAS システム 14 08:31 Thursday, December 18, 2003 プロット : RESID1*CHEST. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A A A B BD B a 0 +-----------------------B---B---AB-BAE-A--B---A--------A---------- l | A B BBBAE AAB A A | -20 + -+--------+--------+--------+--------+--------+--------+--------+- 50 60 70 80 90 100 110 120 CHEST SAS システム 15 08:31 Thursday, December 18, 2003 プロット : RESID1*WEIGHT. 凡例: A = 1 OBS, B = 2 OBS, ... | R 40 + e | s | i 20 + A A d | A A u | A A A B A AC A A AA a 0 +----------A-------A---DACA-D--A-AB------A------------------------ l | A A BA B FABABA A | -20 + ---+---------+---------+---------+---------+---------+---------+-- 40 50 60 70 80 90 100 WEIGHT SAS システム 16 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Moments N 59 Sum Wgts 59 Mean 0 Sum 0 Std Dev 6.478464 Variance 41.9705 Skewness 1.197453 Kurtosis 1.616956 USS 2434.289 CSS 2434.289 CV . Std Mean 0.843424 T:Mean=0 0 Pr>|T| 1.0000 Num ^= 0 59 Num > 0 23 M(Sign) -6.5 Pr>=|M| 0.1175 Sgn Rank -103 Pr>=|S| 0.4416 W:Normal 0.907993 Pr< W 0.0001 SAS システム 17 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Quantiles(Def=5) 100% Max 21.70922 99% 21.70922 75% Q3 4.496601 95% 13.83164 50% Med -1.4844 90% 7.306712 25% Q1 -4.78841 10% -6.60478 0% Min -8.95245 5% -8.26289 1% -8.95245 Range 30.66167 Q3-Q1 9.285006 Mode -4.78841 SAS システム 20 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Stem Leaf # Boxplot 2 2 1 0 1 8 1 | 1 034 3 | 0 555566777 9 | 0 011233444 9 +--+--+ -0 4444333332221111100 19 *-----* -0 99888766655555555 17 +-----+ ----+----+----+----+ Multiply Stem.Leaf by 10**+1 SAS システム 21 08:31 Thursday, December 18, 2003 Univariate Procedure Variable=RESID1 Residual Normal Probability Plot 22.5+ * | * ++ | *+*++++++ 7.5+ ++*****+ | +++******* | *********** -7.5+ * * * ******** +----+----+----+----+----+----+----+----+----+----+ -2 -1 0 +1 +2
where sex='M' and weight<85;