This example comes from Devore and Peck's Statistics: The Exploration and Analysis of Data (3rd ed, Duxbury, 1997, pages 545--552. The data are in tomato.df. An experiment was carried out to assess the effects of tomato variety (factor A with 3 levels) and planting density (factor B with 4 levels: 10, 20, 30, and 40 thousand plants per hectare) on yield. (Adapted by Devore and Peck from an article "Effects of Plant Density on Tomato Yields in Western Nigeria", from Experimental Agriculture, 1976.)
Print the data:
tomato.df
Then let's work with it:
attach(tomato.df)
round(tapply(Yield,list(Variety, Density),mean),2)
round(tapply(Yield,list(Variety, Density),sd),2)
par(mfrow=c(2,1))
boxplot(split(Yield,Variety))
boxplot(split(Yield,Density))
Summarize what you see in these boxplots and tables of summary statistics.
Now, we will compute a so-called "Two-way Analysis of Variance":
tomato.aov <- aov(Yield ~ Variety*Density)
summary(tomato.aov)
interaction.plot(Density, Variety, Yield, fun=mean)
We will discuss the ANOVA as a class.
Example 2: Pancake experiment
(From the Minitab Student Handbook, by Ryan, Joiner and Ryan) An experiment was designed to study the effect of two factors on the quality of pancakes. The two factors were the amount of whey in the recipe and whether or not a nutrional supplement was added. There were 4 levels of whey---0%, 10%, 20%, and 30%---and two levels of supplement---`used' or `not used'. Thus there were 4 x 2 = 8 treatment combinations. Three pancakes were baked using each treatment combination. Each pancake then was rated by an expert and the three ratings averaged to give an overall quality rating for that combination. This was done 3 different times for each treatment combination giving a total of 3 x 8 = 24 pancake ratings. The data can be found in pancake.df.
Do the following:
attach(pancake.df)
round(tapply(Quality,list(Supplement,Whey),mean),2)
round(tapply(Quality,list(Supplement,Whey),sd),2)
par(mfrow=c(1,2))
boxplot(Quality ~ Whey)
boxplot(Quality ~ Supplement)
summary(aov(Quality ~ Supplement*Whey))
interaction.plot(Whey, Supplement, Quality, fun=mean)
#### Results ####
0% 10% 20% 30%
NoSupp 4.4 4.63 4.70 4.80
Supp 3.2 3.70 5.03 5.43
0% 10% 20% 30%
NoSupp 0.1 0.15 0.17 0.26
Supp 0.1 0.10 0.25 0.15
Df Sum Sq Mean Sq F value Pr(>F)
Supplement 1 0.5104 0.5104 17.014 0.0007942 ***
Whey 3 6.6912 2.2304 74.347 1.304e-09 ***
Supplement:Whey 3 3.7246 1.2415 41.384 9.130e-08 ***
Residuals 16 0.4800 0.0300
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Summary of analysis: Quality of pancake increases with whey content and is slightly better (and a whole lot less variable) with the supplement vs the no-supplement. Both effects for Whey (p=1.304e-09) and Supplement (p=0.0007942) are statistically significant. But there is also here a statistically significant interaction between Whey and Supplement (p=9.130e-08). It is probably best to interpret that interaction as the main conclusion of the experiment.
Here is that conclusion: Quality increases with level of whey in the recipe. This "whey effect" is much stronger when the supplement is present than when the supplement is absent.
The data sets follow:
Variety Density Yield 1 1 1 7.9 2 1 1 9.2 3 1 1 10.5 4 1 2 11.2 5 1 2 12.8 6 1 2 13.3 7 1 3 12.1 8 1 3 12.6 9 1 3 14.0 10 1 4 9.1 11 1 4 10.8 12 1 4 12.5 13 2 1 8.1 14 2 1 8.6 15 2 1 10.1 16 2 2 11.5 17 2 2 12.7 18 2 2 13.7 19 2 3 13.7 20 2 3 14.4 21 2 3 15.4 22 2 4 11.3 23 2 4 12.5 24 2 4 14.5 25 3 1 15.3 26 3 1 16.1 27 3 1 17.5 28 3 2 16.6 29 3 2 18.5 30 3 2 19.2 31 3 3 18.0 32 3 3 20.8 33 3 3 21.0 34 3 4 17.2 35 3 4 18.4 36 3 4 18.9 Supplement Whey Quality 1 NoSupp 0% 4.4 2 NoSupp 0% 4.5 3 NoSupp 0% 4.3 4 NoSupp 10% 4.6 5 NoSupp 10% 4.5 6 NoSupp 10% 4.8 7 NoSupp 20% 4.5 8 NoSupp 20% 4.8 9 NoSupp 20% 4.8 10 NoSupp 30% 4.6 11 NoSupp 30% 4.7 12 NoSupp 30% 5.1 13 Supp 0% 3.3 14 Supp 0% 3.2 15 Supp 0% 3.1 16 Supp 10% 3.8 17 Supp 10% 3.7 18 Supp 10% 3.6 19 Supp 20% 5.0 20 Supp 20% 5.3 21 Supp 20% 4.8 22 Supp 30% 5.4 23 Supp 30% 5.6 24 Supp 30% 5.3