Skip to Main Content

Design and Analysis, Fourth Edition, by Keppel and Wickens Chapter 18: The Two-Factor Within-Subject Design | SAS Textbook Examples

Data from Table 18.3, page 407

data table18_3;
input s a b recall ;
datalines;
1 1 1 1
1 1 2 1
1 1 3 2		
1 1 4 2		
1 2 1 1
1 2 2 2		
1 2 3 2		
1 2 4 3		
1 3 1 1		
1 3 2 2
1 3 3 2
1 3 4 3	
2 1 1 2	
2 1 2 2	
2 1 3 3
2 1 4 4	
2 2 1 2	
2 2 2 3
2 2 3 4
2 2 4 5
2 3 1 3	
2 3 2 3
2 3 3 3
2 3 4 5
3 1 1 2
3 1 2 3
3 1 3 3
3 1 4 3
3 2 1 3
3 2 2 4
3 2 3 3
3 2 4 4
3 3 1 2
3 3 2 3
3 3 3 3
3 3 4 4
4 1 1 0
4 1 2 1
4 1 3 0
4 1 4 2
4 2 1 1
4 2 2 2
4 2 3 2
4 2 4 3
4 3 1 2
4 3 2 2
4 3 3 2
4 3 4 3
5 1 1 1
5 1 2 1
5 1 3 2
5 1 4 2
5 2 1 1
5 2 2 1
5 2 3 2
5 2 4 3
5 3 1 1
5 3 2 1
5 3 3 2
5 3 4 2
6 1 1 1
6 1 2 2
6 1 3 3
6 1 4 3
6 2 1 2
6 2 2 3
6 2 3 3
6 2 4 5
6 3 1 2
6 3 2 3
6 3 3 4
6 3 4 4
7 1 1 1
7 1 2 1
7 1 3 2
7 1 4 3
7 2 1 2
7 2 2 1
7 2 3 2
7 2 4 3
7 3 1 1
7 3 2 1
7 3 3 2
7 3 4 3
8 1 1 1
8 1 2 1
8 1 3 2
8 1 4 3
8 2 1 1
8 2 2 2
8 2 3 2
8 2 4 3
8 3 1 2
8 3 2 2
8 3 3 3
8 3 4 4
; 
run;

Table 18.4, page 408. Summary of the Analysis of Variance of a two-factor
within-subject design from the data in Table 18.3

NOTE: The model appears to have blown-up (no error sums of squares and
F-values) at first glance, however, the designation of  correct error terms
is required (see Keppel page 404-405 for discussion) and is done through the
test
command in SAS.

proc glm data = table18_3;
  class s a b;
  model recall = s|a|b /ss3;
  test h = a e = a*s;
  test h = b e = b*s;
  test h = a*b e = a*s*b;
run; quit;
The GLM Procedure

        Class Level Information
Class         Levels    Values
s                  8    1 2 3 4 5 6 7 8
a                  3    1 2 3
b                  4    1 2 3 4

Number of observations    96

Dependent Variable: recall
                                        Sum of
Source                      DF         Squares     Mean Square    F Value    Pr > F
Model                       95     107.8333333       1.1350877        .       .
Error                        0       0.0000000        .
Corrected Total             95     107.8333333

R-Square     Coeff Var      Root MSE    recall Mean
1.000000           .               .       2.291667

Source                      DF     Type III SS     Mean Square    F Value    Pr > F
s                            7     39.16666667      5.59523810        .       .
a                            2      8.33333333      4.16666667        .       .
s*a                         14      5.33333333      0.38095238        .       .
b                            3     42.08333333     14.02777778        .       .
s*b                         21      6.58333333      0.31349206        .       .
a*b                          6      0.66666667      0.11111111        .       .
s*a*b                       42      5.66666667      0.13492063        .       .

        Tests of Hypotheses Using the Type III MS for s*a as an Error Term
Source                      DF     Type III SS     Mean Square    F Value    Pr > F
a                            2      8.33333333      4.16666667      10.94    0.0014

        Tests of Hypotheses Using the Type III MS for s*b as an Error Term
Source                      DF     Type III SS     Mean Square    F Value    Pr > F
b                            3     42.08333333     14.02777778      44.75    <.0001

       Tests of Hypotheses Using the Type III MS for s*a*b as an Error Term
Source                      DF     Type III SS     Mean Square    F Value    Pr > F
a*b                          6      0.66666667      0.11111111       0.82    0.5582

Table 18.8, page 413. The analysis of the simple effects of the trials factor
B for words with positive emotional value (level a2)

proc glm data = table18_3;
  where a =2;
  class b s ;
  model recall = b s/ss3;
run; quit;
The GLM Procedure

        Class Level Information
Class         Levels    Values
b                  4    1 2 3 4
s                  8    1 2 3 4 5 6 7 8

Number of observations    32

Dependent Variable: recall
                                        Sum of
Source                      DF         Squares     Mean Square    F Value    Pr > F
Model                       10     33.25000000      3.32500000      14.70    <.0001
Error                       21      4.75000000      0.22619048
Corrected Total             31     38.00000000

R-Square     Coeff Var      Root MSE    recall Mean
0.875000      19.02379      0.475595       2.500000

Source                      DF     Type III SS     Mean Square    F Value    Pr > F
b                            3     16.75000000      5.58333333      24.68    <.0001
s                            7     16.50000000      2.35714286      10.42    <.0001