Nested, Subsampling Design


The data, log and output from SAS for the Nested/Subsampling example from the course notes are given below. This will be updated from time to time!

Here are the input data and SAS statements


data subsamp1;
input trt tree apple wt;
cards;
   1  1  1  313.063
   1  1  2  329.132
   1  1  3  334.278
   1  1  4  330.088
   1  1  5  334.987
   1  1  6  325.075
   1  2  1  333.936
   1  2  2  326.155
   1  2  3  352.854
   1  2  4  350.791
   1  2  5  318.560
   1  2  6  323.473
   1  3  1  345.494
   1  3  2  349.296
   1  3  3  339.190
   1  3  4  338.942
   1  3  5  331.370
   1  3  6  339.097
   1  4  1  340.840
   1  4  2  336.798
   1  4  3  313.810
   1  4  4  333.880
   1  4  5  343.068
   1  4  6  319.171
   2  1  1  349.271
   2  1  2  336.695
   2  1  3  352.797
   2  1  4  348.486
   2  1  5  352.077
   2  1  6  341.423
   2  2  1  356.880
   2  2  2  356.256
   2  2  3  364.950
   2  2  4  360.570
   2  2  5  362.104
   2  2  6  371.829
   2  3  1  324.161
   2  3  2  340.130
   2  3  3  334.580
   2  3  4  342.813
   2  3  5  327.415
   2  3  6  333.571
   2  4  1  338.742
   2  4  2  340.348
   2  4  3  362.837
   2  4  4  340.782
   2  4  5  348.730
   2  4  6  325.444
   3  1  1  387.868
   3  1  2  372.807
   3  1  3  380.505
   3  1  4  391.804
   3  1  5  388.935
   3  1  6  361.860
   3  2  1  377.948
   3  2  2  380.033
   3  2  3  361.913
   3  2  4  363.098
   3  2  5  365.375
   3  2  6  382.121
   3  3  1  363.583
   3  3  2  387.727
   3  3  3  373.021
   3  3  4  362.931
   3  3  5  378.928
   3  3  6  364.442
   3  4  1  374.851
   3  4  2  361.291
   3  4  3  377.389
   3  4  4  366.722
   3  4  5  374.187
   3  4  6  380.383
   ;
proc glm; /* ANOVA ignoring trees (wrong!) */
classes trt;
model wt = trt;
lsmeans trt/stderr pdiff;
contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
run;

proc glm; /* Nested ANOVA, testing trt against tree Mean Square */
classes trt tree;
model wt = trt tree(trt)/xpx solution;
random tree(trt); /* Specifying tree within trt as a random effect */
test h=trt e=tree(trt); /* Explicitly testing MS trt against MS tree */
lsmeans trt/stderr pdiff e=tree(trt); /* Least Squares Means, using
                                         MS tree as the appropriate error */
contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5 tree(trt) .25 .25 .25 .25
  -.125 -.125 -.125 -.125 -.125 -.125 -.125 -.125/e=tree(trt);
estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5 tree(trt) .25 .25 .25 .25
  -.125 -.125 -.125 -.125 -.125 -.125 -.125 -.125;
/* Explicitly construct contrasts for SS trt (Type I) */
contrast ' SS trt' trt 4 -4 0 tree(trt) 1 1 1 1 -1 -1 -1 -1 0 0 0 0,
                   trt 4 - -4 tree(trt) 1 1 1 1 0 0 0 0 -1 -1 -1 -1;
run;

proc mixed; /* Mixed model analysis, as it should be done */
classes trt tree;
model wt = trt; /* specify only fixed effects */
random tree(trt); /* specify tree within trt as a random effect */
lsmeans trt;
contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
run;

proc sort; /* sort data, by trt and tree within trt */
by trt tree;
run;

proc means; /* compute mean for each tree, and output to a new dataset */
var wt;
by trt tree;
output out=pmeans mean=gmean;
run;

proc glm data=pmeans; /* Analyse tree means, using a 1-way ANOVA */
classes trt;
model gmean = trt;
lsmeans trt/stderr pdiff;
contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
run;


SAS log

The SAS log provides a lot of useful information about the data step and the various PROCedures. We can see that SAS read in 72 observations, which agrees with what we would expect (3 treatments, 4 trees per treatment and 6 apples per tree). There are no error messages; which does not necessarily mean everything is correct, only that SAS did not detect anything wrong! If there are any error messages they should not be ignored, we should correct the errors before proceeding.


NOTE: Copyright (c) 1989-1996 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software Release 6.12  TS020
      Licensed to MCGILL UNIVERSITY COMPUTING CENTRE, Site 0009211001.


5
6    data subsamp1;
7    input trt tree apple wt;
8    cards;

NOTE: The data set WORK.SUBSAMP1 has 72 observations and 4 variables.
NOTE: The DATA statement used 2.31 seconds.


81      ;
82   proc glm; /* ANOVA ignoring trees (wrong!) */
83   classes trt;
84   model wt = trt;                               <--- Analysis 1
85   lsmeans trt/stderr pdiff;
86   contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
87   estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
88   run;

89

NOTE: The PROCEDURE GLM used 3.37 seconds.

                                                   <--- Analysis 2
90   proc glm; /* Nested ANOVA, testing trt against tree Mean Square */
91   classes trt tree;
92   model wt = trt tree(trt)/xpx solution;
93   random tree(trt); /* Specifying tree within trt as a random effect */
94   test h=trt e=tree(trt); /* Explicitly testing MS trt against MS tree */
95   lsmeans trt/stderr pdiff e=tree(trt); /* Least Squares Means, using
96                                            MS tree as the appropriate
error */
97   contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5 tree(trt) .25 .25 .25 .25
  -.125 -.125 -.125 -.125 -.125 -.125 -.125 -.125/e=tree(trt);
98   estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5 tree(trt) .25 .25 .25 .25
  -.125 -.125 -.125 -.125 -.125 -.125 -.125 -.125;
99   run;

NOTE: TYPE I EMS not available without the E1 option.
100

NOTE: The PROCEDURE GLM used 2.33 seconds.

                                                 <--- Analysis 3
101  proc mixed; /* Mixed model analysis, as it should be done */
102  classes trt tree;
103  model wt = trt; /* specify only fixed effects */
104  random tree(trt); /* specify tree within trt as a random effect */
105  lsmeans trt;
106  contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
107  estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
108  run;

NOTE: The PROCEDURE MIXED used 2.58 seconds.


109
110  proc sort; /* sort data, by trt and tree within trt */
111  by trt tree;
112  run;

NOTE: The data set WORK.SUBSAMP1 has 72 observations and 4 variables.
NOTE: The PROCEDURE SORT used 0.81 seconds.


113
114  proc means; /* compute mean for each tree, and output to a new dataset */
115  var wt;
116  by trt tree;
117  output out=pmeans mean=gmean;
118  run;

NOTE: The data set WORK.PMEANS has 12 observations and 5 variables.
NOTE: The PROCEDURE MEANS used 1.5 seconds.


119
120  proc glm data=pmeans; /* Analyse tree means, using a 1-way ANOVA */
121  classes trt;
122  model gmean = trt;                               <--- Analysis 4
123  lsmeans trt/stderr pdiff;
124  contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
125  estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;
126  run;


The SAS System 1

                       General Linear Models Procedure
                           Class Level Information
  Analysis 1
                          Class    Levels    Values
                          TRT           3    1 2 3


                   Number of observations in data set = 72

We can see that in this analysis (the first analysis), SAS used 72 observations and that there was 1 CLASS variable (trt) with 3 levels (1, 2 and 3).


The SAS System 2

                       General Linear Models Procedure

Dependent Variable: WT
                                    Sum of           Mean
Source                  DF         Squares         Square   F Value     Pr > F
Model                    2     20747.03666    10373.51833     80.42     0.0001

Error                   69      8900.87204      128.99815

Corrected Total         71     29647.90869

                  R-Square            C.V.       Root MSE              WT Mean
                  0.699781        3.232757       11.35774             351.3328

Source                  DF       Type I SS    Mean Square   F Value     Pr > F
TRT                      2     20747.03666    10373.51833     80.42     0.0001

Source                  DF     Type III SS    Mean Square   F Value     Pr > F
TRT                      2     20747.03666    10373.51833     80.42     0.0001


Here we have the basic ANOVA table, shown at the top. The model is actually, as discussed before, the Model corrected for the Mean, R(trt | µ). Then underneath the basic ANOVA table is the subdivision into the various component effects. In this case since there is only 1 effect (treatment) in the model there is in fact nothing more to subdivide, which explains why the Type I and Type III Sums of Squares are the same.


The SAS System 3

                       General Linear Models Procedure
                             Least Squares Means

            TRT            WT       Std Err     Pr > |T|   LSMEAN
                       LSMEAN        LSMEAN   H0:LSMEAN=0   Number
            1      333.472833      2.318388        0.0001     1
            2      346.370458      2.318388        0.0001     2
            3      374.155083      2.318388        0.0001     3

                       Pr > |T| H0: LSMEAN(i)=LSMEAN(j)

                            i/j     1       2       3
                            1   .      0.0002  0.0001
                            2  0.0002   .      0.0001
                            3  0.0001  0.0001   .
NOTE: To ensure overall protection level, only probabilities associated with
      pre-planned comparisons should be used.

Here we see the Least Squares Means for each of the treatment effects; which are simply µ + trti, together with the standard errors (2.32) for each mean. Under the table of Least Squares Means we have the table of probabilities associated with comparisons amongst all pairs of treatments. Note, however, the caveat that only pre-planned comparisons really have the associated probability levels.


The SAS System 4

                       General Linear Models Procedure

Dependent Variable: WT

Contrast                DF     Contrast SS    Mean Square   F Value     Pr > F
 trt 1 - (trt 2+3)/2     1     11483.21202    11483.21202     89.02     0.0001

                                        T for H0:    Pr > |T|   Std Error of
Parameter                  Estimate    Parameter=0                Estimate
 trt 1 - (trt 2+3)/2    -26.7899375          -9.43     0.0001     2.83943376


Here we see the results of the specific CONTRAST between treatment 1 and the average of treatments 2 and 3 that we had also requested. Note that the Sums of Squares, Mean Squares and F-ratio are not the same as those for the comparisons between treatments in the ANOVA; this is a slightly different question which begets a slightly different answer! Also, we have the ESTIMATE of this difference, together with it's computed standard error. Note the estimate and the standard error; we will return see the corresponding values from the other 3 analyses.


The SAS System 5

                       General Linear Models Procedure
                           Class Level Information
  Analysis 2
                          Class    Levels    Values
                          TRT           3    1 2 3

                          TREE          4    1 2 3 4


                   Number of observations in data set = 72

Again, we can see that there were 72 observations in this analysis and that there were 3 treatments, the 3 levels of trt. It might appear that there were only 4 trees (whereas we know that there were 12). This is because we (I!) had labeled the trees 1 to 4 within each treatment, so at this stage (we are only at the CLASSES line specification) we have not yet fitted a model and PROC GLM has no way of knowing that we are going to fit a nested model.


The SAS System 6

                       General Linear Models Procedure
                        Matrix Element Representation

Dependent Variable: WT

                      Effect             Representation
                      INTERCEPT          INTERCEPT

                      TRT          1     TRT 1
                                   2     TRT 2
                                   3     TRT 3

                      TREE(TRT)    1 1   DUMMY001
                                   2 1   DUMMY002
                                   3 1   DUMMY003
                                   4 1   DUMMY004
                                   1 2   DUMMY005
                                   2 2   DUMMY006
                                   3 2   DUMMY007
                                   4 2   DUMMY008
                                   1 3   DUMMY009
                                   2 3   DUMMY010
                                   3 3   DUMMY011
                                   4 3   DUMMY012

Here we can see how we can see exactly what order SAS uses to arrange the various levels; useful for when we are specifying the various coefficients to the CONTRAST and/or ESTIMATE statements.


The SAS System 7

                       General Linear Models Procedure

                                The X'X Matrix

                INTERCEPT        TRT 1        TRT 2        TRT 3
INTERCEPT              72           24           24           24
TRT 1                  24           24            0            0
TRT 2                  24            0           24            0
TRT 3                  24            0            0           24
DUMMY001                6            6            0            0
DUMMY002                6            6            0            0
DUMMY003                6            6            0            0
DUMMY004                6            6            0            0
DUMMY005                6            0            6            0
DUMMY006                6            0            6            0
DUMMY007                6            0            6            0
DUMMY008                6            0            6            0
DUMMY009                6            0            0            6
DUMMY010                6            0            0            6
DUMMY011                6            0            0            6
DUMMY012                6            0            0            6
WT              25295.961     8003.348     8312.891     8979.722

                 DUMMY001     DUMMY002     DUMMY003     DUMMY004
INTERCEPT               6            6            6            6
TRT 1                   6            6            6            6
TRT 2                   0            0            0            0
TRT 3                   0            0            0            0
DUMMY001                6            0            0            0
DUMMY002                0            6            0            0
DUMMY003                0            0            6            0
DUMMY004                0            0            0            6
DUMMY005                0            0            0            0

The SAS System 8

                       General Linear Models Procedure

                                The X'X Matrix

                 DUMMY001     DUMMY002     DUMMY003     DUMMY004
DUMMY006                0            0            0            0
DUMMY007                0            0            0            0
DUMMY008                0            0            0            0
DUMMY009                0            0            0            0
DUMMY010                0            0            0            0
DUMMY011                0            0            0            0
DUMMY012                0            0            0            0
WT               1966.623     2005.769     2043.389     1987.567

                 DUMMY005     DUMMY006     DUMMY007     DUMMY008
INTERCEPT               6            6            6            6
TRT 1                   0            0            0            0
TRT 2                   6            6            6            6
TRT 3                   0            0            0            0
DUMMY001                0            0            0            0
DUMMY002                0            0            0            0
DUMMY003                0            0            0            0
DUMMY004                0            0            0            0
DUMMY005                6            0            0            0
DUMMY006                0            6            0            0
DUMMY007                0            0            6            0
DUMMY008                0            0            0            6
DUMMY009                0            0            0            0
DUMMY010                0            0            0            0
DUMMY011                0            0            0            0
DUMMY012                0            0            0            0
WT               2080.749     2172.589      2002.67     2056.883


The SAS System 9

                       General Linear Models Procedure

                                The X'X Matrix

                 DUMMY009     DUMMY010     DUMMY011     DUMMY012
INTERCEPT               6            6            6            6
TRT 1                   0            0            0            0
TRT 2                   0            0            0            0
TRT 3                   6            6            6            6
DUMMY001                0            0            0            0
DUMMY002                0            0            0            0
DUMMY003                0            0            0            0
DUMMY004                0            0            0            0
DUMMY005                0            0            0            0
DUMMY006                0            0            0            0
DUMMY007                0            0            0            0
DUMMY008                0            0            0            0
DUMMY009                6            0            0            0
DUMMY010                0            6            0            0
DUMMY011                0            0            6            0
DUMMY012                0            0            0            6
WT               2283.779     2230.488     2230.632     2234.823

                       WT
INTERCEPT       25295.961
TRT 1            8003.348
TRT 2            8312.891
TRT 3            8979.722
DUMMY001         1966.623
DUMMY002         2005.769
DUMMY003         2043.389
DUMMY004         1987.567
DUMMY005         2080.749

The SAS System 10

                       General Linear Models Procedure

                                The X'X Matrix

                       WT
DUMMY006         2172.589
DUMMY007          2002.67
DUMMY008         2056.883
DUMMY009         2283.779
DUMMY010         2230.488
DUMMY011         2230.632
DUMMY012         2234.823
WT           8916948.5047


The SAS System 11

                       General Linear Models Procedure

Dependent Variable: WT
                                    Sum of           Mean
Source                  DF         Squares         Square   F Value     Pr > F
Model                   11     24127.21374     2193.38307     23.84     0.0001

Error                   60      5520.69496       92.01158

Corrected Total         71     29647.90869

Here we have the Basic ANOVA; the Model (actually the Model over and above the Mean) and the Residual. We can see that Treatment and/or Tree within Treatment has a significant effect.


                  R-Square            C.V.       Root MSE              WT Mean
                  0.813791        2.730251       9.592267             351.3328

Note also, that the Wt Mean (y bar), is exactly the same as in the previous model, and similarly the Corrected Total Sums of Squares. These will not change regardless of the model fitted.


Source                  DF       Type I SS    Mean Square   F Value     Pr > F
TRT                      2     20747.03666    10373.51833    112.74     0.0001
TREE(TRT)                9      3380.17708      375.57523      4.08     0.0004

Source                  DF     Type III SS    Mean Square   F Value     Pr > F
TRT                      2     20747.03666    10373.51833    112.74     0.0001
TREE(TRT)                9      3380.17708      375.57523      4.08     0.0004

Here we can see the Sums of Squares for Treatments and Trees within treatments. Compare the Type I Sums of Squares for Treatments with the Sums of Squares for Treatments from Analysis 1; we see that they are both the same (20747). This is because in Analysis 1 the only effect that we fitted was that for treaments, so the effect of treatment was R(trt | µ). In the analysis (2) the Type I Sums of Squares for treaments are the Sums of Squares due to fitting Treatment after the Mean, but not correcting for anything else, and hence we still have R(trt | µ), and hence we still have exactly the same Sums of Squares.


The SAS System 12

                       General Linear Models Procedure

Dependent Variable: WT

                                        T for H0:    Pr > |T|   Std Error of
Parameter                  Estimate    Parameter=0                Estimate
INTERCEPT               372.4705000 B        95.11     0.0001     3.91602653
TRT       1             -41.2093333 B        -7.44     0.0001     5.53809783
          2             -29.6566667 B        -5.36     0.0001     5.53809783
          3               0.0000000 B          .        .          .
TREE(TRT) 1 1            -3.4906667 B        -0.63     0.5309     5.53809783
          2 1             3.0336667 B         0.55     0.5859     5.53809783
          3 1             9.3036667 B         1.68     0.0982     5.53809783
          4 1             0.0000000 B          .        .          .
          1 2             3.9776667 B         0.72     0.4754     5.53809783
          2 2            19.2843333 B         3.48     0.0009     5.53809783
          3 2            -9.0355000 B        -1.63     0.1080     5.53809783
          4 2             0.0000000 B          .        .          .
          1 3             8.1593333 B         1.47     0.1459     5.53809783
          2 3            -0.7225000 B        -0.13     0.8966     5.53809783
          3 3            -0.6985000 B        -0.13     0.9001     5.53809783
          4 3             0.0000000 B          .        .          .
NOTE: The X'X matrix has been found to be singular and a generalized inverse
      was used to solve the normal equations.   Estimates followed by the
      letter 'B' are biased, and are not unique estimators of the parameters.

Here we have the solution vector, since we requested it in the model statement as one of the options. SAS tells us that the 'so-called' estimates are in fact biased, they are only solutions and not estimates since X'X is not of full rank and hence on unique inverse exists.


The SAS System 13

                       General Linear Models Procedure

Source      Type III Expected Mean Square
TRT         Var(Error) + 6 Var(TREE(TRT)) + Q(TRT)

TREE(TRT)   Var(Error) + 6 Var(TREE(TRT))

We had specified that Tree within treatment was a random effect,

random tree(trt); /* Specifying tree within trt as a random effect */

so GLM provides a Table of the Expectations of the Mean Squares. This can help in deciding just which Mean Square should be tested against which. We can thus see that the Mean Square for Trt should be tested againt the Mean Square for Tree(Trt), since they differ only in the Q(Trt) component. In addition, if we want to we can use these coefficients to help us compute the variance due to trees, Var(Tree(Trt)).

The Mean Square Error = 92.01158. The Mean Square for Trees within Treatments = 375.57. Therefore an unbiased estimate of the Tree variance is:

(375.57523 - 92.01158)/6 = 47.26


The SAS System 14

                       General Linear Models Procedure
                             Least Squares Means

   Standard Errors and Probabilities calculated using the Type III MS for
                          TREE(TRT) as an Error term

            TRT            WT       Std Err     Pr > |T|   LSMEAN
                       LSMEAN        LSMEAN   H0:LSMEAN=0   Number
            1      333.472833      3.955878        0.0001     1
            2      346.370458      3.955878        0.0001     2
            3      374.155083      3.955878        0.0001     3

                       Pr > |T| H0: LSMEAN(i)=LSMEAN(j)

                            i/j     1       2       3
                            1   .      0.0466  0.0001
                            2  0.0466   .      0.0008
                            3  0.0001  0.0008   .
NOTE: To ensure overall protection level, only probabilities associated with
      pre-planned comparisons should be used.

The Least Squares Means, standard errors and the table of probabilities of each pair-wise comparison are shown above; we had requested the LSMEANS for TRT and we had specified that the Error Mean Square to be used is not the default MSE, but rather the Mean Square for Trees within Treatment.

lsmeans trt/stderr pdiff e=tree(trt); /* Least Squares Means, using
                                         MS tree as the appropriate error */

Note the considerably larger standard errors to the LSMeans and the huge difference in the probability associated with the difference between treatment 1 and treatment 2 ( PR 0.0466 compared to 0.0002 in Analysis 1). This illustrates, again, the misinformation that can result from not correctly specifying the correct error term for an analysis using GLM. If we had used PROC MIXED this would have been accommodated 'automagically'.

Again, as in Analysis 1, SAS provides the warning that only the pre-planned comparisons are valid. This is much like the health warning on cigarette packets; largely ignored, and likewise over the long term equally damaging to your health (mental!).



The SAS System 15

                       General Linear Models Procedure

Dependent Variable: WT

Tests of Hypotheses using the Type III MS for TREE(TRT) as an error term

Source                  DF     Type III SS    Mean Square   F Value     Pr > F
TRT                      2     20747.03666    10373.51833     27.62     0.0001
Tests of Hypotheses using the Type III MS for TREE(TRT) as an error term

Contrast                DF     Contrast SS    Mean Square   F Value     Pr > F
 trt 1 - (trt 2+3)/2     1     11483.21202    11483.21202     30.57     0.0004

                                        T for H0:    Pr > |T|   Std Error of
Parameter                  Estimate    Parameter=0                Estimate
 trt 1 - (trt 2+3)/2    -26.7899375         -11.17     0.0001     2.39806670


We had requested a hypothesis test to test the Hypothesis of Treatment effects using Tree within Treatment as the appropriate Error term.

test h=trt e=tree(trt); /* Explicitly testing MS trt against MS tree */

The F-value (27.62) is the Mean Square for Trt (10373.5) divided by the Mean Square for Trees within Trt (375.6), with 2 d.f. for the numerator and 9 d.f. for the denominator.

We also have the test of hypothesis associated with the test of treatment 1 vs the average of treatment 2 and 3.

contrast ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5/e=tree(trt);

Note that here again we have specified that the Mean Square for Tree(Trt) is to be used as the appropriate Error term.

We had also asked for the ESTIMATE of the difference between treatment 1 and the average of treatments 2 and 3.

estimate ' trt 1 - (trt 2+3)/2' trt 1 -.5 -.5;

The estimate was -26.8 ± 2.398. This standard error is the same as from our 1st analysis; not because it is correct, but rather because the GLM ESTIMATE statement (designed for fixed effects analyses) does not allow us to specify an error term other than the residual. So even though in the CONTRAST statement above we have declared that the Mean Square between Trees with Treatments is the appropriate Error term to be used in testing Treatments we cannot specify that here with the Estimate statement and the Residual Mean Square is (incorrectly) used. This is just one of the various problems associated with using PROC GLM for the analysis of models with Random Effects.


The SAS System 16


                             The MIXED Procedure
 Analysis 3
                           Class Level Information

                          Class     Levels  Values
                          TRT            3  1 2 3
                          TREE           4  1 2 3 4

                      REML Estimation Iteration History

              Iteration  Evaluations     Objective     Criterion
                      0            1  413.86022542
                      1            1  403.20515872    0.00000000

                          Convergence criteria met.

Note that 2 iterations were required to obtain convergence, the initial iteration 0, and another iteration (1). since this was a balanced analysis with only 2 factors in the model (Trt and Tree) it converged very quickly. With other more complicated models it may take 5 or 10 iterations to converge.


                    Covariance Parameter Estimates (REML)

                    Cov Parm        Estimate
                    TREE(TRT)    47.26060809
                    Residual     92.01158261

Note that the estimates of the variance components agree with those presented above from Analysis 2. This is because with a completely balanced experiment the ANOVA from Analysis 3 gives us the same results as PROC MIXED. Otherwise we would not get the same answers, PROC MIXED would be the correct approach to use.


                       Model Fitting Information for WT

                   Description                        Value
                   Observations                     72.0000
                   Res Log Likelihood              -265.009
                   Akaike's Information Criterion  -267.009
                   Schwarz's Bayesian Criterion    -269.243

The SAS System 17


                       Model Fitting Information for WT

                   Description                        Value
                   -2 Res Log Likelihood           530.0187

                           Tests of Fixed Effects

                  Source      NDF   DDF  Type III F  Pr > F
                  TRT           2     9       27.62  0.0001

                          ESTIMATE Statement Results

   Parameter                 Estimate     Std Error    DF       t  Pr > |t|
    trt 1 - (trt 2+3)/2  -26.78993750    4.84494086     9   -5.53    0.0004

                          CONTRAST Statement Results

               Source                 NDF   DDF       F  Pr > F
                trt 1 - (trt 2+3)/2     1     9   30.57  0.0004

                             Least Squares Means

       Effect  TRT        LSMEAN     Std Error    DF       t  Pr > |t|
       TRT     1    333.47283333    3.95587765     9   84.30    0.0001
       TRT     2    346.37045833    3.95587765     9   87.56    0.0001
       TRT     3    374.15508333    3.95587765     9   94.58    0.0001

The SAS System 18

          Analysis Variable : WT

--------------------------------- TRT=1 TREE=1 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   327.7705000     8.0650628   313.0630000   334.9870000
          ----------------------------------------------------------
--------------------------------- TRT=1 TREE=2 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   334.2948333    14.4751434   318.5600000   352.8540000
          ----------------------------------------------------------
--------------------------------- TRT=1 TREE=3 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   340.5648333     6.1927894   331.3700000   349.2960000
          ----------------------------------------------------------
--------------------------------- TRT=1 TREE=4 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   331.2611667    11.9948782   313.8100000   343.0680000
          ----------------------------------------------------------
--------------------------------- TRT=2 TREE=1 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   346.7915000     6.3840723   336.6950000   352.7970000
          ----------------------------------------------------------
--------------------------------- TRT=2 TREE=2 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   362.0981667     5.7709197   356.2560000   371.8290000
          ----------------------------------------------------------
--------------------------------- TRT=2 TREE=3 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   333.7783333     7.1503796   324.1610000   342.8130000
          ----------------------------------------------------------
--------------------------------- TRT=2 TREE=4 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   342.8138333    12.3646904   325.4440000   362.8370000
          ----------------------------------------------------------
--------------------------------- TRT=3 TREE=1 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   380.6298333    11.4869300   361.8600000   391.8040000
          ----------------------------------------------------------
--------------------------------- TRT=3 TREE=2 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   371.7480000     9.2395369   361.9130000   382.1210000
          ----------------------------------------------------------
--------------------------------- TRT=3 TREE=3 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   371.7720000    10.0626265   362.9310000   387.7270000
          ----------------------------------------------------------
--------------------------------- TRT=3 TREE=4 -------------------------------

           N          Mean       Std Dev       Minimum       Maximum
          ----------------------------------------------------------
           6   372.4705000     7.1195354   361.2910000   380.3830000
          ----------------------------------------------------------

The SAS System 19

                       General Linear Models Procedure
                           Class Level Information
 Analysis 4
                          Class    Levels    Values
                          TRT           3    1 2 3


                   Number of observations in data set = 12


The SAS System 20

                       General Linear Models Procedure

Dependent Variable: GMEAN
                                    Sum of           Mean
Source                  DF         Squares         Square   F Value     Pr > F
Model                    2     3457.839443    1728.919721     27.62     0.0001

Error                    9      563.362847      62.595872

Corrected Total         11     4021.202290

                  R-Square            C.V.       Root MSE           GMEAN Mean
                  0.859902        2.251926       7.911755             351.3328

Source                  DF       Type I SS    Mean Square   F Value     Pr > F
TRT                      2     3457.839443    1728.919721     27.62     0.0001

Source                  DF     Type III SS    Mean Square   F Value     Pr > F
TRT                      2     3457.839443    1728.919721     27.62     0.0001


Note that we have only 12 observations (the 12 tree means) in this analysis. The Sums of Squares, etc are not the same as in the previous analyses, but the F-ratio for the test of Treatments is 27.62, exactly the same as in Analysis 3 (from PROC MIXED) and Analysis 2 (PROC GLM, but specifying that Tree was a random effect nested within Trt) and the statistical significance is also correct. Note also the agreement with the standard errors of the Least Squares Means and the ESTIMATE statement.


The SAS System 21

                       General Linear Models Procedure
                             Least Squares Means

            TRT         GMEAN       Std Err     Pr > |T|   LSMEAN
                       LSMEAN        LSMEAN   H0:LSMEAN=0   Number
            1      333.472833      3.955878        0.0001     1
            2      346.370458      3.955878        0.0001     2
            3      374.155083      3.955878        0.0001     3

                       Pr > |T| H0: LSMEAN(i)=LSMEAN(j)

                            i/j     1       2       3
                            1   .      0.0466  0.0001
                            2  0.0466   .      0.0008
                            3  0.0001  0.0008   .
NOTE: To ensure overall protection level, only probabilities associated with
      pre-planned comparisons should be used.


The SAS System 22

                       General Linear Models Procedure

Dependent Variable: GMEAN

Contrast                DF     Contrast SS    Mean Square   F Value     Pr > F
 trt 1 - (trt 2+3)/2     1     1913.868670    1913.868670     30.57     0.0004

                                        T for H0:    Pr > |T|   Std Error of
Parameter                  Estimate    Parameter=0                Estimate
 trt 1 - (trt 2+3)/2    -26.7899375          -5.53     0.0004     4.84494086



R.I. Cue ©
Department of Animal Science, McGill University
last update : 2010 May 1