* data step from https://www.msu.edu/course/stt/465/Section1/old/Chapter%204.sas ; /* ------------------------------------------------------------ */ /* Example 4.1: Hermit Crab Counts in Coastline Habitats */ /* Data set is summarized in Table 4.1, p. 110 (on p. 125 in 2nd ed) */ /* ------------------------------------------------------------ */ data crabs; input crabcnt site @@; crabcntplus = crabcnt + .01 ; logcrabcnt = log10(crabcnt + .166) ; * transformation used in the text ; cards; 0 1 0 1 22 1 3 1 17 1 0 1 0 1 7 1 11 1 11 1 73 1 33 1 0 1 65 1 13 1 44 1 20 1 27 1 48 1 104 1 233 1 81 1 22 1 9 1 2 1 0 2 0 2 56 2 0 2 8 2 0 2 3 2 1 2 16 2 55 2 142 2 10 2 2 2 145 2 6 2 4 2 5 2 124 2 24 2 204 2 415 2 466 2 6 2 14 2 12 2 0 3 0 3 4 3 13 3 5 3 1 3 1 3 4 3 4 3 36 3 407 3 0 3 0 3 18 3 4 3 14 3 0 3 24 3 52 3 314 3 245 3 107 3 5 3 6 3 2 3 0 4 0 4 0 4 4 4 2 4 2 4 5 4 4 4 2 4 1 4 0 4 12 4 1 4 30 4 0 4 3 4 28 4 2 4 21 4 8 4 82 4 12 4 10 4 2 4 0 4 0 5 1 5 1 5 2 5 2 5 1 5 2 5 29 5 2 5 2 5 0 5 13 5 0 5 19 5 1 5 3 5 26 5 30 5 5 5 4 5 94 5 1 5 9 5 3 5 0 5 0 6 0 6 0 6 2 6 3 6 0 6 0 6 4 6 0 6 5 6 4 6 22 6 0 6 64 6 4 6 4 6 43 6 3 6 16 6 19 6 95 6 6 6 22 6 0 6 0 6 ; run; proc print ; run ; * Proc TRANSREG can be used to find a suggested Box-Cox transformation. We often look at the optimal value and pick the nearest familiar transformation, such as log, square root, etc. The Box-Cox transformations require positive valued responses, so we add a small constant to each count to avoid zero counts ; ods graphics on ; proc transreg data = crabs plots(unpack) = boxcox ss2 ; model BoxCox(crabcntplus / lambda= -2. to 2. by 0.05) = class(site)/ pboxcoxtable ; run; ods graphics off ; * The MEANS statement with the HOVTEST = BF option gives the test mentioned in the text, also note the different residuals created in the OUTPUT statement ; proc glm data = crabs ; class site ; model logcrabcnt = site ; means site / hovtest = bf ; output out = r_lcrabs p = pred r = res student = studres rstudent = jkres ; run ; * several plots to examine the data and model assumptions ; * note that we sort the data before calling Proc Boxplot ; data r_lcrabs2 ; set r_lcrabs ; absresid = abs(res) ; run ; proc plot data = r_lcrabs2 ; plot res*pred absresid*pred jkres*pred ; proc capability noprint data = r_lcrabs2 lineprinter ; var res ; qqplot res /normal(mu = est sigma = est symbol='.') square ; run ;