* ch25sec6.sas, analysis of 3-factor mixed or random effects models; * (Modeling of random effects corrected 8Feb07); options ls=80 nodate; ; data random; array AA{3}; array BB{5}; array CC{6}; array BC{5,6}; * generate pseudo-random effects; do i=1 to 3; AA(i)=rannor(555); end; do j=1 to 5; BB(j)=2*rannor(555); end; do k=1 to 6; CC(k)=3*rannor(555); end; do j=1 to 5; do k=1 to 6; BC(j,k)=rannor(555); end; end; * generate observations with pseudo-random error terms; do A=1 to 3; i=A; do B=1 to 5; j=B; do C=1 to 6; k=C; do rep=1 to 2; eps_ijkm=rannor(555); * effects of C random; yC = 20 + A + B + CC(k) + eps_ijkm; * effects of B and C random; yBC = 20 + A + BB(j) + CC(k) + BC(j,k) + eps_ijkm; * effects of A, B and C random; yABC = 20 + AA(i) + BB(j) + CC(k) + BC(j,k) + eps_ijkm; output; end; end; end; end; ; proc glm; class A B C; model yC = A | B | C; random C A*C B*C A*B*C / test; title 'Section 27.6: Effects of A and B fixed, effects of C random'; ; proc glm; Class A B C; model yBC = A | B | C; random B C B*C A*B A*C A*B*C / test; title 'Section 27.6: Effects of A fixed, effects of B and C random'; ; proc glm; Class A B C; model yABC = A | B | C; random A | B | C / test; title 'Section 27.6: Effects of A, B and C random'; Section 27.6: Effects of A and B fixed, effects of C random 1 The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 B 5 1 2 3 4 5 C 6 1 2 3 4 5 6 Number of Observations Read 180 Number of Observations Used 180 Section 27.6: Effects of A and B fixed, effects of C random 2 The GLM Procedure Dependent Variable: yC Sum of Source DF Squares Mean Square F Value Pr > F Model 89 2670.991107 30.011136 36.73 <.0001 Error 90 73.533128 0.817035 Corrected Total 179 2744.524235 R-Square Coeff Var Root MSE yC Mean 0.973207 3.459950 0.903900 26.12464 Source DF Type I SS Mean Square F Value Pr > F A 2 138.918920 69.459460 85.01 <.0001 B 4 362.499371 90.624843 110.92 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2102.252052 420.450410 514.61 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 19.056343 0.952817 1.17 0.3020 A*B*C 40 27.633982 0.690850 0.85 0.7191 Source DF Type III SS Mean Square F Value Pr > F A 2 138.918920 69.459460 85.01 <.0001 B 4 362.499371 90.624843 110.92 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2102.252052 420.450410 514.61 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 19.056343 0.952817 1.17 0.3020 A*B*C 40 27.633982 0.690850 0.85 0.7191 Section 27.6: Effects of A and B fixed, effects of C random 3 The GLM Procedure Source Type III Expected Mean Square A Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) + Q(A,A*B) B Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + Q(B,A*B) A*B Var(Error) + 2 Var(A*B*C) + Q(A*B) C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + 10 Var(A*C) + 30 Var(C) A*C Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) B*C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) A*B*C Var(Error) + 2 Var(A*B*C) Section 27.6: Effects of A and B fixed, effects of C random 4 The GLM Procedure Tests of Hypotheses for Mixed Model Analysis of Variance Dependent Variable: yC Source DF Type III SS Mean Square F Value Pr > F * A 2 138.918920 69.459460 46.68 <.0001 Error: MS(A*C) 10 14.881053 1.488105 * This test assumes one or more other fixed effects are zero. Source DF Type III SS Mean Square F Value Pr > F * B 4 362.499371 90.624843 95.11 <.0001 Error: MS(B*C) 20 19.056343 0.952817 * This test assumes one or more other fixed effects are zero. Source DF Type III SS Mean Square F Value Pr > F A*B 8 5.749385 0.718673 1.04 0.4230 A*C 10 14.881053 1.488105 2.15 0.0421 B*C 20 19.056343 0.952817 1.38 0.1896 Error: MS(A*B*C) 40 27.633982 0.690850 Source DF Type III SS Mean Square F Value Pr > F C 5 2102.252052 420.450410 240.25 <.0001 Error 10.987 19.227440 1.750073 Error: MS(A*C) + MS(B*C) - MS(A*B*C) + 49E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F A*B*C 40 27.633982 0.690850 0.85 0.7191 Error: MS(Error) 90 73.533128 0.817035 Section 27.6: Effects of A fixed, effects of B and C random 5 The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 B 5 1 2 3 4 5 C 6 1 2 3 4 5 6 Number of Observations Read 180 Number of Observations Used 180 Section 27.6: Effects of A fixed, effects of B and C random 6 The GLM Procedure Dependent Variable: yBC Sum of Source DF Squares Mean Square F Value Pr > F Model 89 3054.552022 34.320809 42.01 <.0001 Error 90 73.533128 0.817035 Corrected Total 179 3128.085150 R-Square Coeff Var Root MSE yBC Mean 0.976493 3.670374 0.903900 24.62691 Source DF Type I SS Mean Square F Value Pr > F A 2 138.918920 69.459460 85.01 <.0001 B 4 544.742063 136.185516 166.68 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2205.324532 441.064906 539.84 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 117.302087 5.865104 7.18 <.0001 A*B*C 40 27.633982 0.690850 0.85 0.7191 Source DF Type III SS Mean Square F Value Pr > F A 2 138.918920 69.459460 85.01 <.0001 B 4 544.742063 136.185516 166.68 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2205.324532 441.064906 539.84 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 117.302087 5.865104 7.18 <.0001 A*B*C 40 27.633982 0.690850 0.85 0.7191 Section 27.6: Effects of A fixed, effects of B and C random 7 The GLM Procedure Source Type III Expected Mean Square A Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) + 12 Var(A*B) + Q(A) B Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + 12 Var(A*B) + 36 Var(B) A*B Var(Error) + 2 Var(A*B*C) + 12 Var(A*B) C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + 10 Var(A*C) + 30 Var(C) A*C Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) B*C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) A*B*C Var(Error) + 2 Var(A*B*C) Section 27.6: Effects of A fixed, effects of B and C random 8 The GLM Procedure Tests of Hypotheses for Mixed Model Analysis of Variance Dependent Variable: yBC Source DF Type III SS Mean Square F Value Pr > F A 2 138.918920 69.459460 45.82 <.0001 Error 7.7131 11.692550 1.515929 Error: MS(A*B) + MS(A*C) - MS(A*B*C) + 18E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F B 4 544.742063 136.185516 23.11 <.0001 Error 19.331 113.913311 5.892928 Error: MS(A*B) + MS(B*C) - MS(A*B*C) - 16E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F A*B 8 5.749385 0.718673 1.04 0.4230 A*C 10 14.881053 1.488105 2.15 0.0421 B*C 20 117.302087 5.865104 8.49 <.0001 Error: MS(A*B*C) 40 27.633982 0.690850 Source DF Type III SS Mean Square F Value Pr > F C 5 2205.324532 441.064906 66.20 <.0001 Error 22.724 151.392458 6.662360 Error: MS(A*C) + MS(B*C) - MS(A*B*C) + 49E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F A*B*C 40 27.633982 0.690850 0.85 0.7191 Error: MS(Error) 90 73.533128 0.817035 Section 27.6: Effects of A, B and C random 9 The GLM Procedure Class Level Information Class Levels Values A 3 1 2 3 B 5 1 2 3 4 5 C 6 1 2 3 4 5 6 Number of Observations Read 180 Number of Observations Used 180 Section 27.6: Effects of A, B and C random 10 The GLM Procedure Dependent Variable: yABC Sum of Source DF Squares Mean Square F Value Pr > F Model 89 3042.584837 34.186346 41.84 <.0001 Error 90 73.533128 0.817035 Corrected Total 179 3116.117965 R-Square Coeff Var Root MSE yABC Mean 0.976402 3.946281 0.903900 22.90510 Source DF Type I SS Mean Square F Value Pr > F A 2 126.951735 63.475868 77.69 <.0001 B 4 544.742063 136.185516 166.68 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2205.324532 441.064906 539.84 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 117.302087 5.865104 7.18 <.0001 A*B*C 40 27.633982 0.690850 0.85 0.7191 Source DF Type III SS Mean Square F Value Pr > F A 2 126.951735 63.475868 77.69 <.0001 B 4 544.742063 136.185516 166.68 <.0001 A*B 8 5.749385 0.718673 0.88 0.5369 C 5 2205.324532 441.064906 539.84 <.0001 A*C 10 14.881053 1.488105 1.82 0.0679 B*C 20 117.302087 5.865104 7.18 <.0001 A*B*C 40 27.633982 0.690850 0.85 0.7191 Section 27.6: Effects of A, B and C random 11 The GLM Procedure Source Type III Expected Mean Square A Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) + 12 Var(A*B) + 60 Var(A) B Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + 12 Var(A*B) + 36 Var(B) A*B Var(Error) + 2 Var(A*B*C) + 12 Var(A*B) C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) + 10 Var(A*C) + 30 Var(C) A*C Var(Error) + 2 Var(A*B*C) + 10 Var(A*C) B*C Var(Error) + 2 Var(A*B*C) + 6 Var(B*C) A*B*C Var(Error) + 2 Var(A*B*C) Section 27.6: Effects of A, B and C random 12 The GLM Procedure Tests of Hypotheses for Random Model Analysis of Variance Dependent Variable: yABC Source DF Type III SS Mean Square F Value Pr > F A 2 126.951735 63.475868 41.87 <.0001 Error 7.7131 11.692550 1.515929 Error: MS(A*B) + MS(A*C) - MS(A*B*C) + 18E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F B 4 544.742063 136.185516 23.11 <.0001 Error 19.331 113.913311 5.892928 Error: MS(A*B) + MS(B*C) - MS(A*B*C) - 16E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F A*B 8 5.749385 0.718673 1.04 0.4230 A*C 10 14.881053 1.488105 2.15 0.0421 B*C 20 117.302087 5.865104 8.49 <.0001 Error: MS(A*B*C) 40 27.633982 0.690850 Source DF Type III SS Mean Square F Value Pr > F C 5 2205.324532 441.064906 66.20 <.0001 Error 22.724 151.392458 6.662360 Error: MS(A*C) + MS(B*C) - MS(A*B*C) + 49E-16*MS(Error) Source DF Type III SS Mean Square F Value Pr > F A*B*C 40 27.633982 0.690850 0.85 0.7191 Error: MS(Error) 90 73.533128 0.817035