Data from table 23.3, page 515
data table23_3; input s a b c y @@; datalines; 1 1 1 1 11 1 1 1 2 5 1 1 1 3 3 2 1 1 1 12 2 1 1 2 10 2 1 1 3 5 3 1 2 1 17 3 1 2 2 11 3 1 2 3 11 4 1 2 1 18 4 1 2 2 16 4 1 2 3 13 5 2 1 1 20 5 2 1 2 14 5 2 1 3 13 6 2 1 1 12 6 2 1 2 10 6 2 1 3 9 7 2 2 1 16 7 2 2 2 10 7 2 2 3 10 8 2 2 1 20 8 2 2 2 18 8 2 2 3 14 9 3 1 1 23 9 3 1 2 17 9 3 1 3 18 10 3 1 1 22 10 3 1 2 19 10 3 1 3 22 11 3 2 1 14 11 3 2 2 8 11 3 2 3 8 12 3 2 1 18 12 3 2 2 16 12 3 2 3 12 ; run; data table23_3w; input s a b c1 c2 c3; datalines; 1 1 1 11 5 3 2 1 1 12 10 5 3 1 2 17 11 11 4 1 2 18 16 13 5 2 1 20 14 13 6 2 1 12 10 9 7 2 2 16 10 10 8 2 2 20 18 14 9 3 1 23 17 18 10 3 1 22 19 22 11 3 2 14 8 8 12 3 2 18 16 12 ; run;
Table 23.3, page 515. Analysis of variance of mixed three-way factorial design with two between-subject factors (a and b) and one within-subject factor (factor c)
NOTE: proc glm on the narrow data set in a A*B*(C*S) design is more complex than either proc mixed or proc glm on the wide data set. The complexities arises since we have to specify the nesting () of factors and define the tests for between and within subject tests. However, in a A*(B*C*S) design (the next problem) proc glm is the easiest way the model the between and within subject factors, but it is still complex. Table 23.2 and page 512-514 of Keppel discuss the correct error terms with respect the design.
proc glm data = table23_3; class s a b c; model y = a b a*b s(a*b) c a*c b*c a*b*c c*s(a*b)/ss3; test h = a b a*b e = s(a*b); test h = c a*c b*c a*b*c e =c*s(a*b); run; quit;
The GLM Procedure
Class Level Information
Class Levels Values
s 12 1 2 3 4 5 6 7 8 9 10 11 12
a 3 1 2 3
b 2 1 2
c 3 1 2 3
Number of observations 36
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 35 882.7500000 25.2214286 . .
Error 0 0.0000000 .
Corrected Total 35 882.7500000
R-Square Coeff Var Root MSE y Mean
1.000000 . . 13.75000
Source DF Type III SS Mean Square F Value Pr > F
a 2 176.1666667 88.0833333 . .
b 1 0.6944444 0.6944444 . .
a*b 2 309.7222222 154.8611111 . .
s(a*b) 6 153.5000000 25.5833333 . .
c 2 191.1666667 95.5833333 . .
a*c 4 7.6666667 1.9166667 . .
b*c 2 1.7222222 0.8611111 . .
a*b*c 4 11.1111111 2.7777778 . .
s*c(a*b) 12 31.0000000 2.5833333 . .
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 2 176.1666667 88.0833333 3.44 0.1009
b 1 0.6944444 0.6944444 0.03 0.8745
a*b 2 309.7222222 154.8611111 6.05 0.0364
Tests of Hypotheses Using the Type III MS for s*c(a*b) as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
c 2 191.1666667 95.5833333 37.00 <.0001
a*c 4 7.6666667 1.9166667 0.74 0.5815
b*c 2 1.7222222 0.8611111 0.33 0.7230
a*b*c 4 11.1111111 2.7777778 1.08 0.4111
proc glm data = table23_3w; class a b; model c1 c2 c3 = a|b; repeated c 3; run; quit;
[c-level output omitted]
Repeated Measures Analysis of Variance
Repeated Measures Level Information
Dependent Variable c1 c2 c3
Level of c 1 2 3
Manova Test Criteria and Exact F Statistics for the Hypothesis of no c Effect
H = Type III SSCP Matrix for c
E = Error SSCP Matrix
S=1 M=0 N=1.5
Statistic Value F Value Num DF Den DF Pr > F
Wilks' Lambda 0.05654871 41.71 2 5 0.0008
Pillai's Trace 0.94345129 41.71 2 5 0.0008
Hotelling-Lawley Trace 16.68386817 41.71 2 5 0.0008
Roy's Greatest Root 16.68386817 41.71 2 5 0.0008
Manova Test Criteria and F Approximations for the Hypothesis of no c*a Effect
H = Type III SSCP Matrix for c*a
E = Error SSCP Matrix
S=2 M=-0.5 N=1.5
Statistic Value F Value Num DF Den DF Pr > F
Wilks' Lambda 0.53462133 0.92 4 10 0.4899
Pillai's Trace 0.46568779 0.91 4 12 0.4886
Hotelling-Lawley Trace 0.86990460 1.07 4 5.1429 0.4578
Roy's Greatest Root 0.86923942 2.61 2 6 0.1531
NOTE: F Statistic for Roy's Greatest Root is an upper bound.
NOTE: F Statistic for Wilks' Lambda is exact.
Manova Test Criteria and Exact F Statistics for the Hypothesis of no c*b Effect
H = Type III SSCP Matrix for c*b
E = Error SSCP Matrix
S=1 M=0 N=1.5
Statistic Value F Value Num DF Den DF Pr > F
Wilks' Lambda 0.83885049 0.48 2 5 0.6445
Pillai's Trace 0.16114951 0.48 2 5 0.6445
Hotelling-Lawley Trace 0.19210755 0.48 2 5 0.6445
Roy's Greatest Root 0.19210755 0.48 2 5 0.6445
Manova Test Criteria and F Approximations for the Hypothesis of no c*a*b Effect
H = Type III SSCP Matrix for c*a*b
E = Error SSCP Matrix
S=2 M=-0.5 N=1.5
Statistic Value F Value Num DF Den DF Pr > F
Wilks' Lambda 0.44083349 1.27 4 10 0.3458
Pillai's Trace 0.55974001 1.17 4 12 0.3737
Hotelling-Lawley Trace 1.26712923 1.56 4 5.1429 0.3135
Roy's Greatest Root 1.26610170 3.80 2 6 0.0859
NOTE: F Statistic for Roy's Greatest Root is an upper bound.
NOTE: F Statistic for Wilks' Lambda is exact.
Tests of Hypotheses for Between Subjects Effects Source DF Type III SS Mean Square F Value Pr > F a 2 176.1666667 88.0833333 3.44 0.1009 b 1 0.6944444 0.6944444 0.03 0.8745 a*b 2 309.7222222 154.8611111 6.05 0.0364 Error 6 153.5000000 25.5833333
Univariate Tests of Hypotheses for Within Subject Effects
Adj Pr > F
Source DF Type III SS Mean Square F Value Pr > F G - G H - F
c 2 191.1666667 95.5833333 37.00 <.0001 <.0001 <.0001
c*a 4 7.6666667 1.9166667 0.74 0.5815 0.5636 0.5815
c*b 2 1.7222222 0.8611111 0.33 0.7230 0.6866 0.7230
c*a*b 4 11.1111111 2.7777778 1.08 0.4111 0.4090 0.4111
Error(c) 12 31.0000000 2.5833333
Greenhouse-Geisser Epsilon 0.8332
Huynh-Feldt Epsilon 2.076
proc mixed data = table23_3; class s a b c; model y = a|b|c; repeated/ subject = s type = cs; run; quit;
The Mixed Procedure
Model Information
Data Set WORK.TABLE23_3
Dependent Variable y
Covariance Structure Compound Symmetry
Subject Effect s
Estimation Method REML
Residual Variance Method Profile
Fixed Effects SE Method Model-Based
Degrees of Freedom Method Between-Within
Class Level Information
Class Levels Values
s 12 1 2 3 4 5 6 7 8 9 10 11 12
a 3 1 2 3
b 2 1 2
c 3 1 2 3
Dimensions
Covariance Parameters 2
Columns in X 48
Columns in Z 0
Subjects 12
Max Obs Per Subject 3
Observations Used 36
Observations Not Used 0
Total Observations 36
Iteration History
Iteration Evaluations -2 Res Log Like Criterion
0 1 105.44943515
1 1 94.39904969 0.00000000
Convergence criteria met.
Covariance Parameter Estimates
Cov Parm Subject Estimate
CS s 7.6667
Residual 2.5833
Fit Statistics
-2 Res Log Likelihood 94.4
AIC (smaller is better) 98.4
AICC (smaller is better) 99.2
BIC (smaller is better) 99.4
Null Model Likelihood Ratio Test
DF Chi-Square Pr > ChiSq
1 11.05 0.0009
Type 3 Tests of Fixed Effects
Num Den
Effect DF DF F Value Pr > F
a 2 6 3.44 0.1009
b 1 6 0.03 0.8745
a*b 2 6 6.05 0.0364
c 2 12 37.00 <.0001
a*c 4 12 0.74 0.5815
b*c 2 12 0.33 0.7230
a*b*c 4 12 1.08 0.4111
Data from table 23.4, page 517
data table23_4; input s a b c y @@; datalines; 1 1 1 1 1 1 1 2 1 1 1 1 3 1 2 1 1 1 2 1 1 1 2 2 3 1 1 3 2 2 1 1 1 3 2 1 1 2 3 4 1 1 3 3 2 2 1 1 1 2 2 1 2 1 3 2 1 3 1 3 2 1 1 2 2 2 1 2 2 4 2 1 3 2 4 2 1 1 3 3 2 1 2 3 5 2 1 3 3 4 3 1 1 1 1 3 1 2 1 2 3 1 3 1 3 3 1 1 2 3 3 1 2 2 3 3 1 3 2 5 3 1 1 3 2 3 1 2 3 5 3 1 3 3 5 4 2 1 1 2 4 2 2 1 1 4 2 3 1 1 4 2 1 2 2 4 2 2 2 2 4 2 3 2 2 4 2 1 3 3 4 2 2 3 3 4 2 3 3 2 5 2 1 1 3 5 2 2 1 2 5 2 3 1 3 5 2 1 2 3 5 2 2 2 4 5 2 3 2 3 5 2 1 3 5 5 2 2 3 5 5 2 3 3 4 6 2 1 1 1 6 2 2 1 2 6 2 3 1 1 6 2 1 2 2 6 2 2 2 3 6 2 3 2 3 6 2 1 3 1 6 2 2 3 3 6 2 3 3 2 ; run;
Table 23.4, page 517. Analysis of variance of a mixed three-way factorial design with one between-subject factor (A) and two within-subject factors (B and C)
proc glm data = table23_4; class s a b c; model y = a|b|c|s(a)/ss3; test h = a e = s(a); test h = b a*b e = b*s(a); test h = c a*c e = c*s(a); test h = b*c a*b*c e = b*c*s(a); run; quit;
The GLM Procedure
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 53 77.64814815 1.46505940 . .
Error 0 0.00000000 .
Corrected Total 53 77.64814815
R-Square Coeff Var Root MSE y Mean
1.000000 . . 2.685185
Source DF Type III SS Mean Square F Value Pr > F
a 1 1.50000000 1.50000000 . .
b 2 7.70370370 3.85185185 . .
a*b 2 5.77777778 2.88888889 . .
c 2 19.37037037 9.68518519 . .
a*c 2 0.11111111 0.05555556 . .
b*c 4 4.07407407 1.01851852 . .
a*b*c 4 0.44444444 0.11111111 . .
s(a) 4 24.37037037 6.09259259 . .
s*b(a) 8 5.62962963 0.70370370 . .
s*c(a) 8 4.29629630 0.53703704 . .
s*b*c(a) 16 4.37037037 0.27314815 . .
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 1 1.50000000 1.50000000 0.25 0.6458
Tests of Hypotheses Using the Type III MS for s*b(a) as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
b 2 7.70370370 3.85185185 5.47 0.0318
a*b 2 5.77777778 2.88888889 4.11 0.0593
Tests of Hypotheses Using the Type III MS for s*c(a) as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
c 2 19.37037037 9.68518519 18.03 0.0011
a*c 2 0.11111111 0.05555556 0.10 0.9029
Tests of Hypotheses Using the Type III MS for s*b*c(a) as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
b*c 4 4.07407407 1.01851852 3.73 0.0250
a*b*c 4 0.44444444 0.11111111 0.41 0.8011
Table 23.10, page 526. Analysis of the between-subjects simple interaction A*B at c=3.
NOTE: Evaluating the design at a specific level of a within-subject factor reduces the design to a two-factor between-subject design.
proc glm data = table23_3; where c =3; class a b ; model y = a|b /ss3; run; quit;
The GLM Procedure Class Level Information Class Levels Values a 3 1 2 3 b 2 1 2 Number of observations 12
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 5 263.0000000 52.6000000 8.77 0.0099
Error 6 36.0000000 6.0000000
Corrected Total 11 299.0000000
R-Square Coeff Var Root MSE y Mean
0.879599 21.29991 2.449490 11.50000
Source DF Type III SS Mean Square F Value Pr > F
a 2 98.0000000 49.0000000 8.17 0.0194
b 1 0.3333333 0.3333333 0.06 0.8215
a*b 2 164.6666667 82.3333333 13.72 0.0058
proc glm data = table23_3w; class a b; model c3 = a|b /ss3; run; quit;
The GLM Procedure
Class Level Information
Class Levels Values
a 3 1 2 3
b 2 1 2
Number of observations 12
Dependent Variable: c3
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 5 263.0000000 52.6000000 8.77 0.0099
Error 6 36.0000000 6.0000000
Corrected Total 11 299.0000000
R-Square Coeff Var Root MSE c3 Mean
0.879599 21.29991 2.449490 11.50000
Source DF Type III SS Mean Square F Value Pr > F
a 2 98.0000000 49.0000000 8.17 0.0194
b 1 0.3333333 0.3333333 0.06 0.8215
a*b 2 164.6666667 82.3333333 13.72 0.0058
proc mixed data = table23_3; where c = 3; class s a b ; model y = a|b; repeated/ subject = s type = cs; run; quit;
The Mixed Procedure
Model Information
Data Set WORK.TABLE23_3
Dependent Variable y
Covariance Structure Compound Symmetry
Subject Effect s
Estimation Method REML
Residual Variance Method Profile
Fixed Effects SE Method Model-Based
Degrees of Freedom Method Between-Within
Class Level Information
Class Levels Values
s 12 1 2 3 4 5 6 7 8 9 10 11 12
a 3 1 2 3
b 2 1 2
Dimensions
Covariance Parameters 2
Columns in X 12
Columns in Z 0
Subjects 12
Max Obs Per Subject 1
Observations Used 12
Observations Not Used 0
Total Observations 12
Iteration History
Iteration Evaluations -2 Res Log Like Criterion
0 1 31.93670230
1 1 31.93670230 0.00000000
Convergence criteria met but final hessian is not positive
definite.
Covariance Parameter Estimates
Cov Parm Subject Estimate
CS s 5.1429
Residual 0.8571
Fit Statistics
-2 Res Log Likelihood 31.9
AIC (smaller is better) 35.9
AICC (smaller is better) 39.9
BIC (smaller is better) 36.9
Null Model Likelihood Ratio Test
DF Chi-Square Pr > ChiSq
1 0.00 1.0000
Type 3 Tests of Fixed Effects
Num Den
Effect DF DF F Value Pr > F
a 2 6 8.17 0.0194
b 1 6 0.06 0.8215
a*b 2 6 13.72 0.0058
Table 23.12, page 528. Simple effects of factor B and C for female subjects from the data in Table 23.4 using only the restricted error terms.
NOTE: Restricting the design to one level of the between subject factor reduces the design to a two-factor within-subject design.
proc glm data = table23_4; where a = 1; class s b c; model y = b|c|s/ss3; test h = b e = b*s; test h = c e = c*s; test h = b*c e = s*b*c ; run;quit;
The GLM Procedure
Dependent Variable: y
Sum of
Source DF Squares Mean Square F Value Pr > F
Model 26 43.40740741 1.66951567 . .
Error 0 0.00000000 .
Corrected Total 26 43.40740741
R-Square Coeff Var Root MSE y Mean
1.000000 . . 2.851852
Source DF Type III SS Mean Square F Value Pr > F
b 2 12.51851852 6.25925926 . .
c 2 11.18518519 5.59259259 . .
b*c 4 3.03703704 0.75925926 . .
s 2 9.85185185 4.92592593 . .
s*b 4 3.03703704 0.75925926 . .
s*c 4 1.03703704 0.25925926 . .
s*b*c 8 2.74074074 0.34259259 . .
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 2 12.51851852 6.25925926 8.24 0.0381
Tests of Hypotheses Using the Type III MS for s*c as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
c 2 11.18518519 5.59259259 21.57 0.0072
Tests of Hypotheses Using the Type III MS for s*b*c as an Error Term
Source DF Type III SS Mean Square F Value Pr > F
b*c 4 3.03703704 0.75925926 2.22 0.1571
