Stat 141 Nov 10 Analysis of Variance continued: randomized blocks, factorial designs > # do randomixed block alfalfa (SW p.487 "alfalfa and acid rain") > alf = read.table(file="D:\\stat141\\alfalfa.dat", header = T) > attach(alf) > interaction.plot(trt, block, height) # plot of cell means, here n=1 > tapply(height, list(trt,block), mean) #table cell means a b c d e control 2.47 2.15 1.46 2.36 1.0 high 1.10 1.05 0.50 1.00 1.5 low 1.58 1.15 1.27 1.25 1.0 > rndb = aov(height ~ trt + block) # two factor anova, no interaction > summary(rndb) #match Table 11.9 Df Sum Sq Mean Sq F value Pr(>F) trt 2 1.98601 0.99301 5.4709 0.03182 * block 4 0.83963 0.20991 1.1565 0.39740 Residuals 8 1.45205 0.18151 > TukeyHSD(rndb) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = height ~ trt + block) $trt diff lwr upr high-control -0.858 -1.627935 -0.088065 low-control -0.638 -1.407935 0.131935 low-high 0.220 -0.549935 0.989935 -------------------------------------------------------------------------------------- factorial designs soybean data. (plus co2 toads, summary in text) > soy = read.table(file="D:\\stat141\\soybean.dat", header = T) > attach(soy); tapply(area, list(shaking,light), mean) # Table 11.11 p.492 low moderate control 245.3077 304.0769 stress 212.9231 268.8462 > tapply(area, list(shaking,light), sd) low moderate control 27.02278 26.92416 stress 29.74744 35.23220 > tapply(area, list(shaking,light), length) low moderate control 13 13 stress 13 13 > interaction.plot(shaking, light, area) # Fig 11.4 p.493 > soyaov = aov(area ~ shaking*light) > summary(soyaov) # Df Sum Sq Mean Sq F value Pr(>F) shaking 1 14858 14858 16.5954 0.0001725 *** light 1 42752 42752 47.7490 1.010e-08 *** shaking:light 1 26 26 0.0294 0.8645695 Residuals 48 42976 895 --- > TukeyHSD(soyaov) [single contrast, row and column]