# # Exercise 5.1a - continues on from Exercise 4.2 # # Statistical Methods in Biology: Design and Analysis of Experiments and Regression # by S.J. Welham, S.A. Gezan, S.J. Clark & A. Mead (2014) # Chapman & Hall/CRC Press, Boca Raton, Florida. ISBN: 978-1-4398-0878-8 # Data from K. Hammond-Kosack, Rothamsted Research # Version 1, 26/09/2014 # Set working directory - use setwd() function or from Session menu in RStudio # e.g. setwd("d:/stats4biol/data) # Read data grains <- read.table("grains.dat",sep="",header=T) summary(grains) # One-way ANOVA grains.aov <- aov(Grains~Treatment, data=grains) summary(grains.aov) # Get simple residuals simple.res <- residuals(grains.aov) # get standardized residuals std.res <- rstandard(grains.aov) # plot standardized against simple residuals plot(y=std.res, x=simple.res) # Check whether ratio is constant? std.res/simple.res # Check distribution of standardized residuals hist(std.res) # Additional material # Verify SE of simple.res # Get estimate s^2 grains.aovt <- summary(grains.aov)[[1]] ResMS <- grains.aovt$"Mean Sq"[2]; ResMS s2 <- ResMS # Get replication of treatments n.table <- aggregate(Grains~Treatment, data=grains, FUN=length) n <- n.table$Grains[1]; n # Calculate SE(simple.res) se.simple = sqrt(s2*(n-1)/n); se.simple # Check inverse = ratio of std.res to simple.res 1/se.simple # End of file