58 2. 2 factorials in 2 blocks Suppose we needed four batches of formaldehyde, and coulddoonly4runsperbatch. Thisisthena2 4 factorial in 2 2 blocks. Some more algebra: If two effects are confounded with blocks, then so is their product, which is defined by multiplication mod 2 : 0 = 2 = = E.g. = 2 =. Pick two effects to be confounded with blocks: and. Then also = is confounded. We wouldn t pick and, since =.
59 For the choices and we have = + 2 + 3 +0 4 = + 2 + 3 2 = + 2 + 3 + 4 = + 3 + 4 with () a b ab c ac bc abc 0 0 0 0 2 0 0 0 0 Block I IV II III IV I III II d ad bd abd cd acd bcd abcd 0 0 0 0 2 0 0 0 0 Block III II IV I II III I IV Block I : () Block II : Block III : Block IV :
A B C D blocks ABC ACD BD y - - - - - - 25 2 - - - 4 7 3 - - - 2 - - 48 4 - - 3 - - 45 5 - - - 4 68 6 - - - - 40 7 - - 3 - - 60 8-2 - - 65 9 - - - 3 - - 43 0 - - 2 - - 80 - - 4 25 2 - - - 4 3 - - 2 - - 55 4-3 - - 86 5 - - - 20 6 4 76 60
6 > g <- lm(y ~blocks + A + B + C + D + A*B + A*C + A*D + B*C + C*D + A*B*D + B*C*D + A*B*C*D) > anova(g) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(>F) blocks 3 3787.7 262.6 A 05.6 05.6 B 826.6 826.6 C 885. 885. D 33. 33. A:B 95. 95. A:C.6.6 A:D 540.6 540.6 B:C 27.6 27.6 C:D 60. 60. A:B:D 3. 3. B:C:D 22.6 22.6 A:B:C:D 5. 5. Residuals 0 0.0
62 Normal Q Q Plot Sample Quantiles 0 0 20 30 40 50 A:C A:B C:D D B:C:D A:B:D A:B:C:D B blocks3 blocks2 A:D B:C C A blocks4 0 Theoretical Quantiles Fig. 7.2. Half normal plot for 2 4 factorial in 2 2 blocks. Itlookslikewecandropthemaineffect of D if we keep some of its interactions.
63 R will, by default, estimate a main effect if an interaction is in the model. To fit blocks, A, B, C, AB, AD, BC, CD but not D, we can add the SS and df for D to those for Error. > h <- lm(y ~blocks + A + B + C + B*C + A*B + A*D + C*D) > anova(h) Df Sum Sq Mean Sq F value Pr(>F) blocks 3 3787.7 262.6 56.5969 0.000333 *** A 05.6 05.6 37.240 0.0003042 *** B 826.6 826.6 02.594 0.0005356 *** C 885. 885. 09.7752 0.0004690 *** D 33. 33. 4.008 0.28484 B:C 27.6 27.6 26.9845 0.006540 ** A:B 95. 95..7907 0.0264444 * A:D 540.6 540.6 67.0465 0.0027 ** C:D 60. 60. 7.4496 0.0524755. Residuals 4 32.3 8. This would change to (32 3+33 ) 5 =3 08 on 5 d.f. - not a helpful step (since was larger than ).
64 mean of y 40 45 50 55 60 65 70 B mean of y 35 40 45 50 55 60 65 D A A mean of y 35 40 45 50 55 60 C mean of y 40 45 50 55 60 D B C Fig. 7.3. Interaction plots. The best combination seemstobea,c,dhigh,blow.
65 22. Partial confounding To get an estimate of error, we have to either drop certain effects from the model, or replicate the design. If we replicate, we can either: Confoundthesameeffects with blocks in each replication - complete confounding, or Confound different effects with each replication - partial confounding. Partial confounding is often better, since we then get estimates of effects from the replications in which they are not confounded.
66 Example 7-3 from text. Two replicates of a 2 3 factorial are to be run, in 2 block each. Replicate : Confound ABC with blocks. So = + 2 + 3 =0for() and =for Replicate 2: Confound AB with blocks. So = + 2 =0for() and = for Rep Rep2 Block Block 2 Block 3 Block 4 () = 550 = 669 () = 604 =650 =642 = 633 = 052 = 60 =749 = 037 =635 =868 = 075 =729 =860 =063
67 A B C Rep Block ABC AB y - - - I - 550 2 - I - 642 3 - I - - 749 4 - I - - 075 5 - - I 2-669 6 - - I 2-633 7 - - I 2 037 8 I 2 729 9 - - - II 3-604 0 - - II 3 052 - II 3-635 2 II 3 860 3 - - II 4-650 4 - - II 4-60 5 - II 4 - - 868 6 - II 4 - - 063 When the levels of one factor (Blocks) make sense only within the levels of another factor (Replicates) we say that the first is nested within the second. A waytoindicatethisinrisas:
> h <- lm(y ~Rep + Block%in%Rep + A + B + C + A*B + A*C + B*C + A*B*C) > anova(h) Analysis of Variance Table 68 Response: y Df Sum Sq Mean Sq F value Pr(>F) Rep 3875 3875.59 0.27255 A 43 43 6.94 0.00079 * B 28 28 0.0853 0.78987 C 374850 374850 46.9446 6.75e-05 *** Rep:Block 2 458 229 0.0898 0.95560 A:B 3528 3528.3830 0.292529 A:C 94403 94403 37.0066 0.00736 ** B:C 8 8 0.007 0.936205 A:B:C 6 6 0.0024 0.96286 Residuals 5 2755 255 Through the partial confounding we are able to estimate all interactions. It looks like only A, C, and AC are significant.
69 resids 40 0 40 resids 40 0 40.0.2.4.6.8 2.0 c(a).0.2.4.6.8 2.0 c(c) resids 40 0 40 resids 40 0 40.0.2.4.6.8 2.0 c(b).0.5 2.0 2.5 3.0 3.5 4.0 c(block) Normal Q Q Plot resids 40 0 40 Sample Quantiles 40 0 40 600 700 800 900 000 00 fits 2 0 2 Theoretical Quantiles Fig. 7.4. Residuals for fit to A, C, and AC only.
70 mean of y 650 700 750 800 850 900 II I 4 3 2 A B C Block mean of y 600 700 800 900 000 A Factors C Fig. 7.5. Design and interactions. How is ( ) computed? One way is to compute in Rep I, where this effect is confounded with blocks, and similarly in
7 RepII,andaddthem: " # 2 (550 + + 075) +(669+ +729) = 8 = 338 = =20 25 ( ) = 338 + 20 25 = 458 25 in agreement with the ANOVA output. See the programme on the course web site to see how to do this calculation very easily. Another method goes back to general principles. We calculate a SS for blocks within each replicate (since blocks make sense only within the replicates): ( ) =4 X X ³ 2 =458 25 = 2 = 2 Here is the average in block of replicate, and is the overall average of that replicate, which is the only one in which that block makes sense. See the R calculation.