#Biostatistics 260 #ONE-WAY ANOVA CONTRASTS ZAR=read.table("ZarEX11.1R.txt") ZAR attach(ZAR) Y=conc X=factor(code) options(digits=12) #DESCRIPTIVE STATISTICS: N=length(Y) N k=5 #MEANS: Xbar=tapply(Y,ZAR[,-1],mean) Xbar #NUMBERS: tapply(Y,ZAR[-1],length) #STANDARD DEVIATIONS: tapply(Y,ZAR[-1],sd) #GENERATING ANOVA TABLE: FM=lm(Y~X) anova(FM) #MAKING CONTRASTS IN R require(gmodels) #MUST LOAD {gmodels} PACKAGE FROM CRAN #CONTRAST FOR ZAR Example 11.5 C1=c(0,1/3,1/3,1/3,-1) fit.contrast(FM,X,C1,conf.int=0.95) C2=c(1,-1/3,-1/3,-1/3,0) fit.contrast(FM,X,C2,conf.int=0.95) C3=c(1/2,-1/3,-1/3,-1/3,1/2) fit.contrast(FM,X,C3,conf.int=0.95) C4=c(1/2,-1/2,-1/2,1/2,0) fit.contrast(FM,X,C4,conf.int=0.95)