# The GLM Procedure

### Example 45.1 Randomized Complete Blocks with Means Comparisons and Contrasts

This example, reported by Stenstrom (1940), analyzes an experiment to investigate how snapdragons grow in various soils. To eliminate the effect of local fertility variations, the experiment is run in blocks, with each soil type sampled in each block. Since these data are balanced, the Type I and Type III SS are the same and are equal to the traditional ANOVA SS.

First, the standard analysis is shown, followed by an analysis that uses the SOLUTION option and includes MEANS and CONTRAST statements. The ORDER= DATA option in the second PROC GLM statement is used so that the ordering of coefficients in the CONTRAST statement can correspond to the ordering in the input data. The SOLUTION option requests a display of the parameter estimates, which are produced by default only if there are no CLASS variables. A MEANS statement is used to request a table of the means with two multiple-comparison procedures requested. In experiments with focused treatment questions, CONTRAST statements are preferable to general means comparison methods. The following statements produce Output 45.1.1 through Output 45.1.4.

```title 'Balanced Data from Randomized Complete Block';
data plants;
input Type \$ @;
do Block = 1 to 3;
input StemLength @;
output;
end;
datalines;
Clarion  32.7 32.3 31.5
Clinton  32.1 29.7 29.1
Knox     35.7 35.9 33.1
O'Neill  36.0 34.2 31.2
Compost  31.8 28.0 29.2
Wabash   38.2 37.8 31.9
Webster  32.5 31.1 29.7
;
```
```proc glm;
class Block Type;
model StemLength = Block Type;
run;
```
```proc glm order=data;
class Block Type;
model StemLength = Block Type / solution;

/*----------------------------------clrn-cltn-knox-onel-cpst-wbsh-wstr */
contrast 'Compost vs. others'  Type   -1   -1   -1   -1    6   -1   -1;
contrast 'River soils vs. non' Type   -1   -1   -1   -1    0    5   -1,
Type   -1    4   -1   -1    0    0   -1;
contrast 'Glacial vs. drift'   Type   -1    0    1    1    0    0   -1;
contrast 'Clarion vs. Webster' Type   -1    0    0    0    0    0    1;
contrast "Knox vs. O'Neill"    Type    0    0    1   -1    0    0    0;
run;

means Type / waller regwq;
run;
```

Output 45.1.1: Analysis of Variance for Randomized Complete Blocks

 Balanced Data from Randomized Complete Block

The GLM Procedure

Class Level Information
Class Levels Values
Block 3 1 2 3
Type 7 Clarion Clinton Compost Knox O'Neill Wabash Webster

 Number of Observations Read 21 21

 Balanced Data from Randomized Complete Block

The GLM Procedure

Dependent Variable: StemLength

Source DF Sum of Squares Mean Square F Value Pr > F
Model 8 142.1885714 17.7735714 10.80 0.0002
Error 12 19.7428571 1.6452381
Corrected Total 20 161.9314286

R-Square Coeff Var Root MSE StemLength Mean
0.878079 3.939745 1.282668 32.55714

Source DF Type I SS Mean Square F Value Pr > F
Block 2 39.0371429 19.5185714 11.86 0.0014
Type 6 103.1514286 17.1919048 10.45 0.0004

Source DF Type III SS Mean Square F Value Pr > F
Block 2 39.0371429 19.5185714 11.86 0.0014
Type 6 103.1514286 17.1919048 10.45 0.0004

This analysis shows that the stem length is significantly different for the different soil types. In addition, there are significant differences in stem length among the three blocks in the experiment.

The GLM procedure is invoked again, this time with the ORDER= DATA option. This enables you to write accurate contrast statements more easily because you know the order SAS is using for the levels of the variable `Type`. The standard analysis is displayed again, this time including the tests for contrasts that you specified as well as the estimated parameters. These additional results are shown in Output 45.1.2.

Output 45.1.2: Contrasts and Solutions

 Balanced Data from Randomized Complete Block

The GLM Procedure

Dependent Variable: StemLength

Contrast DF Contrast SS Mean Square F Value Pr > F
Compost vs. others 1 29.24198413 29.24198413 17.77 0.0012
River soils vs. non 2 48.24694444 24.12347222 14.66 0.0006
Glacial vs. drift 1 22.14083333 22.14083333 13.46 0.0032
Clarion vs. Webster 1 1.70666667 1.70666667 1.04 0.3285
Knox vs. O'Neill 1 1.81500000 1.81500000 1.10 0.3143

Parameter Estimate   Standard
Error
t Value Pr > |t|
Intercept 29.35714286 B 0.83970354 34.96 <.0001
Block 1 3.32857143 B 0.68561507 4.85 0.0004
Block 2 1.90000000 B 0.68561507 2.77 0.0169
Block 3 0.00000000 B . . .
Type Clarion 1.06666667 B 1.04729432 1.02 0.3285
Type Clinton -0.80000000 B 1.04729432 -0.76 0.4597
Type Knox 3.80000000 B 1.04729432 3.63 0.0035
Type O'Neill 2.70000000 B 1.04729432 2.58 0.0242
Type Compost -1.43333333 B 1.04729432 -1.37 0.1962
Type Wabash 4.86666667 B 1.04729432 4.65 0.0006
Type Webster 0.00000000 B . . .

 Note: The X'X matrix has been found to be singular, and a generalized inverse was used to solve the normal equations. Terms whose estimates are followed by the letter 'B' are not uniquely estimable.

The contrast label, degrees of freedom, sum of squares, Mean Square, F Value, and Pr > F are shown for each contrast requested. In this example, the contrast results indicate the following inferences, at the 5% significance level:

• The stem length of plants grown in compost soil is significantly different from the average stem length of plants grown in other soils.

• The stem length of plants grown in river soils is significantly different from the average stem length of those grown in nonriver soils.

• The average stem length of plants grown in glacial soils (Clarion and Webster types) is significantly different from the average stem length of those grown in drift soils (Knox and O’Neill types).

• Stem lengths for Clarion and Webster types are not significantly different.

• Stem lengths for Knox and O’Neill types are not significantly different.

In addition to the estimates for the parameters of the model, the results of t tests about the parameters are also displayed. The ‘B’ following the parameter estimates indicates that the estimates are biased and do not represent a unique solution to the normal equations.

Output 45.1.3: Waller-Duncan tests

 Balanced Data from Randomized Complete Block

The GLM Procedure

Waller-Duncan K-ratio t Test for StemLength

 Note: This test minimizes the Bayes risk under additive loss and certain other assumptions.

 Kratio 100 12 1.64524 10.45 2.12034 2.2206

Means with the same letter are
not significantly different.
Waller Grouping Mean N Type
A 35.967 3 Wabash
A
A 34.900 3 Knox
A
B A 33.800 3 O'Neill
B
B C 32.167 3 Clarion
C
D C 31.100 3 Webster
D C
D C 30.300 3 Clinton
D
D   29.667 3 Compost

Output 45.1.4: Ryan-Einot-Gabriel-Welsch Multiple Range Test

 Balanced Data from Randomized Complete Block

The GLM Procedure

Ryan-Einot-Gabriel-Welsch Multiple Range Test for StemLength

 Note: This test controls the Type I experimentwise error rate.

 Alpha 0.05 12 1.64524

Number of Means 2 3 4 5 6 7
Critical Range 2.9875528 3.2837322 3.4395625 3.5402383 3.5402383 3.6653133

Means with the same letter are
not significantly different.
REGWQ Grouping Mean N Type
A   35.967 3 Wabash
A
B A   34.900 3 Knox
B A
B A C 33.800 3 O'Neill
B   C
B D C 32.167 3 Clarion
D C
D C 31.100 3 Webster
D
D   30.300 3 Clinton
D
D   29.667 3 Compost

The final two pages of output (Output 45.1.3 and Output 45.1.4) present results of the Waller-Duncan and REGWQ multiple-comparison procedures. For each test, notes and information pertinent to the test are given in the output. The `Type` means are arranged from highest to lowest. Means with the same letter are not significantly different. For this example, while some pairs of means are significantly different, there are no clear equivalence classes among the different soils.

For an alternative method of analyzing and displaying mean differences, including high-resolution graphics, see Example 45.3.