# Chicken Weights by Feed Type ####
# An experiment was conducted to measure and compare the effectiveness
# of various feed supplements on the growth rate of chickens.
data("chickwts")
summary(chickwts)## weight feed
## Min. :108.0 casein :12
## 1st Qu.:204.5 horsebean:10
## Median :258.0 linseed :12
## Mean :261.3 meatmeal :11
## 3rd Qu.:323.5 soybean :14
## Max. :423.0 sunflower:12
plot(chickwts$weight~chickwts$feed)Figure 1: Chicken weights based on different foods eaten
I’d say that this data has homogeneity of variance because the spread of the area on the box plots are around the same. The Q-Q plot shows that the normality because the points lie on the best fit line, towards the ends of the data there seem to be some stragglers.
hist(chickwts$weight) #This shows that there is a normal distributionFigure 2: Chicken Weights plotted on a histogram
boxplot(chickwts$weight~chickwts$feed) #This shows equal varianceFigure 3: Chicken weights data plotted on a box plot for equal variance
qqnorm(chickwts$weight) #This also shows for normality
qqline(chickwts$weight)Figure 4: Chicken weights Q-Q plot to check for normality
I didn’t transform the data. As we see in figures 3-5 there these functions don’t normalize the data and the original function is more normal before the fact.
#The following codes are to check to see if we can transform the data to make it more normal.
chickwts$weightLog<-log10(chickwts$weight)
qqnorm(chickwts$weightLog)
qqline(chickwts$weightLog)Figure 5: Chicken weights Q-Q plot transformed using log base 10
chickwts$weightSqrt<-sqrt(chickwts$weight)
qqnorm(chickwts$weightSqrt)
qqline(chickwts$weightSqrt)Figure 6:Chicken weights Q-Q plot transformed using the square root function
chickwts$weightSqrd<-(chickwts$weight)^2
qqnorm(chickwts$weightSqrd)
qqline(chickwts$weightSqrd)figure 7: Chicken weights Q-Q plot transformed using the square function
The p-value was a really small number so we can reject the null hypothesis and say that there is a significant difference.
weight.aov<-aov(weight~feed, data=chickwts)
plot(weight.aov)Figure 8: ANOVA for chicken weight by feed.
Figure 8: ANOVA for chicken weight by feed.
Figure 8: ANOVA for chicken weight by feed.
Figure 8: ANOVA for chicken weight by feed.
summary(weight.aov)## Df Sum Sq Mean Sq F value Pr(>F)
## feed 5 231129 46226 15.37 5.94e-10 ***
## Residuals 65 195556 3009
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Since we rejected the null hypothesis in the previous question, we can run a multiple comparison test because there is a significant difference. The alternate hypothesis says there is a difference, but we can’t know where it is until we run this test and see that there is a significant difference between Horsebean and Casein, Linseed and Casein, Soybean and Casein, Meatmeal and Horsebean, Soybean and Horsebean, Sunflower and Horsebean, Sunflower and Linseed, Sunflower and Soybean.
TukeyHSD(weight.aov)## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = weight ~ feed, data = chickwts)
##
## $feed
## diff lwr upr p adj
## horsebean-casein -163.383333 -232.346876 -94.41979 0.0000000
## linseed-casein -104.833333 -170.587491 -39.07918 0.0002100
## meatmeal-casein -46.674242 -113.906207 20.55772 0.3324584
## soybean-casein -77.154762 -140.517054 -13.79247 0.0083653
## sunflower-casein 5.333333 -60.420825 71.08749 0.9998902
## linseed-horsebean 58.550000 -10.413543 127.51354 0.1413329
## meatmeal-horsebean 116.709091 46.335105 187.08308 0.0001062
## soybean-horsebean 86.228571 19.541684 152.91546 0.0042167
## sunflower-horsebean 168.716667 99.753124 237.68021 0.0000000
## meatmeal-linseed 58.159091 -9.072873 125.39106 0.1276965
## soybean-linseed 27.678571 -35.683721 91.04086 0.7932853
## sunflower-linseed 110.166667 44.412509 175.92082 0.0000884
## soybean-meatmeal -30.480519 -95.375109 34.41407 0.7391356
## sunflower-meatmeal 52.007576 -15.224388 119.23954 0.2206962
## sunflower-soybean 82.488095 19.125803 145.85039 0.0038845
There is a significant difference between the weights of the chickens and the feed type used (ANOVA p-value=0.0000). The data was not transformed and is the raw data obtained from the field. A Tukey HSD multiple comparison test was used to determine which of the feed was significantly different from the other. The weights of the chicken who ate Horsebean versus Casein(p=0.000) are significantly lower and Linseed versus Casein(p=0.000) are also significantly lower. However, chickens who ate Soybean versus Casein(p=0.008), Meatmeal versus Horsebean(p=0.000), Soybean versus Horsebean(p=0.004), Sunflower versus Horsebean(p=0.000), Sunflower versus Linseed(p=0.000), Sunflower versus Soybean(p=0.004) are significantly higher than it’s counterpart.
Please turn–in your homework via Sakai by saving and submitting an R Markdown PDF or HTML file from R Pubs!