1 options ls=99 ps=256 nocenter nodate nonumber; 2 3 data surgical; Title1 'Surgical example from Chapter 8'; 4 input x1 x2 x3 x4 y; 5 * label x1='blood clotting score'; 6 * label x2='Prognostic data (inc age)'; 7 * label x3='enzyme function score'; 8 * label x4='liver function score'; 9 * label Y='Survival time'; 10 logy=log(y); 11 cards; NOTE: The data set WORK.SURGICAL has 54 observations and 6 variables. NOTE: DATA statement used: real time 0.05 seconds cpu time 0.05 seconds 66 ; 67 proc print data=surgical; title2 'Raw data listing'; run; NOTE: There were 54 observations read from the data set WORK.SURGICAL. NOTE: The PROCEDURE PRINT printed page 1. NOTE: PROCEDURE PRINT used: real time 0.03 seconds cpu time 0.03 seconds
Surgical example from Chapter 8 Raw data listing Obs x1 x2 x3 x4 y logy 1 6.7 62 81 2.59 200 5.29832 2 5.1 59 66 1.70 101 4.61512 3 7.4 57 83 2.16 204 5.31812 4 6.5 73 41 2.01 101 4.61512 5 7.8 65 115 4.30 509 6.23245 6 5.8 38 72 1.42 80 4.38203 7 5.7 46 63 1.91 80 4.38203 8 3.7 68 81 2.57 127 4.84419 9 6.0 67 93 2.50 202 5.30827 10 3.7 76 94 2.40 203 5.31321 11 6.3 84 83 4.13 329 5.79606 12 6.7 51 43 1.86 65 4.17439 13 5.8 96 114 3.95 830 6.72143 14 5.8 83 88 3.95 330 5.79909 15 7.7 62 67 3.40 168 5.12396 16 7.4 74 68 2.40 217 5.37990 17 6.0 85 28 2.98 87 4.46591 18 3.7 51 41 1.55 34 3.52636 19 7.3 68 74 3.56 215 5.37064 20 5.6 57 87 3.02 172 5.14749 21 5.2 52 76 2.85 109 4.69135 22 3.4 83 53 1.12 136 4.91265 23 6.7 26 68 2.10 70 4.24850 24 5.8 67 86 3.40 220 5.39363 25 6.3 59 100 2.95 276 5.62040 26 5.8 61 73 3.50 144 4.96981 27 5.2 52 86 2.45 181 5.19850 28 11.2 76 90 5.59 574 6.35263 29 5.2 54 56 2.71 72 4.27667 30 5.8 76 59 2.58 178 5.18178 31 3.2 64 65 0.74 71 4.26268 32 8.7 45 23 2.52 58 4.06044 33 5.0 59 73 3.50 116 4.75359 34 5.8 72 93 3.30 295 5.68698 35 5.4 58 70 2.64 115 4.74493 36 5.3 51 99 2.60 184 5.21494 37 2.6 74 86 2.05 118 4.77068 38 4.3 8 119 2.85 120 4.78749 39 4.8 61 76 2.45 151 5.01728 40 5.4 52 88 1.81 148 4.99721 41 5.2 49 72 1.84 95 4.55388 42 3.6 28 99 1.30 75 4.31749 43 8.8 86 88 6.40 483 6.18002 44 6.5 56 77 2.85 153 5.03044 45 3.4 77 93 1.48 191 5.25227 46 6.5 40 84 3.00 123 4.81218 47 4.5 73 106 3.05 311 5.73979 48 4.8 86 101 4.10 398 5.98645 49 5.1 67 77 2.86 158 5.06260 50 3.9 82 103 4.55 310 5.73657 51 6.6 77 46 1.95 124 4.82028 52 6.4 85 40 1.21 125 4.82831 53 6.4 59 85 2.33 198 5.28827 54 8.8 78 72 3.20 313 5.74620 69 options ls=99 ps=56; title2 'Scatter plots'; 70 proc plot data=surgical; plot y*x1 y*x2 y*x3 y*x4; run; NOTE: There were 54 observations read from the data set WORK.SURGICAL. NOTE: The PROCEDURE PLOT printed pages 2-5. NOTE: PROCEDURE PLOT used: real time 0.01 seconds cpu time 0.01 seconds 71 proc plot data=surgical; plot logy*x1 logy*x2 logy*x3 logy*x4; run; 72 options ls=99 ps=256; NOTE: There were 54 observations read from the data set WORK.SURGICAL. NOTE: The PROCEDURE PLOT printed pages 6-9. NOTE: PROCEDURE PLOT used: real time 0.01 seconds cpu time 0.01 seconds Surgical example from Chapter 8 Scatter plots Plot of y*x1. Legend: A = 1 obs, B = 2 obs, etc. y | | 900 + | | | A 800 + | | | 700 + | | | 600 + | A | | 500 + A | A | | 400 + A | | | A A A 300 + A A A | A | | A AA 200 + A A A A A A | AA A A A | A A A A A | A A A A A A AB 100 + AB A | A A A AA A B | A | A 0 + | --+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-- 2 3 4 5 6 7 8 9 10 11 12 x1 Plot of y*x2. Legend: A = 1 obs, B = 2 obs, etc. y | | 900 + | | | A 800 + | | | 700 + | | | 600 + | A | | 500 + A | A | | 400 + A | | | A AA 300 + AA A | A | | AA A 200 + A A A A AA | AA A A A | A A B A | A A AA A A A A A 100 + A A A A | A A A A A A A A | A | A 0 + | --+---------+---------+---------+---------+---------+---------+---------+---------+---------+-- 8 18 28 38 48 58 68 78 88 98 x2 Surgical example from Chapter 8 Scatter plots Plot of y*x3. Legend: A = 1 obs, B = 2 obs, etc. y | | 900 + | | | A 800 + | | | 700 + | | | 600 + | A | | 500 + A | A | | 400 + A | | | A A A 300 + A A A | A | | A A A 200 + AA A BA | A A B A | A AB A | A A A A A A A A A 100 + A A A A | A A A A A A A A | A | A 0 + | ---+--------------+--------------+--------------+--------------+--------------+-- 20 40 60 80 100 120 x3 Plot of y*x4. Legend: A = 1 obs, B = 2 obs, etc. y | | 900 + | | | A 800 + | | | 700 + | | | 600 + | A | | 500 + A | A | | 400 + A | | | A A A 300 + A A A | A | | A A A 200 + A A AA AA | A B A A | A A B A | AA A A AA A A A 100 + A A A A | A AA AA A A A | A | A 0 + | --+------------+------------+------------+------------+------------+------------+------------+- 0 1 2 3 4 5 6 7 x4 Surgical example from Chapter 8 Scatter plots Plot of logy*x1. Legend: A = 1 obs, B = 2 obs, etc. logy | 7.0 + | | | A | | 6.5 + | | A | A | A | 6.0 + A | | A A | A A A | A | A 5.5 + | A A | A A A AA | A A A | A A A | A A 5.0 + A A A A | A | A AB | A A A A | A | AA A 4.5 + A | AA | A | A A A | A | A 4.0 + | | | | | 3.5 + A --+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2 3 4 5 6 7 8 9 10 11 12 x1 Plot of logy*x2. Legend: A = 1 obs, B = 2 obs, etc. logy | 7.0 + | | | A | | 6.5 + | | A | A | A | 6.0 + A | | AA | A A A | A | A 5.5 + | A A | A A AA A | A A A | A A A | A A 5.0 + A A B | A | A A A A | A AA A | A | A A A 4.5 + A | A A | A | A A A | A | A 4.0 + | | | | | 3.5 + A --+---------+---------+---------+---------+---------+---------+---------+---------+---------+- 8 18 28 38 48 58 68 78 88 98 x2 Surgical example from Chapter 8 Scatter plots Plot of logy*x3. Legend: A = 1 obs, B = 2 obs, etc. logy | 7.0 + | | | A | | 6.5 + | | A | A | A | 6.0 + A | | A A | A A A | A | A 5.5 + | A A | A AA AA | A A A | A B | A A 5.0 + A AA A | A | A A A A | A A A A | A | A A A 4.5 + A | A A | A | A A A | A | A 4.0 + | | | | | 3.5 + A ---+--------------+--------------+--------------+--------------+--------------+-- 20 40 60 80 100 120 x3 Plot of logy*x4. Legend: A = 1 obs, B = 2 obs, etc. logy | 7.0 + | | | A | | 6.5 + | | A | A | A | 6.0 + A | | A A | A A A | A | A 5.5 + | A A | A A AA A | A A A | A A A | A A 5.0 + A A A A | A | A A A A | A A A A | A | A A A 4.5 + A | A A | A | A A A | A | A 4.0 + | | | | | 3.5 + A -+------------+------------+------------+------------+------------+------------+------------+- 0 1 2 3 4 5 6 7 x4
74 proc transreg data=surgical; title2 'Box-Cox transformation'; 75 MODEL BOXCOX(Y) = identity(X1 X2 X3 X4); run; NOTE: Algorithm converged. NOTE: There were 54 observations read from the data set WORK.SURGICAL. NOTE: The PROCEDURE TRANSREG printed pages 10-11. NOTE: PROCEDURE TRANSREG used: real time 0.04 seconds cpu time 0.04 seconds Surgical example from Chapter 8 Box-Cox transformation The TRANSREG Procedure Transformation Information for BoxCox(y) Lambda R-Square Log Like -3.00 0.28 -353.091 -2.75 0.32 -335.979 -2.50 0.36 -319.102 -2.25 0.41 -302.473 -2.00 0.48 -286.098 -1.75 0.55 -269.960 -1.50 0.62 -254.005 -1.25 0.70 -238.105 -1.00 0.78 -222.020 -0.75 0.86 -205.344 -0.50 0.91 -187.536 -0.25 0.95 -168.735 0.00 + 0.97 -154.624 < 0.25 0.97 -160.106 0.50 0.94 -180.331 0.75 0.90 -201.921 1.00 0.84 -222.037 1.25 0.77 -240.961 1.50 0.69 -259.200 1.75 0.62 -277.117 2.00 0.55 -294.936 2.25 0.49 -312.792 2.50 0.44 -330.763 2.75 0.39 -348.891 3.00 0.35 -367.194 < - Best Lambda * - Confidence Interval + - Convenient Lambda Surgical example from Chapter 8 Box-Cox transformation The TRANSREG Procedure TRANSREG Univariate Algorithm Iteration History for BoxCox(y) Iteration Average Maximum Criterion Number Change Change R-Square Change Note ------------------------------------------------------------------------- 1 0.00000 0.00000 0.97236 Converged Algorithm converged.
77 proc corr data=surgical; title2 'Simple correlations'; 78 var x1 x2 x3 x4; with y logy; run; NOTE: The PROCEDURE CORR printed page 12. NOTE: PROCEDURE CORR used: real time 0.02 seconds cpu time 0.02 seconds Surgical example from Chapter 8 Simple correlations The CORR Procedure 2 With Variables: y logy 4 Variables: x1 x2 x3 x4 Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum y 54 197.16667 145.29940 10647 34.00000 830.00000 logy 54 5.07983 0.63041 274.31096 3.52636 6.72143 x1 54 5.78333 1.60303 312.30000 2.60000 11.20000 x2 54 63.24074 16.90253 3415 8.00000 96.00000 x3 54 77.11111 21.25378 4164 23.00000 119.00000 x4 54 2.74426 1.07036 148.19000 0.74000 6.40000 Pearson Correlation Coefficients, N = 54 Prob > |r| under H0: Rho=0 x1 x2 x3 x4 y 0.37252 0.55398 0.58024 0.72233 0.0055 <.0001 <.0001 <.0001 logy 0.34643 0.59290 0.66509 0.72620 0.0103 <.0001 <.0001 <.0001 80 proc reg data=surgical lineprinter; title2 'Full model'; 81 model logy = x1 x2 x3 x4; run; NOTE: 54 observations read. NOTE: 54 observations used in computations. 82 options ls=99 ps=56; plot residual.*predicted.; run; 83 options ls=99 ps=256; 84 NOTE: The PROCEDURE REG printed pages 13-14. NOTE: PROCEDURE REG used: real time 0.06 seconds cpu time 0.06 seconds Surgical example from Chapter 8 Full model The REG Procedure Model: MODEL1 Dependent Variable: logy Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 4 20.48086 5.12022 430.98 <.0001 Error 49 0.58214 0.01188 Corrected Total 53 21.06300 Root MSE 0.10900 R-Square 0.9724 Dependent Mean 5.07983 Adj R-Sq 0.9701 Coeff Var 2.14568 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 1.12536 0.11568 9.73 <.0001 x1 1 0.15779 0.01253 12.60 <.0001 x2 1 0.02131 0.00101 21.19 <.0001 x3 1 0.02182 0.00091252 23.91 <.0001 x4 1 0.00442 0.02236 0.20 0.8442 ------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+------ RESIDUAL | | | | 0.4 + + | | | | | | | 1 | 0.3 + + | | | 1 | | | | 1 | 0.2 + 1 + | | | 1 | | 1 | R | | e 0.1 + 1 + s | | i | 1 11 | d | 1 1 1 1 | u | 1 1 1 1 1 2 1 | a 0.0 + 1 1 111 1 1 1 + l | 1 1 1 1 1 2 | | 1 1 1 1 1 1 | | 1 | | 1 1 | -0.1 + 1 + | 1 | | 1 1 | | 1 | | 1 | -0.2 + + | 1 | | 1 | | | | | -0.3 + + | | ------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+------ 3.6 3.8 4.0 4.2 4.4 4.6 4.8 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 6.6 Predicted Value of logy PRED
85 proc reg data=surgical; title2 'Cp selection criteria'; 86 model logy = x1 x2 x3 x4 / selection=cp; run; NOTE: 54 observations read. NOTE: 54 observations used in computations. NOTE: The PROCEDURE REG printed page 15. NOTE: PROCEDURE REG used: real time 0.05 seconds cpu time 0.05 seconds Surgical example from Chapter 8 Cp selection criteria The REG Procedure Model: MODEL1 Dependent Variable: logy C(p) Selection Method Number in Model C(p) R-Square Variables in Model 3 3.0390 0.9723 x1 x2 x3 4 5.0000 0.9724 x1 x2 x3 x4 3 161.6520 0.8829 x2 x3 x4 2 283.6276 0.8129 x2 x3 3 451.8957 0.7192 x1 x3 x4 2 507.8069 0.6865 x3 x4 2 573.2766 0.6496 x2 x4 3 574.5468 0.6500 x1 x2 x4 2 580.0075 0.6458 x1 x3 1 787.9471 0.5274 x4 2 789.1422 0.5278 x1 x4 1 938.6707 0.4424 x3 2 948.2417 0.4381 x1 x2 1 1099.691 0.3515 x2 1 1510.148 0.1200 x1
87 proc reg data=surgical; title2 'RSquare selection criteria'; 88 model logy = x1 x2 x3 x4 / selection = RSquare; run; NOTE: 54 observations read. NOTE: 54 observations used in computations. NOTE: The PROCEDURE REG printed page 16. NOTE: PROCEDURE REG used: real time 0.05 seconds cpu time 0.05 seconds R-Square Selection Method Number in Model R-Square Variables in Model 1 0.5274 x4 1 0.4424 x3 1 0.3515 x2 1 0.1200 x1 ------------------------------------------- 2 0.8129 x2 x3 2 0.6865 x3 x4 2 0.6496 x2 x4 2 0.6458 x1 x3 2 0.5278 x1 x4 2 0.4381 x1 x2 ------------------------------------------- 3 0.9723 x1 x2 x3 3 0.8829 x2 x3 x4 3 0.7192 x1 x3 x4 3 0.6500 x1 x2 x4 ------------------------------------------- 4 0.9724 x1 x2 x3 x4
89 proc reg data=surgical; title2 'Adjusted RSquare selection criteria'; 90 model logy = x1 x2 x3 x4 / selection = AdjRSq; run; NOTE: 54 observations read. NOTE: 54 observations used in computations. 91 NOTE: The PROCEDURE REG printed page 17. NOTE: PROCEDURE REG used: real time 0.05 seconds cpu time 0.05 seconds Surgical example from Chapter 8 Adjusted RSquare selection criteria The REG Procedure Model: MODEL1 Dependent Variable: logy Adjusted R-Square Selection Method Number in Adjusted Model R-Square R-Square Variables in Model 3 0.9707 0.9723 x1 x2 x3 4 0.9701 0.9724 x1 x2 x3 x4 3 0.8758 0.8829 x2 x3 x4 2 0.8056 0.8129 x2 x3 3