* ch18eg.sas, using data from exercise 18.17; * 1-way ANOVA: residual plots, Box-Cox transformations, * and Hartley's test. Also discuss Satterthwaite's procedure; ; options ls=76; ; data WindSpd; do A=1 to 4; * A = speed; do j=1 to 16; drop j; input y @@; * y = number of breaks; output; end; end; lines; 4 3 2 3 4 4 3 6 5 4 2 4 4 2 3 4 7 6 4 6 7 2 9 5 5 9 3 8 6 4 7 6 12 6 14 12 10 9 12 17 7 6 12 11 6 13 10 14 17 15 7 20 13 11 16 25 11 24 18 21 16 19 9 23 ; * Fit the ANOVA models and save info for residual plots; proc glm noprint; class A; model y = A; output out=B r=e p=yhat; title 'Chapter 18 example using data of exercise 18.17.'; proc rank normal=Blom; var e; ranks nscore; * proc print; ; * Residual plots; proc plot; plot e*yhat / vpos=19 vref=0; *** plot e*nscore / vpos=19 vref=0 href=0; title2 'Residual Plots.'; ; * Box-Cox transformation; proc sort data=WindSpd; by A; proc means noprint data=WindSpd; by A; var y; output out=C mean=ybar var=s2; data C; set C; ln_ybar=log(ybar); ln_s2=log(s2); proc print; title2 'Conduct Hartleys Test, and Determine a Box-Cox Transformation.'; proc plot; plot ln_s2*ln_ybar / vpos=19; ; * Based on the plot, use h(y)=ln(y); data WindSpd; set WindSpd; ln_y = log(y); proc glm; class A; model ln_y = A; means A / Tukey alpha=0.01; output out=B r=e p=lnyhat; title2 'Analysis of ln(y). (How to interpret the results?)'; proc rank normal=Blom; var e; ranks nscore; ; * Residual plots; proc plot; plot e*lnyhat / vpos=19 vref=0; plot e*nscore / vpos=19 vref=0 href=0; ; proc corr nosimple; var e nscore; ; * Use Satterthwaite's method for comparing means; data A12; set WindSpd; if A=1 or A=2; proc ttest ci=none; var y; class A; * no CI for sigma; title2 'Compare levels 1 and 2 of A using Satterthwaites approximation.'; ; data A13; set WindSpd; if A=1 or A=3; proc ttest ci=none; var y; class A; title2 'Compare levels 1 and 3 of A using Satterthwaites approximation.'; ; data A14; set WindSpd; if A=1 or A=4; proc ttest ci=none; var y; class A; title2 'Compare levels 1 and 4 of A using Satterthwaites approximation.'; ; data A23; set WindSpd; if A=2 or A=3; proc ttest ci=none; var y; class A; title2 'Compare levels 2 and 3 of A using Satterthwaites approximation.'; ; data A24; set WindSpd; if A=2 or A=4; proc ttest ci=none; var y; class A; title2 'Compare levels 2 and 4 of A using Satterthwaites approximation.'; ; data A34; set WindSpd; if A=3 or A=4; proc ttest ci=none; var y; class A; title2 'Compare levels 3 and 4 of A using Satterthwaites approximation.'; Chapter 18 example using data of exercise 18.17. 1 Residual Plots. Plot of e*yhat. Legend: A = 1 obs, B = 2 obs, etc. 10 + | A | A | A A e | | A | B B A | A A A A | A C D A 0 +--------G---------D------------------A----------------------A-------- | G B B C | B A | B A A | C | B | | A | -10 + A ---+-------+-------+-------+-------+-------+-------+-------+-------+-- 2 4 6 8 10 12 14 16 18 yhat Chapter 18 example using data of exercise 18.17. 2 Conduct Hartleys Test, and Determine a Box-Cox Transformation. Obs A _TYPE_ _FREQ_ ybar s2 ln_ybar ln_s2 1 1 0 16 3.5625 1.1958 1.27046 0.17884 2 2 0 16 5.8750 3.9833 1.77071 1.38212 3 3 0 16 10.6875 10.4958 2.36907 2.35098 4 4 0 16 16.5625 28.9292 2.80714 3.36485 Chapter 18 example using data of exercise 18.17. 3 Conduct Hartleys Test, and Determine a Box-Cox Transformation. Plot of ln_s2*ln_ybar. Legend: A = 1 obs, B = 2 obs, etc. ln_s2 | 4 + | | | A 3 + | | | A 2 + | | A | 1 + | | | A 0 + | ---+-------------+-------------+-------------+-------------+-- 1.0 1.5 2.0 2.5 3.0 ln_ybar Chapter 18 example using data of exercise 18.17. 5 Analysis of ln(y). (How to interpret the results?) The GLM Procedure Dependent Variable: ln_y Sum of Source DF Squares Mean Square F Value Pr > F Model 3 21.69169895 7.23056632 56.78 <.0001 Error 60 7.64042176 0.12734036 Corrected Total 63 29.33212071 R-Square Coeff Var Root MSE ln_y Mean 0.739520 17.84571 0.356848 1.999628 Chapter 18 example using data of exercise 18.17. 6 Analysis of ln(y). (How to interpret the results?) The GLM Procedure Tukey's Studentized Range (HSD) Test for ln_y NOTE: This test controls the Type I experimentwise error rate, but it generally has a higher Type II error rate than REGWQ. Alpha 0.01 Error Degrees of Freedom 60 Error Mean Square 0.12734 Critical Value of Studentized Range 4.59418 Minimum Significant Difference 0.4099 Means with the same letter are not significantly different. Tukey Grouping Mean N A A 2.7499 16 4 B 2.3211 16 3 C 1.7039 16 2 D 1.2237 16 1 Chapter 18 example using data of exercise 18.17. 7 Plot of e*lnyhat. Legend: A = 1 obs, B = 2 obs, etc. e | 1.0 + | | | A 0.5 + B A A | A A B B | C A C | G D E B 0.0 +---------------------------------------B-----------C--------- | D B A A | | B A B -0.5 + C C A | A | A | -1.0 + A ---+-------------+-------------+-------------+-------------+-- 1.0 1.5 2.0 2.5 3.0 lnyhat Chapter 18 example using data of exercise 18.17. 8 Plot of e*nscore. Legend: A = 1 obs, B = 2 obs, etc. e | | 1.0 + | | | | | | | A 0.5 + | A B A | | BAAAA | | ACBA | AADA G D 0.0 +------------------------------ABB-+----------------------------------- | A DAB | | | | ABB | -0.5 + A C C | | A | | A | | | -1.0 + A | --+----------+----------+----------+----------+----------+----------+-- -3 -2 -1 0 1 2 3 Rank for Variable e Chapter 18 example using data of exercise 18.17. 9 The CORR Procedure Pearson Correlation Coefficients, N = 64 e nscore e 1.00000 0.97166 Chapter 18 example using data of exercise 18.17. 10 Compare levels 1 and 2 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 1 16 2.9798 3.5625 4.1452 1.0935 0.2734 y 2 16 4.8115 5.875 6.9385 1.9958 0.499 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -4.06 0.0003 y Satterthwaite Unequal 23.3 -4.06 0.0005 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 3.33 0.0258 Chapter 18 example using data of exercise 18.17. 11 Compare levels 1 and 3 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 1 16 2.9798 3.5625 4.1452 1.0935 0.2734 y 3 16 8.9612 10.688 12.414 3.2397 0.8099 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -8.34 <.0001 y Satterthwaite Unequal 18.4 -8.34 <.0001 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 8.78 <.0001 Chapter 18 example using data of exercise 18.17. 12 Compare levels 1 and 4 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 1 16 2.9798 3.5625 4.1452 1.0935 0.2734 y 4 16 13.696 16.563 19.429 5.3786 1.3446 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -9.47 <.0001 y Satterthwaite Unequal 16.2 -9.47 <.0001 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 24.19 <.0001 Chapter 18 example using data of exercise 18.17. 13 Compare levels 2 and 3 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 2 16 4.8115 5.875 6.9385 1.9958 0.499 y 3 16 8.9612 10.688 12.414 3.2397 0.8099 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -5.06 <.0001 y Satterthwaite Unequal 25 -5.06 <.0001 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 2.63 0.0701 Chapter 18 example using data of exercise 18.17. 14 Compare levels 2 and 4 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 2 16 4.8115 5.875 6.9385 1.9958 0.499 y 4 16 13.696 16.563 19.429 5.3786 1.3446 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -7.45 <.0001 y Satterthwaite Unequal 19.1 -7.45 <.0001 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 7.26 0.0004 Chapter 18 example using data of exercise 18.17. 15 Compare levels 3 and 4 of A using Satterthwaites approximation. The TTEST Procedure Statistics Lower CL Upper CL Variable A N Mean Mean Mean Std Dev Std Err y 3 16 8.9612 10.688 12.414 3.2397 0.8099 y 4 16 13.696 16.563 19.429 5.3786 1.3446 T-Tests Variable Method Variances DF t Value Pr > |t| y Pooled Equal 30 -3.74 0.0008 y Satterthwaite Unequal 24.6 -3.74 0.0010 Equality of Variances Variable Method Num DF Den DF F Value Pr > F y Folded F 15 15 2.76 0.0584