The GLM Procedure |
This example uses data from Cochran and Cox (1957, p. 176) to illustrate the analysis of a three-way factorial design with replication, including the use of the CONTRAST statement with interactions, the OUTSTAT= data set, and the SLICE= option in the LSMEANS statement.
The object of the study is to determine the effects of electric current on denervated muscle. The variables are as follows:
the replicate number, 1 or 2
the length of time the current is applied to the muscle, ranging from 1 to 4
the level of electric current applied, ranging from 1 to 4
the number of treatments per day, ranging from 1 to 3
the weight of the denervated muscle
The following statements produce Output 39.5.1 through Output 39.5.4.
data muscles; do Rep=1 to 2; do Time=1 to 4; do Current=1 to 4; do Number=1 to 3; input MuscleWeight @@; output; end; end; end; end; datalines; 72 74 69 61 61 65 62 65 70 85 76 61 67 52 62 60 55 59 64 65 64 67 72 60 57 66 72 72 43 43 63 66 72 56 75 92 57 56 78 60 63 58 61 79 68 73 86 71 46 74 58 60 64 52 71 64 71 53 65 66 44 58 54 57 55 51 62 61 79 60 78 82 53 50 61 56 57 56 56 56 71 56 58 69 46 55 64 56 55 57 64 66 62 59 58 88 ;
proc glm outstat=summary; class Rep Current Time Number; model MuscleWeight = Rep Current|Time|Number; contrast 'Time in Current 3' Time 1 0 0 -1 Current*Time 0 0 0 0 0 0 0 0 1 0 0 -1, Time 0 1 0 -1 Current*Time 0 0 0 0 0 0 0 0 0 1 0 -1, Time 0 0 1 -1 Current*Time 0 0 0 0 0 0 0 0 0 0 1 -1; contrast 'Current 1 versus 2' Current 1 -1; lsmeans Current*Time / slice=Current; run;
proc print data=summary; run;
The first CONTRAST statement examines the effects of Time within level 3 of Current. This is also called the simple effect of Time within Current*Time. Note that, since there are three degrees of freedom, it is necessary to specify three rows in the CONTRAST statement, separated by commas. Since the parameterization that PROC GLM uses is determined in part by the ordering of the variables in the CLASS statement, Current is specified before Time so that the Time parameters are nested within the Current*Time parameters; thus, the Current*Time contrast coefficients in each row are simply the Time coefficients of that row within the appropriate level of Current.
The second CONTRAST statement isolates a single-degree-of-freedom effect corresponding to the difference between the first two levels of Current. You can use such a contrast in a large experiment where certain preplanned comparisons are important, but you want to take advantage of the additional error degrees of freedom available when all levels of the factors are considered.
The LSMEANS statement with the SLICE= option is an alternative way to test for the simple effect of Time within Current*Time. In addition to listing the LS-means for each current strength and length of time, it gives a table of tests for differences between the LS-means across Time within each Current level. In some cases, this can be a way to disentangle a complex interaction.
Class Level Information | ||
---|---|---|
Class | Levels | Values |
Rep | 2 | 1 2 |
Current | 4 | 1 2 3 4 |
Time | 4 | 1 2 3 4 |
Number | 3 | 1 2 3 |
The output, shown in Output 39.5.2 and Output 39.5.3, indicates that the main effects for Rep, Current, and Number are significant (with -values of 0.0045, <0.0001, and 0.0461, respectively), but the main effect for Time is not significant, indicating that, in general, it does not matter how long the current is applied. None of the interaction terms are significant, nor are the contrasts significant. Notice that the row in the sliced ANOVA table corresponding to level 3 of current matches the "Time in Current 3" contrast.
Source | DF | Type I SS | Mean Square | F Value | Pr > F |
---|---|---|---|---|---|
Rep | 1 | 605.010417 | 605.010417 | 8.89 | 0.0045 |
Current | 3 | 2145.447917 | 715.149306 | 10.51 | <.0001 |
Time | 3 | 223.114583 | 74.371528 | 1.09 | 0.3616 |
Current*Time | 9 | 298.677083 | 33.186343 | 0.49 | 0.8756 |
Number | 2 | 447.437500 | 223.718750 | 3.29 | 0.0461 |
Current*Number | 6 | 644.395833 | 107.399306 | 1.58 | 0.1747 |
Time*Number | 6 | 367.979167 | 61.329861 | 0.90 | 0.5023 |
Current*Time*Number | 18 | 1050.854167 | 58.380787 | 0.86 | 0.6276 |
Source | DF | Type III SS | Mean Square | F Value | Pr > F |
---|---|---|---|---|---|
Rep | 1 | 605.010417 | 605.010417 | 8.89 | 0.0045 |
Current | 3 | 2145.447917 | 715.149306 | 10.51 | <.0001 |
Time | 3 | 223.114583 | 74.371528 | 1.09 | 0.3616 |
Current*Time | 9 | 298.677083 | 33.186343 | 0.49 | 0.8756 |
Number | 2 | 447.437500 | 223.718750 | 3.29 | 0.0461 |
Current*Number | 6 | 644.395833 | 107.399306 | 1.58 | 0.1747 |
Time*Number | 6 | 367.979167 | 61.329861 | 0.90 | 0.5023 |
Current*Time*Number | 18 | 1050.854167 | 58.380787 | 0.86 | 0.6276 |
The SS, statistics, and -values can be stored in an OUTSTAT= data set, as shown in Output 39.5.4.
Obs | _NAME_ | _SOURCE_ | _TYPE_ | DF | SS | F | PROB |
---|---|---|---|---|---|---|---|
1 | MuscleWeight | ERROR | ERROR | 47 | 3199.49 | . | . |
2 | MuscleWeight | Rep | SS1 | 1 | 605.01 | 8.8875 | 0.00454 |
3 | MuscleWeight | Current | SS1 | 3 | 2145.45 | 10.5054 | 0.00002 |
4 | MuscleWeight | Time | SS1 | 3 | 223.11 | 1.0925 | 0.36159 |
5 | MuscleWeight | Current*Time | SS1 | 9 | 298.68 | 0.4875 | 0.87562 |
6 | MuscleWeight | Number | SS1 | 2 | 447.44 | 3.2864 | 0.04614 |
7 | MuscleWeight | Current*Number | SS1 | 6 | 644.40 | 1.5777 | 0.17468 |
8 | MuscleWeight | Time*Number | SS1 | 6 | 367.98 | 0.9009 | 0.50231 |
9 | MuscleWeight | Current*Time*Number | SS1 | 18 | 1050.85 | 0.8576 | 0.62757 |
10 | MuscleWeight | Rep | SS3 | 1 | 605.01 | 8.8875 | 0.00454 |
11 | MuscleWeight | Current | SS3 | 3 | 2145.45 | 10.5054 | 0.00002 |
12 | MuscleWeight | Time | SS3 | 3 | 223.11 | 1.0925 | 0.36159 |
13 | MuscleWeight | Current*Time | SS3 | 9 | 298.68 | 0.4875 | 0.87562 |
14 | MuscleWeight | Number | SS3 | 2 | 447.44 | 3.2864 | 0.04614 |
15 | MuscleWeight | Current*Number | SS3 | 6 | 644.40 | 1.5777 | 0.17468 |
16 | MuscleWeight | Time*Number | SS3 | 6 | 367.98 | 0.9009 | 0.50231 |
17 | MuscleWeight | Current*Time*Number | SS3 | 18 | 1050.85 | 0.8576 | 0.62757 |
18 | MuscleWeight | Time in Current 3 | CONTRAST | 3 | 34.83 | 0.1706 | 0.91574 |
19 | MuscleWeight | Current 1 versus 2 | CONTRAST | 1 | 99.19 | 1.4570 | 0.23344 |
Copyright © SAS Institute, Inc. All Rights Reserved.