Original Program from program editor.
*******************************************************************;
*** Neter, Kutner, Nachtsheim, Wasserman (1996) [Ch24pr17.sas] ***;
*** Artificial pearl quality depends on the number of coats ***;
*** of lacquer applied. The experiment evaluates the market ***;
*** value of the pearls and The number of coats applied. The ***;
*** experiment was reproduced on 4 different batches of pearls ***;
*******************************************************************;
options ps=256 ls=99 nocenter nodate nonumber nolabel;
TITLE1 'Example of Randomized Complete BLock Design (RBD)';
data pearls; infile cards missover;
TITLE2 'Artificial pearl market value with coats of lacquer';
LABEL value = 'Market value of the pearl';
LABEL coats = 'coats of lacquer';
LABEL batch = 'Batch of pearls produced';
LABEL rep = 'A pearl within a batch';
input value c batch rep;
coats = (c-2)*2+8;
cards; run;
72.0 1 1 1
74.6 1 1 2
67.4 1 1 3
72.8 1 1 4
72.1 1 2 1
76.9 1 2 2
74.8 1 2 3
73.3 1 2 4
75.2 1 3 1
73.8 1 3 2
75.7 1 3 3
77.8 1 3 4
70.4 1 4 1
68.1 1 4 2
72.4 1 4 3
72.4 1 4 4
76.9 2 1 1
78.1 2 1 2
72.9 2 1 3
74.2 2 1 4
80.3 2 2 1
79.3 2 2 2
76.6 2 2 3
77.2 2 2 4
80.2 2 3 1
76.6 2 3 2
77.3 2 3 3
79.9 2 3 4
74.3 2 4 1
77.6 2 4 2
74.4 2 4 3
72.9 2 4 4
76.3 3 1 1
74.1 3 1 2
77.1 3 1 3
75.0 3 1 4
80.9 3 2 1
73.7 3 2 2
78.6 3 2 3
80.2 3 2 4
79.2 3 3 1
78.0 3 3 2
77.6 3 3 3
81.2 3 3 4
71.6 3 4 1
77.7 3 4 2
75.2 3 4 3
74.4 3 4 4
;
PROC PRINT DATA=pearls; TITLE3 'LISTING OF DATA'; RUN;
PROC MIXED DATA=PEARLS ORDER=DATA; CLASSES BATCH COATS;
TITLE3 'Randomized block design with PROC MIXED';
MODEL VALUE = COATS;
RANDOM BATCH BATCH*COATS;
lsmeans coats / adjust=tukey pdiff;
** treatments in order=data ====> 6 8 10;
contrast 'linear trend' coats -1 0 1;
contrast 'curved trend' coats -1 2 -1;
ods output diffs=ppp lsmeans=mmm;
*ods listing exclude diffs lsmeans;
RUN;
TITLE4 'Post hoc adjustment with macro by Arnold Saxton';
* SAS Macro by Arnold Saxton: Saxton, A.M. 1998. A macro for ;
* converting mean separation output to letter groupings in Proc Mixed. ;
* In Proc. 23rd SAS Users Group Intl., SAS Institute, Cary, NC, pp1243-1246.;
%include 'C:\Geaghan\EXST\EXST7005New\Fall2003\SaS\pdmix800.sas';
%pdmix800(ppp,mmm,alpha=0.05,sort=yes);
run;
PROC GLM DATA=PEARLS ORDER=DATA; CLASSES BATCH COATS;
TITLE3 'Randomized block design with PROC GLM';
MODEL VALUE = BATCH COATS BATCH*COATS;
RANDOM BATCH BATCH*COATS / TEST;
TEST H=BATCH COATS E=BATCH*COATS;
lsmeans coats / adjust=tukey pdiff stderr;
contrast 'linear trend' coats -1 0 1;
contrast 'curved trend' coats -1 2 -1;
RUN;
Below is output from the SAS log (bold) and output from the SAS Output window.
1 *******************************************************************;
2 *** Neter, Kutner, Nachtsheim, Wasserman (1996) [Ch24pr17.sas] ***;
3 *** Artificial pearl quality depends on the number of coats ***;
4 *** of lacquer applied. The experiment evaluates the market ***;
5 *** value of the pearls and The number of coats applied. The ***;
6 *** experiment was reproduced on 4 different batches of pearls ***;
7 *******************************************************************;
8 options ps=256 ls=99 nocenter nodate nonumber nolabel;
9 TITLE1 'Example of Randomized Complete BLock Design (RBD)';
10
11
12 data pearls; infile cards missover;
13 TITLE2 'Artificial pearl market value with coats of lacquer';
14 LABEL value = 'Market value of the pearl';
15 LABEL coats = 'coats of lacquer';
16 LABEL batch = 'Batch of pearls produced';
17 LABEL rep = 'A pearl within a batch';
18 input value c batch rep;
19 coats = (c-2)*2+8;
20 cards;
NOTE: The data set WORK.PEARLS has 48 observations and 5 variables.
NOTE: DATA statement used:
real time 0.44 seconds
20 ! run;
69 ;
70 PROC PRINT DATA=pearls; TITLE3 'LISTING OF DATA'; RUN;
NOTE: There were 48 observations read from the data set WORK.PEARLS.
NOTE: The PROCEDURE PRINT printed page 1.
NOTE: PROCEDURE PRINT used:
real time 0.38 seconds
Example of Randomized Complete BLock Design (RBD)
Artificial pearl market value with coats of lacquer
LISTING OF DATA
Obs value coats batch rep c
1 72.0 6 1 1 1
2 74.6 6 1 2 1
3 67.4 6 1 3 1
4 72.8 6 1 4 1
5 72.1 6 2 1 1
6 76.9 6 2 2 1
7 74.8 6 2 3 1
8 73.3 6 2 4 1
9 75.2 6 3 1 1
10 73.8 6 3 2 1
11 75.7 6 3 3 1
12 77.8 6 3 4 1
13 70.4 6 4 1 1
14 68.1 6 4 2 1
15 72.4 6 4 3 1
16 72.4 6 4 4 1
17 76.9 8 1 1 2
18 78.1 8 1 2 2
19 72.9 8 1 3 2
20 74.2 8 1 4 2
21 80.3 8 2 1 2
22 79.3 8 2 2 2
23 76.6 8 2 3 2
24 77.2 8 2 4 2
25 80.2 8 3 1 2
26 76.6 8 3 2 2
27 77.3 8 3 3 2
28 79.9 8 3 4 2
29 74.3 8 4 1 2
30 77.6 8 4 2 2
31 74.4 8 4 3 2
32 72.9 8 4 4 2
33 76.3 10 1 1 3
34 74.1 10 1 2 3
35 77.1 10 1 3 3
36 75.0 10 1 4 3
37 80.9 10 2 1 3
38 73.7 10 2 2 3
39 78.6 10 2 3 3
40 80.2 10 2 4 3
41 79.2 10 3 1 3
42 78.0 10 3 2 3
43 77.6 10 3 3 3
44 81.2 10 3 4 3
45 71.6 10 4 1 3
46 77.7 10 4 2 3
47 75.2 10 4 3 3
48 74.4 10 4 4 3
72 PROC MIXED DATA=PEARLS ORDER=DATA; CLASSES BATCH COATS;
73 TITLE3 'Randomized block design with PROC MIXED';
74 MODEL VALUE = COATS;
75 RANDOM BATCH BATCH*COATS;
76 lsmeans coats / adjust=tukey pdiff;
77 ** treatments in order=data ====> 6 8 10;
78 contrast 'linear trend' coats -1 0 1;
79 contrast 'curved trend' coats -1 2 -1;
80 ods output diffs=ppp lsmeans=mmm;
81 *ods listing exclude diffs lsmeans;
82 RUN;
NOTE:Convergence criteria met.
NOTE: Estimated G matrix is not positive definite.
NOTE: The data set WORK.MMM has 3 observations and 7 variables.
NOTE: The data set WORK.PPP has 3 observations and 10 variables.
NOTE: The PROCEDURE MIXED printed page 2.
NOTE: PROCEDURE MIXED used:
real time 0.76 seconds
83 TITLE4 'Post hoc adjustment with macro by Arnold Saxton';
84 * SAS Macro by Arnold Saxton: Saxton, A.M. 1998. A macro for ;
85 * converting mean separation output to letter groupings in Proc Mixed. ;
86 * In Proc. 23rd SAS Users Group Intl., SAS Institute, Cary, NC, pp1243-1246.;
87 %include 'C:\Geaghan\EXST\EXST7005New\Fall2003\SaS\pdmix800.sas';
715 %pdmix800(ppp,mmm,alpha=0.05,sort=yes);
PDMIX800 03.26.2002 processing
Worksize = 1024
Symbol size = 262128
4.3390183727
Tukey-Kramer values for coats are 2.21727 (avg) 2.21727 (min) 2.21727 (max).
716 run;
Example of Randomized Complete BLock Design (RBD)
Artificial pearl market value with coats of lacquer
Randomized block design with PROC MIXED
The Mixed Procedure
Model Information
Data Set WORK.PEARLS
Dependent Variable value
Covariance Structure Variance Components
Estimation Method REML
Residual Variance Method Profile
Fixed Effects SE Method Model-Based
Degrees of Freedom Method Containment
Class Level Information
Class Levels Values
batch 4 1 2 3 4
coats 3 6 8 10
Dimensions
Covariance Parameters 3
Columns in X 4
Columns in Z 16
Subjects 1
Max Obs Per Subject 48
Observations Used 48
Observations Not Used 0
Total Observations 48
Iteration History
Iteration Evaluations -2 Res Log Like Criterion
0 1 225.45311480
1 2 207.86808217 0.00000079
2 1 207.86803230 0.00000000
Convergence criteria met.
Covariance Parameter Estimates
Cov Parm Estimate
batch 3.8974
batch*coats 0
Residual 4.1780
Fit Statistics
-2 Res Log Likelihood 207.9
AIC (smaller is better) 211.9
AICC (smaller is better) 212.2
BIC (smaller is better) 210.6
Type 3 Tests of Fixed Effects
Num Den
Effect DF DF F Value Pr > F
coats 2 6 18.00 0.0029
Contrasts
Num Den
Label DF DF F Value Pr > F
linear trend 1 6 27.92 0.0019
curved trend 1 6 8.07 0.0295
Least Squares Means
Standard
Effect coats Estimate Error DF t Value Pr > |t|
coats 6 73.1062 1.1115 6 65.77 <.0001
coats 8 76.7937 1.1115 6 69.09 <.0001
coats 10 76.9250 1.1115 6 69.21 <.0001
Differences of Least Squares Means
Standard
Effect coats _coats Estimate Error DF t Value Pr > |t| Adjustment Adj P
coats 6 8 -3.6875 0.7227 6 -5.10 0.0022 Tukey-Kramer 0.0053
coats 6 10 -3.8187 0.7227 6 -5.28 0.0019 Tukey-Kramer 0.0045
coats 8 10 -0.1312 0.7227 6 -0.18 0.8619 Tukey-Kramer 0.9820
Example of Randomized Complete BLock Design (RBD)
Artificial pearl market value with coats of lacquer
Randomized block design with PROC MIXED
Post hoc adjustment with macro by Arnold Saxton
Effect=coats ADJUSTMENT=Tukey-Kramer(P<0.05) BYGROUP=1
Obs coats Estimate StdErr MSGROUP
1 10 76.9250 1.1115 A
2 8 76.7937 1.1115 A
3 6 73.1062 1.1115 B
718 PROC GLM DATA=PEARLS ORDER=DATA; CLASSES BATCH COATS;
719 TITLE3 'Randomized block design with PROC GLM';
720 MODEL VALUE = BATCH COATS BATCH*COATS;
721 RANDOM BATCH BATCH*COATS / TEST;
722 TEST H=BATCH COATS E=BATCH*COATS;
723 lsmeans coats / adjust=tukey pdiff stderr;
724 contrast 'linear trend' coats -1 0 1;
725 contrast 'curved trend' coats -1 2 -1;
726 RUN;
NOTE: TYPE I EMS not available without the E1 option.
NOTE: The PROCEDURE GLM printed pages 4-9.
NOTE: PROCEDURE GLM used:
real time 0.16 seconds
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 8.83 seconds
Example of Randomized Complete BLock Design (RBD)
Artificial pearl market value with coats of lacquer
Randomized block design with PROC GLM
The GLM Procedure
Class Level Information
Class Levels Values
batch 4 1 2 3 4
coats 3 6 8 10
Number of observations 48
Dependent Variable: value
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 11 305.0916667 27.7356061 5.75 <.0001
Error 36 173.6250000 4.8229167
Corrected Total 47 478.7166667
R-Square Coeff Var Root MSE value Mean
0.637312 2.904593 2.196114 75.60833
Source DF Type I SS Mean Square F Value Pr > F
batch 3 152.8516667 50.9505556 10.56 <.0001
coats 2 150.3879167 75.1939583 15.59 <.0001
batch*coats 6 1.8520833 0.3086806 0.06 0.9988
Source DF Type III SS Mean Square F Value Pr > F
batch 3 152.8516667 50.9505556 10.56 <.0001
coats 2 150.3879167 75.1939583 15.59 <.0001
batch*coats 6 1.8520833 0.3086806 0.06 0.9988
The GLM Procedure
Source Type III Expected Mean Square
batch Var(Error) + 4 Var(batch*coats) + 12 Var(batch)
coats Var(Error) + 4 Var(batch*coats) + Q(coats)
batch*coats Var(Error) + 4 Var(batch*coats)
Example of Randomized Complete BLock Design (RBD)
Artificial pearl market value with coats of lacquer
Randomized block design with PROC GLM
The GLM Procedure
Tests of Hypotheses for Mixed Model Analysis of Variance
Dependent Variable: value
Source DF Type III SS Mean Square F Value Pr > F
batch 3 152.851667 50.950556 165.06 <.0001
coats 2 150.387917 75.193958 243.60 <.0001
Error 6 1.852083 0.308681
Error: MS(batch*coats)
Source DF Type III SS Mean Square F Value Pr > F
batch*coats 6 1.852083 0.308681 0.06 0.9988
Error: MS(Error) 36 173.625000 4.822917
Least Squares Means
Adjustment for Multiple Comparisons: Tukey
Standard LSMEAN
coats value LSMEAN Error Pr > |t| Number
6 73.1062500 0.5490285 <.0001 1
8 76.7937500 0.5490285 <.0001 2
10 76.9250000 0.5490285 <.0001 3
Least Squares Means for effect coats
Pr > |t| for H0: LSMean(i)=LSMean(j)
Dependent Variable: value
i/j 1 2 3
1 <.0001 <.0001
2 <.0001 0.9844
3 <.0001 0.9844
Dependent Variable: value
Contrast DF Contrast SS Mean Square F Value Pr > F
linear trend 1 116.6628125 116.6628125 24.19 <.0001
curved trend 1 33.7251042 33.7251042 6.99 0.0120
Tests of Hypotheses Using the Type III MS for batch*coats as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
batch 3 152.8516667 50.9505556 165.06 <.0001
coats 2 150.3879167 75.1939583 243.60 <.0001