Recipe 4: Completely Randomized Design

Corn Silk: A Completely Randomized Design

Max Winkelman

Rensselaer Polytechnic Institute

October 16 2014

Version 1

1. Setting

Corn silk

The data analyzed in this recipe is a csv file that contains various measurements of the phytochemical parameters of corn silk taken from Sarepoua et al[1].

Install the ‘Cornsilk.csv’ file

corn <- read.csv("~/RPI/Classes/Design of Experiments/R/Cornsilk.csv")
#reads in the csv file "Cornsilk.csv" form My Documents and stores it in the variable "corn"
corn$Type = as.factor(corn$Type)
#makes the column "Type" a factor
corn$Varieties = as.factor(corn$Varieties)
#makes the column "Varieties" a factor

Factors and Levels

Factor: Corn Type and Corn Variety

Levels: Type: Purple Waxy Corn, White Waxy Corn, and Super Sweet Corn and Variety P1-P5, W1-W3, and S1 and S2

#Summary of Data 
head(corn)
##               Type Varieties Silkingstage Milkystage Maturitystage  Mean
## 1 Purple waxy corn        P1        123.8      179.6         149.1 150.8
## 2 Purple waxy corn        P1        127.6      182.8         146.5 152.3
## 3 Purple waxy corn        P1        120.0      176.4         151.7 149.4
## 4 Purple waxy corn        P2        112.8      169.2         114.7 132.2
## 5 Purple waxy corn        P2        114.9      166.8         117.8 133.2
## 6 Purple waxy corn        P2        110.7      171.6         111.6 131.3
#displays the first 6 sets of variables 
tail(corn)
##                Type Varieties Silkingstage Milkystage Maturitystage Mean
## 25 Super sweet corn        S1         85.5       75.2          65.5 75.4
## 26 Super sweet corn        S1         83.1       78.4          63.5 75.0
## 27 Super sweet corn        S1         87.9       72.0          67.5 75.8
## 28 Super sweet corn        S2         93.4       78.3          69.4 80.4
## 29 Super sweet corn        S2         90.2       81.4          71.6 81.1
## 30 Super sweet corn        S2         96.6       75.2          67.2 79.7
#displays the last 6 sets of variables 
summary(corn)
##                Type      Varieties   Silkingstage     Milkystage   
##  Purple waxy corn:15   P1     : 3   Min.   : 83.1   Min.   : 54.4  
##  Super sweet corn: 6   P2     : 3   1st Qu.: 89.8   1st Qu.: 59.3  
##  White waxy corn : 9   P3     : 3   Median :105.9   Median :112.9  
##                        P4     : 3   Mean   :110.7   Mean   :121.3  
##                        P5     : 3   3rd Qu.:122.8   3rd Qu.:178.8  
##                        S1     : 3   Max.   :176.0   Max.   :212.3  
##                        (Other):12                                  
##  Maturitystage        Mean      
##  Min.   : 24.4   Min.   : 58.8  
##  1st Qu.: 48.0   1st Qu.: 64.8  
##  Median : 91.6   Median :106.2  
##  Mean   : 97.8   Mean   :109.9  
##  3rd Qu.:146.0   3rd Qu.:150.4  
##  Max.   :190.3   Max.   :192.9  
## 
#displays a summary of the variables

Continuous variables:

The continuous variables in this file are the total phenolic content (ug GAE/g dried sample) from corn in the Silking Stage (R1), the Milky Stage (R4), and the Maturity Stage (R6). The mean total phenolic content of all three of these variables is also a continuous variable. The categorical variables in this file are “Type of Corn”" and “Varieties.”

Response variables:

The total phenolic content from corn in the Silking Stage (R1), the Milky Stage (R4), and the Maturity Stage (R6) can all be considered response variables. For this specific recipe, the response variable will be the mean the total phenolic content.

The Data: How is it organized and what does it look like?

The csv file “Cornsilk.csv” contains modified data from Table 2 from Sarepoua et al and is oganized into columns that contain the five variables described above with slightly altered variable names that were changed for ease of coding[1]. The original table that was taken from Sarepoua et al contains the variables Type of Corn, Varieties, and Total phenolic content, which is organized into the three stages, R1, R4, and R6, and the mean value of the three stages. R1, R4, and R6 contain the mean values taken from three measurements made during the course of the experiment, as well as the standard deviation. The csv file used in this recipe contains the upper and lower standard deviation bounds in addition to the means.

Randomization

In the experiment conducted by Sarepoua et al, 10 corn varieties were evaluated using a completely randomized design that contained three replicates at the Vegetable Farm of Khon Kaen University in Khon Kaen, Thailand from May to July of 2012. The total phenolic, total flavonoids, total anthocyanin, and antioxidant activity were recorded by DPPH free-radical-scavenging assays [1].The total phenolic data was selected to be analyzed in this specific recipe.

2. Experimental Design

In this sample recipe, the effect of corn type and variety on the mean phenolic content will be investigated. An anova will be performed to determine if the variation of phenolic content in silk can be attributed to the type and the variety of corn. The two factors in this experiment will be the Type of Corn (Purple waxy corn, white waxy corn, and super sweet corn) and the variety of corn (P1-P5, W1-W3, and S1 and S2). The mean phenolic content will be the response variable that is used in the anova. It is hypothesized that the mean phenolic content of silk from corns from all types and varieties will be equal.

What is the rationale for this design?

An anova was selected to analyze the data from Cornsilk.csv because this recipe describes a two-factor, multilevel experiment. This test will be conducted with the assumption that the population from which the samples originated from are normally distributed and equality of variance amongst sample means.

Randomize: What is the Randomization Scheme?

The corn silk total phenolic content varieties were evaluated using a completely randomized design [1].

Replicate: Are there replicates and/or repeated measures?

There are both replicates and repeated measures in this experiment. Each measurement of total phenolic content was made three times and at each of the three stages of corn development.

Block: Did you use blocking in the design?

Yes, the 10 varieties of corn were grouped into 3 blocks based on corn type.

3. Statistical Analysis

Exploratory Data Analysis: Graphics and Descriptive Summary

#Boxplot
boxplot(Mean~Type,data=corn, xlab="Type of Corn", ylab="Total phenolic content (ug GAE/g dried sample)")
title("Effect of Corn Type on Phenolic Content")

plot of chunk unnamed-chunk-3

#boxplot of the horse power data from each model year

boxplot(Mean~Varieties,data=corn, xlab="Variety of Corn", ylab="Total phenolic content (ug GAE/g dried sample)", las=2)
title("Effect of Corn Variety on Phenolic Content")

plot of chunk unnamed-chunk-3

#boxplot of the horse power data from each model year

The two boxplots above display the distribution of total phenolic content that can be attributed to the corn type and the corn variety. No statistical inference can be made from these boxplots without performing a statistical test. By visual inspection, the median phenolic content of purple waxy corn is much higher that the medians of the other two types. Due to the lack of a large sample size when comparing the variety of corn, the medians of each corn variety appear to be relatively distinct from each other, except for W1, W2, and W3, which appear to have similar medians.

ANOVA Testing

An analysis of variance (ANOVA) will be used to determine the statistical significance between the total phenolic content means. The null hypothesis for all three ANOVA tests is that the mean phenolic content vectors of all samples are equal to each other. The first anova test will analyze the phenolic content variance as a result of the variation of corn type. The second anova test will analyze the phenolic content variance as a result of the variation of the corn variety. The third anova test will analyze the phenolic content variance as a result of the interaction between type and variety. If the null hypothesis is rejected, the alternative hypothesis, which states that the mean vectors are not equal to each other, is accepted. Afterwards, a Tukey’s Honestly Significant Difference test will be performed to due which means are significantly different.

# ANOVA
#Corn Type
model_type = aov(Mean~Type,data=corn) 
anova(model_type)
## Analysis of Variance Table
## 
## Response: Mean
##           Df Sum Sq Mean Sq F value  Pr(>F)    
## Type       2  53032   26516     109 1.2e-13 ***
## Residuals 27   6561     243                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#performs an anova test

#Corn Variety
model_variety = aov(Mean~Varieties,data=corn) 
anova(model_variety)
## Analysis of Variance Table
## 
## Response: Mean
##           Df Sum Sq Mean Sq F value Pr(>F)    
## Varieties  9  59546    6616    2850 <2e-16 ***
## Residuals 20     46       2                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#performs an anova test

#Corn Type and Variety
model_type_variety = aov(Mean~Type*Varieties,data=corn)
anova(model_type_variety)
## Analysis of Variance Table
## 
## Response: Mean
##           Df Sum Sq Mean Sq F value Pr(>F)    
## Type       2  53032   26516   11423 <2e-16 ***
## Varieties  7   6515     931     401 <2e-16 ***
## Residuals 20     46       2                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#performs an anova test

ANOVA Results: The anova test that analyzed the variation in phenolic content as a result of the variation in the corn type produced a p-value of 1.2e-13. This indicates that there is a very small probability that the variation of phenolic content can be solely attributed to randomization. It is highly likely that the corn type has an effect on the phenolic content mean. The anova test that analyzed the variation in phenolic content as a result of the variation in the variety of corn produced a p-value of less than 2e-16. This indicates that there is a very small probability that the variation of phenolic content can be solely attributed to randomization. It is highly likely that the variety of corn has an effect on the phenolic content mean. The anova test that analyzed the variation in phenolic content as a result of interaction of corn type and variety produced a p-value of less than 2e-16. This indicates that there is a small probability that the variation of phenolic content can be solely attributed to randomization. It is likely that the interaction of the type and variety of corn has an effect on the phenolic content mean. However, without a post-hoc analysis, it is impossible to determine precisely which means are significantly distinct from the others.

Post-Hoc Analysis

Tukey’s Honestly Significantly Difference is a multiple comparison procedure that is used after an ANOVA to determine which specific sample means are significantly different from the others. In this recipe, Tukey’s HSD is used to determine which corn type and variety produced significantly different phenolic content means.

#Tukey's HSD
#Corn Type
TukeyHSD(model_type, ordered = FALSE, conf.level = 0.95)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Mean ~ Type, data = corn)
## 
## $Type
##                                     diff     lwr     upr  p adj
## Super sweet corn-Purple waxy corn -73.69  -92.36 -55.023 0.0000
## White waxy corn-Purple waxy corn  -89.78 -106.08 -73.486 0.0000
## White waxy corn-Super sweet corn  -16.09  -36.46   4.282 0.1421
#performs a THSD test for the type of corn

#Corn Variety
TukeyHSD(model_variety, ordered = FALSE, conf.level = 0.95)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Mean ~ Varieties, data = corn)
## 
## $Varieties
##            diff       lwr       upr  p adj
## P2-P1  -18.6000  -23.0052  -14.1948 0.0000
## P3-P1    2.3667   -2.0385    6.7718 0.6678
## P4-P1  -18.2333  -22.6385  -13.8282 0.0000
## P5-P1   38.2667   33.8615   42.6718 0.0000
## S1-P1  -75.4333  -79.8385  -71.0282 0.0000
## S2-P1  -70.4333  -74.8385  -66.0282 0.0000
## W1-P1  -89.6333  -94.0385  -85.2282 0.0000
## W2-P1  -86.1667  -90.5718  -81.7615 0.0000
## W3-P1  -91.2667  -95.6718  -86.8615 0.0000
## P3-P2   20.9667   16.5615   25.3718 0.0000
## P4-P2    0.3667   -4.0385    4.7718 1.0000
## P5-P2   56.8667   52.4615   61.2718 0.0000
## S1-P2  -56.8333  -61.2385  -52.4282 0.0000
## S2-P2  -51.8333  -56.2385  -47.4282 0.0000
## W1-P2  -71.0333  -75.4385  -66.6282 0.0000
## W2-P2  -67.5667  -71.9718  -63.1615 0.0000
## W3-P2  -72.6667  -77.0718  -68.2615 0.0000
## P4-P3  -20.6000  -25.0052  -16.1948 0.0000
## P5-P3   35.9000   31.4948   40.3052 0.0000
## S1-P3  -77.8000  -82.2052  -73.3948 0.0000
## S2-P3  -72.8000  -77.2052  -68.3948 0.0000
## W1-P3  -92.0000  -96.4052  -87.5948 0.0000
## W2-P3  -88.5333  -92.9385  -84.1282 0.0000
## W3-P3  -93.6333  -98.0385  -89.2282 0.0000
## P5-P4   56.5000   52.0948   60.9052 0.0000
## S1-P4  -57.2000  -61.6052  -52.7948 0.0000
## S2-P4  -52.2000  -56.6052  -47.7948 0.0000
## W1-P4  -71.4000  -75.8052  -66.9948 0.0000
## W2-P4  -67.9333  -72.3385  -63.5282 0.0000
## W3-P4  -73.0333  -77.4385  -68.6282 0.0000
## S1-P5 -113.7000 -118.1052 -109.2948 0.0000
## S2-P5 -108.7000 -113.1052 -104.2948 0.0000
## W1-P5 -127.9000 -132.3052 -123.4948 0.0000
## W2-P5 -124.4333 -128.8385 -120.0282 0.0000
## W3-P5 -129.5333 -133.9385 -125.1282 0.0000
## S2-S1    5.0000    0.5948    9.4052 0.0184
## W1-S1  -14.2000  -18.6052   -9.7948 0.0000
## W2-S1  -10.7333  -15.1385   -6.3282 0.0000
## W3-S1  -15.8333  -20.2385  -11.4282 0.0000
## W1-S2  -19.2000  -23.6052  -14.7948 0.0000
## W2-S2  -15.7333  -20.1385  -11.3282 0.0000
## W3-S2  -20.8333  -25.2385  -16.4282 0.0000
## W2-W1    3.4667   -0.9385    7.8718 0.2061
## W3-W1   -1.6333   -6.0385    2.7718 0.9390
## W3-W2   -5.1000   -9.5052   -0.6948 0.0155
#performs a THSD test for the variety of corn

#Corn Type and Variety
TukeyHSD(model_type_variety, ordered = FALSE, conf.level = 0.95)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Mean ~ Type * Varieties, data = corn)
## 
## $Type
##                                     diff    lwr    upr p adj
## Super sweet corn-Purple waxy corn -73.69 -75.56 -71.83     0
## White waxy corn-Purple waxy corn  -89.78 -91.41 -88.16     0
## White waxy corn-Super sweet corn  -16.09 -18.12 -14.06     0
## 
## $Varieties
##           diff      lwr      upr  p adj
## P2-P1 -18.6000 -23.0052 -14.1948 0.0000
## P3-P1   2.3667  -2.0385   6.7718 0.6678
## P4-P1 -18.2333 -22.6385 -13.8282 0.0000
## P5-P1  38.2667  33.8615  42.6718 0.0000
## S1-P1  -1.7400  -6.1452   2.6652 0.9139
## S2-P1   3.2600  -1.1452   7.6652 0.2702
## W1-P1   0.1489  -4.2563   4.5541 1.0000
## W2-P1   3.6156  -0.7896   8.0207 0.1677
## W3-P1  -1.4844  -5.8896   2.9207 0.9651
## P3-P2  20.9667  16.5615  25.3718 0.0000
## P4-P2   0.3667  -4.0385   4.7718 1.0000
## P5-P2  56.8667  52.4615  61.2718 0.0000
## S1-P2  16.8600  12.4548  21.2652 0.0000
## S2-P2  21.8600  17.4548  26.2652 0.0000
## W1-P2  18.7489  14.3437  23.1541 0.0000
## W2-P2  22.2156  17.8104  26.6207 0.0000
## W3-P2  17.1156  12.7104  21.5207 0.0000
## P4-P3 -20.6000 -25.0052 -16.1948 0.0000
## P5-P3  35.9000  31.4948  40.3052 0.0000
## S1-P3  -4.1067  -8.5118   0.2985 0.0806
## S2-P3   0.8933  -3.5118   5.2985 0.9990
## W1-P3  -2.2178  -6.6229   2.1874 0.7380
## W2-P3   1.2489  -3.1563   5.6541 0.9885
## W3-P3  -3.8511  -8.2563   0.5541 0.1191
## P5-P4  56.5000  52.0948  60.9052 0.0000
## S1-P4  16.4933  12.0882  20.8985 0.0000
## S2-P4  21.4933  17.0882  25.8985 0.0000
## W1-P4  18.3822  13.9771  22.7874 0.0000
## W2-P4  21.8489  17.4437  26.2541 0.0000
## W3-P4  16.7489  12.3437  21.1541 0.0000
## S1-P5 -40.0067 -44.4118 -35.6015 0.0000
## S2-P5 -35.0067 -39.4118 -30.6015 0.0000
## W1-P5 -38.1178 -42.5229 -33.7126 0.0000
## W2-P5 -34.6511 -39.0563 -30.2459 0.0000
## W3-P5 -39.7511 -44.1563 -35.3459 0.0000
## S2-S1   5.0000   0.5948   9.4052 0.0184
## W1-S1   1.8889  -2.5163   6.2941 0.8696
## W2-S1   5.3556   0.9504   9.7607 0.0100
## W3-S1   0.2556  -4.1496   4.6607 1.0000
## W1-S2  -3.1111  -7.5163   1.2941 0.3244
## W2-S2   0.3556  -4.0496   4.7607 1.0000
## W3-S2  -4.7444  -9.1496  -0.3393 0.0285
## W2-W1   3.4667  -0.9385   7.8718 0.2061
## W3-W1  -1.6333  -6.0385   2.7718 0.9390
## W3-W2  -5.1000  -9.5052  -0.6948 0.0155
#performs a THSD test for the interaction of the type and variety of corn

Tukey’s HSD returns a matrix that contains statistical parameters for the interaction of an individual sample mean with every other sample mean being statistically analyzed. The comparisons between super sweet corn and purple waxy corn and white waxy corn and purple waxy corn both return confidence intervals that do not contain the value zero and have p adj values of 0.00. This indicates that there is difference between the sample means. However, the comparison between white waxy corn and super sweet corn produced a confidence interval that did contact zero and a p adj value of 0.1421. This indicates that there is no difference between the sample means and that the variation can be attributed to randomization. The same method of interperetation can be done for the Tukey’s HSD matrices returned from the corn variety and the type-variety interaction. These matrices are too large to individually describe each comparison. It should be noted that since the p adj values for the comparisons between W1, W2, and W3 were all above 0.05, indicating that the prediction made from the boxplot that the means were similar was correct.

Estimation of Parameters

Summary of all factors and levels

#Summary
pwc<-corn$Type=="Purple waxy corn" 
summary(corn[pwc,])
##                Type      Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:15   P1     :3   Min.   :111   Min.   :144  
##  Super sweet corn: 0   P2     :3   1st Qu.:115   1st Qu.:168  
##  White waxy corn : 0   P3     :3   Median :124   Median :180  
##                        P4     :3   Mean   :131   Mean   :178  
##                        P5     :3   3rd Qu.:129   3rd Qu.:186  
##                        S1     :0   Max.   :176   Max.   :212  
##                        (Other):0                              
##  Maturitystage      Mean    
##  Min.   :112   Min.   :131  
##  1st Qu.:133   1st Qu.:133  
##  Median :146   Median :151  
##  Mean   :147   Mean   :152  
##  3rd Qu.:151   3rd Qu.:154  
##  Max.   :190   Max.   :193  
## 
#displays a summary of the data of the type "Purple Waxy Corn"

wwc<-corn$Type=="White waxy corn" 
summary(corn[wwc,])
##                Type     Varieties  Silkingstage     Milkystage  
##  Purple waxy corn:0   W1     :3   Min.   : 84.1   Min.   :54.4  
##  Super sweet corn:0   W2     :3   1st Qu.: 87.1   1st Qu.:55.0  
##  White waxy corn :9   W3     :3   Median : 89.6   Median :56.8  
##                       P1     :0   Mean   : 91.8   Mean   :56.9  
##                       P2     :0   3rd Qu.: 98.5   3rd Qu.:58.8  
##                       P3     :0   Max.   :101.1   Max.   :59.6  
##                       (Other):0                                 
##  Maturitystage       Mean     
##  Min.   :24.4   Min.   :58.8  
##  1st Qu.:28.6   1st Qu.:59.6  
##  Median :36.1   Median :61.2  
##  Mean   :36.7   Mean   :61.8  
##  3rd Qu.:45.8   3rd Qu.:64.0  
##  Max.   :49.4   Max.   :65.3  
## 
#displays a summary of the data of the type "White Waxy Corn"

ssc<-corn$Type=="Super sweet corn" 
summary(corn[ssc,])
##                Type     Varieties  Silkingstage    Milkystage  
##  Purple waxy corn:0   S1     :3   Min.   :83.1   Min.   :72.0  
##  Super sweet corn:6   S2     :3   1st Qu.:86.1   1st Qu.:75.2  
##  White waxy corn :0   P1     :0   Median :89.0   Median :76.8  
##                       P2     :0   Mean   :89.5   Mean   :76.8  
##                       P3     :0   3rd Qu.:92.6   3rd Qu.:78.4  
##                       P4     :0   Max.   :96.6   Max.   :81.4  
##                       (Other):0                                
##  Maturitystage       Mean     
##  Min.   :63.5   Min.   :75.0  
##  1st Qu.:65.9   1st Qu.:75.5  
##  Median :67.3   Median :77.8  
##  Mean   :67.5   Mean   :77.9  
##  3rd Qu.:68.9   3rd Qu.:80.2  
##  Max.   :71.6   Max.   :81.1  
## 
#displays a summary of the data of the type "Super sweet Corn"

summary(corn[corn$Varieties=="P1",])
##                Type     Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:3   P1     :3   Min.   :120   Min.   :176  
##  Super sweet corn:0   P2     :0   1st Qu.:122   1st Qu.:178  
##  White waxy corn :0   P3     :0   Median :124   Median :180  
##                       P4     :0   Mean   :124   Mean   :180  
##                       P5     :0   3rd Qu.:126   3rd Qu.:181  
##                       S1     :0   Max.   :128   Max.   :183  
##                       (Other):0                              
##  Maturitystage      Mean    
##  Min.   :146   Min.   :149  
##  1st Qu.:148   1st Qu.:150  
##  Median :149   Median :151  
##  Mean   :149   Mean   :151  
##  3rd Qu.:150   3rd Qu.:152  
##  Max.   :152   Max.   :152  
## 
#displays a summary of the data of the variety P1

summary(corn[corn$Varieties=="P2",])
##                Type     Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:3   P2     :3   Min.   :111   Min.   :167  
##  Super sweet corn:0   P1     :0   1st Qu.:112   1st Qu.:168  
##  White waxy corn :0   P3     :0   Median :113   Median :169  
##                       P4     :0   Mean   :113   Mean   :169  
##                       P5     :0   3rd Qu.:114   3rd Qu.:170  
##                       S1     :0   Max.   :115   Max.   :172  
##                       (Other):0                              
##  Maturitystage      Mean    
##  Min.   :112   Min.   :131  
##  1st Qu.:113   1st Qu.:132  
##  Median :115   Median :132  
##  Mean   :115   Mean   :132  
##  3rd Qu.:116   3rd Qu.:133  
##  Max.   :118   Max.   :133  
## 
#displays a summary of the data of the variety P2

summary(corn[corn$Varieties=="P3",])
##                Type     Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:3   P3     :3   Min.   :124   Min.   :183  
##  Super sweet corn:0   P1     :0   1st Qu.:126   1st Qu.:184  
##  White waxy corn :0   P2     :0   Median :127   Median :185  
##                       P4     :0   Mean   :127   Mean   :185  
##                       P5     :0   3rd Qu.:128   3rd Qu.:186  
##                       S1     :0   Max.   :130   Max.   :187  
##                       (Other):0                              
##  Maturitystage      Mean    
##  Min.   :145   Min.   :153  
##  1st Qu.:146   1st Qu.:153  
##  Median :147   Median :153  
##  Mean   :147   Mean   :153  
##  3rd Qu.:149   3rd Qu.:154  
##  Max.   :150   Max.   :154  
## 
#displays a summary of the data of the variety P3

summary(corn[corn$Varieties=="P4",])
##                Type     Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:3   P4     :3   Min.   :113   Min.   :144  
##  Super sweet corn:0   P1     :0   1st Qu.:114   1st Qu.:146  
##  White waxy corn :0   P2     :0   Median :116   Median :148  
##                       P3     :0   Mean   :116   Mean   :148  
##                       P5     :0   3rd Qu.:117   3rd Qu.:149  
##                       S1     :0   Max.   :118   Max.   :151  
##                       (Other):0                              
##  Maturitystage      Mean    
##  Min.   :132   Min.   :132  
##  1st Qu.:133   1st Qu.:132  
##  Median :134   Median :133  
##  Mean   :134   Mean   :133  
##  3rd Qu.:136   3rd Qu.:133  
##  Max.   :137   Max.   :133  
## 
#displays a summary of the data of the variety P4

summary(corn[corn$Varieties=="P5",])
##                Type     Varieties  Silkingstage   Milkystage 
##  Purple waxy corn:3   P5     :3   Min.   :171   Min.   :201  
##  Super sweet corn:0   P1     :0   1st Qu.:172   1st Qu.:204  
##  White waxy corn :0   P2     :0   Median :173   Median :207  
##                       P3     :0   Mean   :173   Mean   :207  
##                       P4     :0   3rd Qu.:175   3rd Qu.:210  
##                       S1     :0   Max.   :176   Max.   :212  
##                       (Other):0                              
##  Maturitystage      Mean    
##  Min.   :184   Min.   :185  
##  1st Qu.:186   1st Qu.:187  
##  Median :187   Median :189  
##  Mean   :187   Mean   :189  
##  3rd Qu.:189   3rd Qu.:191  
##  Max.   :190   Max.   :193  
## 
#displays a summary of the data of the variety P5

summary(corn[corn$Varieties=="W1",])
##                Type     Varieties  Silkingstage     Milkystage  
##  Purple waxy corn:0   W1     :3   Min.   : 98.5   Min.   :55.0  
##  Super sweet corn:0   P1     :0   1st Qu.: 99.2   1st Qu.:56.1  
##  White waxy corn :3   P2     :0   Median : 99.8   Median :57.3  
##                       P3     :0   Mean   : 99.8   Mean   :57.3  
##                       P4     :0   3rd Qu.:100.5   3rd Qu.:58.5  
##                       P5     :0   Max.   :101.1   Max.   :59.6  
##                       (Other):0                                 
##  Maturitystage       Mean     
##  Min.   :24.4   Min.   :59.3  
##  1st Qu.:25.4   1st Qu.:60.2  
##  Median :26.5   Median :61.2  
##  Mean   :26.5   Mean   :61.2  
##  3rd Qu.:27.6   3rd Qu.:62.1  
##  Max.   :28.6   Max.   :63.1  
## 
#displays a summary of the data of the variety W1

summary(corn[corn$Varieties=="W2",])
##                Type     Varieties  Silkingstage    Milkystage  
##  Purple waxy corn:0   W2     :3   Min.   :87.1   Min.   :54.4  
##  Super sweet corn:0   P1     :0   1st Qu.:88.3   1st Qu.:55.6  
##  White waxy corn :3   P2     :0   Median :89.6   Median :56.8  
##                       P3     :0   Mean   :89.6   Mean   :56.8  
##                       P4     :0   3rd Qu.:90.8   3rd Qu.:58.0  
##                       P5     :0   Max.   :92.1   Max.   :59.2  
##                       (Other):0                                
##  Maturitystage       Mean     
##  Min.   :45.8   Min.   :64.0  
##  1st Qu.:46.7   1st Qu.:64.3  
##  Median :47.6   Median :64.7  
##  Mean   :47.6   Mean   :64.7  
##  3rd Qu.:48.5   3rd Qu.:65.0  
##  Max.   :49.4   Max.   :65.3  
## 
#displays a summary of the data of the variety W2

summary(corn[corn$Varieties=="W3",])
##                Type     Varieties  Silkingstage    Milkystage  
##  Purple waxy corn:0   W3     :3   Min.   :84.1   Min.   :54.6  
##  Super sweet corn:0   P1     :0   1st Qu.:85.0   1st Qu.:55.6  
##  White waxy corn :3   P2     :0   Median :85.9   Median :56.7  
##                       P3     :0   Mean   :85.9   Mean   :56.7  
##                       P4     :0   3rd Qu.:86.8   3rd Qu.:57.8  
##                       P5     :0   Max.   :87.7   Max.   :58.8  
##                       (Other):0                                
##  Maturitystage       Mean     
##  Min.   :34.2   Min.   :58.8  
##  1st Qu.:35.1   1st Qu.:59.2  
##  Median :36.1   Median :59.6  
##  Mean   :36.1   Mean   :59.6  
##  3rd Qu.:37.0   3rd Qu.:60.0  
##  Max.   :38.0   Max.   :60.3  
## 
#displays a summary of the data of the variety W3

summary(corn[corn$Varieties=="S1",])
##                Type     Varieties  Silkingstage    Milkystage  
##  Purple waxy corn:0   S1     :3   Min.   :83.1   Min.   :72.0  
##  Super sweet corn:3   P1     :0   1st Qu.:84.3   1st Qu.:73.6  
##  White waxy corn :0   P2     :0   Median :85.5   Median :75.2  
##                       P3     :0   Mean   :85.5   Mean   :75.2  
##                       P4     :0   3rd Qu.:86.7   3rd Qu.:76.8  
##                       P5     :0   Max.   :87.9   Max.   :78.4  
##                       (Other):0                                
##  Maturitystage       Mean     
##  Min.   :63.5   Min.   :75.0  
##  1st Qu.:64.5   1st Qu.:75.2  
##  Median :65.5   Median :75.4  
##  Mean   :65.5   Mean   :75.4  
##  3rd Qu.:66.5   3rd Qu.:75.6  
##  Max.   :67.5   Max.   :75.8  
## 
#displays a summary of the data of the variety S1

summary(corn[corn$Varieties=="S2",])
##                Type     Varieties  Silkingstage    Milkystage  
##  Purple waxy corn:0   S2     :3   Min.   :90.2   Min.   :75.2  
##  Super sweet corn:3   P1     :0   1st Qu.:91.8   1st Qu.:76.8  
##  White waxy corn :0   P2     :0   Median :93.4   Median :78.3  
##                       P3     :0   Mean   :93.4   Mean   :78.3  
##                       P4     :0   3rd Qu.:95.0   3rd Qu.:79.8  
##                       P5     :0   Max.   :96.6   Max.   :81.4  
##                       (Other):0                                
##  Maturitystage       Mean     
##  Min.   :67.2   Min.   :79.7  
##  1st Qu.:68.3   1st Qu.:80.0  
##  Median :69.4   Median :80.4  
##  Mean   :69.4   Mean   :80.4  
##  3rd Qu.:70.5   3rd Qu.:80.8  
##  Max.   :71.6   Max.   :81.1  
## 
#displays a summary of the data of the variety S2

Diagnostics/Model Adequacy Checking

Quantile-Quantile (Q-Q) plots are graphs used to verify the distributional assumption for a set of data. Based on the theoretical distribution, the expected value for each datum is determined. If the data values in a set follow the theoretical distribution, then they will appear as a straight line on a Q-Q plot. When an anova is performed, it is done so with the assumption that the test statistic follows a normal distribution. Visualization of a Q-Q plot will further confirm if that assumption is correct for the anova tests that were performed.

#Q-Q Plots
#Corn Type
qqnorm(residuals(model_type), main="Normal Q-Q Plot for Corn Type", ylab="Total phenolic content Residuals")
qqline(residuals(model_type))

plot of chunk unnamed-chunk-7

#produces a Q-Q normal plot for the corn type residuals with a normal fit line

#Corn Type
qqnorm(residuals(model_variety), main="Normal Q-Q Plot for Corn Variety", ylab="Total phenolic content Residuals")
qqline(residuals(model_variety))

plot of chunk unnamed-chunk-7

#produces a Q-Q normal plot for the corn variety residuals with a normal fit line

#Corn Type
qqnorm(residuals(model_type_variety), main="Normal Q-Q Plot for Interaction of Corn Type and Variety", ylab="Total phenolic content Residuals")
qqline(residuals(model_type_variety))

plot of chunk unnamed-chunk-7

#produces a Q-Q normal plot for the corn type-variety interaction residuals with a normal fit line

All three Normal Q-Q plots for the type and variety of corn have a linear relationship between the 25th and 75th percentile and two non-linear tails. Despite that fact that the tails do not follow a non-linear relationship, the distribution assumption that the samples follow a normal distribution can still be assumed since it is not unusual that tails deviate from the linear portion of the graph. The relatively linear relationship for all three data sets justifies the use of ANOVA to test for the significant difference.

Two Way Interaction Plots display the mean of the response for two-way combinations of factors, and can indicate if there is any interactions between them through visual inspection. Data sets that do not have any interaction will appear as perfectly parallel lines. Changes in slope and intersections are good indications of interactions.

interaction.plot(corn$Varieties,corn$Type,corn$Mean, xlab="Corn Variety", ylab="Means of Total Phenolic Content", main="Corn Interaction Plot", trace.label="Corn Type")

plot of chunk unnamed-chunk-8

#creates a plot that shows the interaction of corn type and variety on a corn's phenolic content

In the interaction plot above, there are clear observations of non-parallel lines, but no intersections. This still indicates that there are interactions between the type and variety of corn.

A Residuals vs. Fits Plot is a common graph used in residual analysis. It is a scatter plot of residuals as a function of fitted values, or the estimated responses. These plots are used to identify linearity, outliers, and error variances.

#Residual vs Fit 
#Corn Type
plot(fitted(model_type),residuals(model_type), main="Residual vs Fitted Plot for Corn Type") 

plot of chunk unnamed-chunk-9

#Corn Variety
plot(fitted(model_variety),residuals(model_variety), main="Residual vs Fitted Plot for Country of Origin")

plot of chunk unnamed-chunk-9

#Corn Interaction
plot(fitted(model_type_variety),residuals(model_type_variety), main="Residual vs Fitted Plot for Interaction") 

plot of chunk unnamed-chunk-9

The residual plot for corn type shows a large variation of residuals that are slightly more positively skewed. The residual plots for the corn variety and the type-variety interaction show the same small variation of residuals evenly distributed about zero. The lack of any extreme variation and noticeable outliers in all three graphs confirms the use of anova as a statistical test.

4. References to the Literature

[1] Sarepoua, Eakrin, Ratchada Tangwongchai, Bhalang Suriharn, and Kamol Lertrat. “Influence of Variety and Harvest Maturity on Phytochemical Content in Corn Silk.” Food Chemistry 169 (February 15, 2014): 424-29. doi:10.1016/j.foodchem.2014.07.136.

5. Appendices

The raw data used in this statistical analysis are referenced in the research article.