# 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
data("chickwts") #chicken Weights by Feed Type
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
chickwts## weight feed
## 1 179 horsebean
## 2 160 horsebean
## 3 136 horsebean
## 4 227 horsebean
## 5 217 horsebean
## 6 168 horsebean
## 7 108 horsebean
## 8 124 horsebean
## 9 143 horsebean
## 10 140 horsebean
## 11 309 linseed
## 12 229 linseed
## 13 181 linseed
## 14 141 linseed
## 15 260 linseed
## 16 203 linseed
## 17 148 linseed
## 18 169 linseed
## 19 213 linseed
## 20 257 linseed
## 21 244 linseed
## 22 271 linseed
## 23 243 soybean
## 24 230 soybean
## 25 248 soybean
## 26 327 soybean
## 27 329 soybean
## 28 250 soybean
## 29 193 soybean
## 30 271 soybean
## 31 316 soybean
## 32 267 soybean
## 33 199 soybean
## 34 171 soybean
## 35 158 soybean
## 36 248 soybean
## 37 423 sunflower
## 38 340 sunflower
## 39 392 sunflower
## 40 339 sunflower
## 41 341 sunflower
## 42 226 sunflower
## 43 320 sunflower
## 44 295 sunflower
## 45 334 sunflower
## 46 322 sunflower
## 47 297 sunflower
## 48 318 sunflower
## 49 325 meatmeal
## 50 257 meatmeal
## 51 303 meatmeal
## 52 315 meatmeal
## 53 380 meatmeal
## 54 153 meatmeal
## 55 263 meatmeal
## 56 242 meatmeal
## 57 206 meatmeal
## 58 344 meatmeal
## 59 258 meatmeal
## 60 368 casein
## 61 390 casein
## 62 379 casein
## 63 260 casein
## 64 404 casein
## 65 318 casein
## 66 352 casein
## 67 359 casein
## 68 216 casein
## 69 222 casein
## 70 283 casein
## 71 332 casein
plot(chickwts$weight ~ chickwts$feed)hist (chickwts$weight) #Histogram shows an structure like poisson distribution, so data is not normal.qqnorm(chickwts$weight)
qqline(chickwts$weight)# In the Q-Q plots the data does not fall along the 1:1 line. so data is not normalboxplot(chickwts$weight ~ chickwts$feed) #the spread of the box plots are not equal, so data is not normal #I run the three transformations
logNormalSQRT <- sqrt(chickwts$weight) #Square Root Transformation
qqnorm (logNormalSQRT)
qqline (logNormalSQRT)logNolmalX2<- (chickwts$weight) ^2 #squared transformation
qqnorm (logNolmalX2)
qqline (logNolmalX2)lognormalLog <- log10 (chickwts$weight + 0.0001)#Log transformation
qqnorm (lognormalLog)
qqline (lognormalLog) weight.aov <- aov(weight ~ feed, data = chickwts)
plot (weight.aov)summary(weight.aov) # this show that the Pr(>F) or p-value is significant, because is less then 0.05 so we reject the null hypothesis## 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
#yes, I did run a multiple comparison test because the p-value is singnificant, it is less then 0.05
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
#The weight and the feed of the chickens were significantly different (ANOVA p-value = 0.0000). The data was transformed to approximate normality. We run a Tukey HSD multiple comparison test to find out which groups are different. The feeds with a significan p-value (p-value < or = to 0.05) are: Chickens that eat horsebean-casein, linseed-casein, soybean-casein, meatmeal-horsebean, soybean-horsebean, sunflower-horsebean, sunflower-linseed and sunflower-soybean. The feeds with not significan p-value ( equal or > than 0.05) are: meatmeal-casein, sunflower-casein, linseed-horsebean, meatmeal-linseed, soybean-linseed, soybean-meatmeal, sunflower-meatmeal.Please turn–in your homework via Sakai by saving and submitting an R Markdown PDF or HTML file from R Pubs!