# # Exercise 4.4 # # 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 J. Pell, Rothamsted Research # Version 1, 22/09/2014 # Set working directory - use setwd() function or from Session menu in RStudio # e.g. setwd("d:/stats4biol/data) # Set up packages to be used later - available from CRAN library(lsmeans) # tables of predicted means & contrasts # Read data transmission <- read.table("transmission.dat",sep="",header=T) summary(transmission) # One-way ANOVA transmission.aov <- aov(LogitP~Density, data=transmission) summary(transmission.aov) # Tables of predicted means transmission.lsm <- lsmeans(transmission.aov, ~Density) t.means.df <- summary(transmission.lsm); t.means.df # Get contrasts between means with SE = SED t.con <- contrast(transmission.lsm, method="pairwise") t.con.df <- summary(t.con) # Calculate LSD from SED t.con.df$LSD <- t.con.df$SE * qt(0.975,t.con.df$df) t.con.df # Plot of predicted means plot(y=t.means.df$lsmean, x=c(1,5,10), xlim=c(-5,11.5), ylim=c(-1.2,0.4), axes=FALSE, xlab="Treatment", ylab="Predicted mean") arrows(-3,-1,-3,-1+t.con.df$LSD[1], code=3, angle=90) axis(1, at=c(-3,1,5,10), labels=c("LSD","A","B","C")) axis(2, at=c(-1.2,-0.8,-0.4,0,0.4)) # End of file